-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper vs Proper Vertex Allignment when Writing to Vertex Buffer From Compute Shader #351
Conversation
Test Merge
Merge main into my fork
Merge Main
Merge main into my fork.
Merge branches
Thanks for writing this! I do think it's a little too niche to be a "sample". I think it would be great to have something explaining and/or showing this alignment issue, perhaps on https://webgpufundamentals.org/ if there isn't something already. WebGPU fundamentals is also in this Github org at https://github.com/webgpu/webgpufundamentals. @greggman maintains it - what do you think? |
I'd also agree it's too niche for it's own example, even if it would be more germane for a website like https://webglsamples.org/. It could possibly be folded into one of the existing samples. For instance, an option could be added to Rotating Cube to modify the vertex positions in either the vertex or the compute shader, demonstrating how vec3fs need to be handled differently depending on the shader context. The general purpose of the original example (sending uniforms to a shader to modify a mesh), would be maintained, but additional information about manipulating vertex data would be added. However, that might obfuscate or distract from the original intention of that shader, or any other shader such an option might be applied to. As for the webgpufundamentals suggestion, a section could probably be added to https://webgpufundamentals.org/webgpu/lessons/webgpu-vertex-buffers.html, potentially containing a redirect to https://toji.dev/webgpu-best-practices/compute-vertex-data. |
Sounds great to me. I don't think the current format of webgpu-samples is suitable right now to explain this alignment detail |
Not sure if this would be too niche or low density of an example, but inspired by Toji's article (https://toji.dev/webgpu-best-practices/compute-vertex-data) on handling vertex data in compute shaders, I've created this simple sample showing how shaders that seemingly perform the same result can fail to execute depending on how vertex data is interpreted by the compute shader.
The example is mostly done, with tweaks only really needed for additional comments, explanations, or questions about the validity of the example as a test case when compared to other samples which much more comprehensively exhibit WebGPU's capabilities rather than addressing a small consideration one needs to take when handling vertex data in compute shaders.