-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Nodes: Struct extension proposal #29760
Comments
@sunag I noticed that there is already a method in the WGSLNodeBuilder PS: matrices already work with storage buffers so I withdrew the PR |
the structs methods were added for rendering to multiple render targets in a single pass, so aren't a complete implementation of structs in WGSL. For example an assumption that all elements are vec4() is built in at the moment. |
Thanks for the explanation aardgoose. |
I also see advantages in having a const example = struct({
someVector4: 'vec4',
someVector3: 'vec3',
someScalar: 'float'
});
const structBuffer = structArray( example, count ); |
I like the idea of the structArray. I had also seen the struct optionally as a structArray, hence the .push() to add elements. But two cleanly separated nodes with struct and structArray is better. |
I thought about the topic a little again. I think I have an idea. I would like to explain this using this code that I work with:
Using node elements in it would be more cumbersome. The node system is intended to be a help and not to complicate a simple way to summarize data I then use this function like this:
This way I can easily bundle any datas in a storage. But what is missing now is the struct. But this can be solved much more easily and elegantly with a new method for the storageBufferArrays.
Without set structNames then the WGSLNodeBuilder works normally and treats the storage as vec4 elements because of the 4 in my StorageBufferAttribute example. So everything is as usual and fine. However, if the WGSLNodeBuilder sees that structNames are given to the storageBufferAttribute, then the node builder does not build arrays as it does by default but simply struct arrays. Setting the name list can then also set a flag isStructStorage = true;. Another option is a setStuct function. With this you could also specify the data types, which makes it possible to use mixed types.
|
Description
I'm ready to get to work on this myself, but I'd like to hear your opinion on my ideas. Better I ask before I Investing energy and time in a way that you don't consider good.
After the initial euphoria about Aardgoose's bundler expansion, disillusionment followed in the days that followed.
The extension is great because it takes care of all the uniforms that I as a user don't want to take care of myself.
But it is not intended for storageBuffers. So far we only use the storageBuffers in analogy to attributes. In WebGPU you would like to use entire parameter sets with storage buffers in compute shaders. If uniform had an additional flag that we would call struct, then that would be a clean distinctive feature. Then at this point the WGSLNodeBuilder would make a case distinction as to whether it is a struct or not and at if false, the previous code is executed and if true, we can run a structbuilder without any risks.
What I don't yet see clearly is how the struct content is best transported into the WGSLNodeBuilder using the uniform.
But with this you could store worldMatrices, boundingSphere, ... of every instance of a mesh in a storageBuffer.
This means that almost anything can be brought into the compute shader for processing in order to exploit the big potential of WebGPU.
A new node is necessary for this, e.g. struct and I imagine it like this.
The struct built by the WGSLNodeBuilder would then look like this:
If you see it as a good way, I'm willing to invest a lot of time and energy myself.
Solution
Described in the description
Alternatives
Lots of individual storage buffers and in the case of matrices no sensible solution.
Additional context
No response
The text was updated successfully, but these errors were encountered: