-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WIP: Initial stub for mesh shaders #3236
Conversation
The Click to expand the list of errors ocurred..monocodus |
2 similar comments
The Click to expand the list of errors ocurred..monocodus |
The Click to expand the list of errors ocurred..monocodus |
Thank you, that's amazing to see! I'll do a proper review shortly. IIRC from WebGPU discussions, the whole idea of the mesh shaders was kicked off by some research work of doing them on compute, long before it became available in hardware/drivers. Therefore, compute path should be possible, even if not as efficient. I'd like us to have that path available at some point. We have |
Only if Vulkan or D3D12 define a separate pipeline kind for this. As far as I see from a brief look, it's all the same graphics pipeline, just a bunch of stages are replaced. So let's keep it
Can we have an enum? enum PrimitiveAssemer {
Vertex(InputAssemer, VertexBuffers),
Mesh(...),
} |
I will try to summarise here what options I see. Firstly, just the struct itself:
Secondly, there is a question of
Since I have started writing about breakage of the API, I have realised that the API of As you are the maintainer, you should choose the course of action and I will modify the code accordingly. |
Right, I don't think we should try too hard to avoid API breakage here. Consider this to be experimental, we'll adjust as we go, and
I think we can do better than that. We can exclude the task and mesh stages from the graphics shader set and put them here: enum PrimitiveAssember<'a, B> {
Vertex {
buffers: Vec<VertexBufferDesc>,
attributes: Vec<AttributeDesc>,
input_assember: InputAssemblerDesc,
},
Mesh {
task_shader: EntryPoint<'a, B>,
mesh_shader: EntryPoint<'a, B>,
},
} |
+1 for the enum variant - totally replacing the GraphicsShaderSet might be an option here and move all old pipeline stages into the Vertex variant. Fragment shader entrypoint could live then as field in the GraphicsPipelineDesc or be part of some other sub desc. |
I updated the API with the Enum idea. I must admit that the solution is slowly growing on me. I also added 2 new errors to the pipeline CreationError, one for when the mesh shader is not supported and the other one for when the vertex stage is missing in vertex primitive assembly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I believe this is great amount of good work here.
Just a few notes on how we should polish this more before landing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looks like we are almost there :)
We have one final big problem to resolve that I just realized. There is one major difference between DX12 and Vulkan. I modelled the API according to Vulkan, which is currently the lowest common denominator. Alternative could be:
Maybe this will change with KHR version of the extension and we should wait until then. Unless, NVIDIA/Khronos/AMD could give use some more formation. |
Let's model this after Vulkan for now, and then reconsider when KHR extension comes out. |
I will leave It as is It is then.
I thought you were part of Khronos on behalf of Mozilla :D. What I would give for being part of Khronos. No, I am merely a master's student who is using WebGPU for my diploma thesis and I wanted to use mesh shaders for that. |
I am a part of Khronos, just having more than I can chew on my plate. I can dive and check the archives though to see where things are going, at least. |
bors try |
tryBuild failed: |
Could you rebase and squash please? |
Done. |
bors try |
tryBuild failed: |
I'm confused as to why some PRs are landing fine, and others aren't :/ |
Initial stub for mesh shaders to flesh out the API changes. Stub mesh shaders address some details DX12: remove mesh shaders from the indented block Improve the code based on review fix metal backend
@kvark CI finally succeeded! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
bors r+
Build succeeded: |
This is my attempt at adding support for mesh shaders.
This (first) PR only stubs the API. From my investigation, the extension is relatively simple(it effectively only adds new shaders and 3 draw commands mirroring the original ones) and seems to be the same across Direct3D and Vulkan.
Even though the Vulkan only has NV extension so far, based on announcements of RDNA2 and DirectX Ultimate we can expect KHR version and I don't see how it could diverge in any way. Thus, both Vulkan and DX12 implementations should be trivial.
I know nothing about Metal and I am not aware of information about support for mesh shaders. At worst, they could be emulated using compute shaders but It would probably be so slow that It would be practically worthless.
Tasks:
PR checklist:
make
succeeds (on *nix)make reftests
succeedsrustfmt
run on changed codeResources:
Vulkan specification of mesh shaders
DirectX specification of mesh shader