-
Notifications
You must be signed in to change notification settings - Fork 713
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
[SPIR-V] Multiple variables with TaskPayloadWorkgroupEXT in task/amplification shaders #5981
Comments
cc @tywuAMD |
Thanks for identifying this @godlikepanos . @cassiebeckley Can you look into this? Relevant spec: https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/EXT/SPV_EXT_mesh_shader.html And it looks like adding this to spirv-val is already being tracked here: KhronosGroup/SPIRV-Tools#4919 |
this seems like a related problem to KhronosGroup/SPIRV-Tools#4969 (comment) where there are more than 1 RayTracing StorageClass Variable |
Hi. Is there a chance this can be prioritized? On top of the problems it causes on RenderDoc (the mesh view in RenderDoc doesn't work when there are multiple TaskPayloadWorkgroupEXT) it also causes issues on AMD. AMD confirmed that their driver's compiler fails to link the task and mesh shaders because of the issue |
for notes, I think this was added already for Ray Tracing shaders |
@cassiebeckley feel free to re-assign this to me if you don't have bandwidth for it right now. |
The existing logic from VK_NV_mesh_shader was incorrectly adapted for the VK_EXT_mesh_shader implementation when it comes to the handling of mesh payloads as in/out variables. Because TaskPayloadWorkgroupEXT must be applied to a single global OpVariable for each Task/Mesh shader, the struct should not be flattened. Further, as far as I can tell, Location assignment is not necessary for these input and output variables, so the usual reason for flattening structs does not apply. This change now removes the inner struct member global variables and ensures the parent payload is decorated with TaskPayloadWorkgroupEXT. Note that for amplification/task shaders, the payload variable is created with the groupshared decl, and then it's storage class needs to be updated when that variable is used as a parameter to the DispatchMesh call, as described in: https://docs.vulkan.org/spec/latest/proposals/proposals/VK_EXT_mesh_shader.html#_hlsl_changes Tested with updated spirv-val from: KhronosGroup/SPIRV-Tools#5640 Fixes microsoft#5981
) The existing logic from `VK_NV_mesh_shader` was incorrectly adapted for the `VK_EXT_mesh_shader` implementation when it comes to the handling of payloads as in/out variables. Because `TaskPayloadWorkgroupEXT` must be applied to a single global `OpVariable` for each task/mesh shader, the struct should not be flattened. Further, Location assignment is not necessary for these input and output variables, so the usual reason for flattening structs does not apply. This change now removes the inner struct member global variables and ensures the parent payload is decorated with `TaskPayloadWorkgroupEXT`. Note that for amplification/task shaders, the payload variable is created with the `groupshared` decl, and then its storage class needs to be updated when that variable is used as a parameter to the `DispatchMesh` call, as described in: https://docs.vulkan.org/spec/latest/proposals/proposals/VK_EXT_mesh_shader.html#_hlsl_changes Tested with new validation checks from: KhronosGroup/SPIRV-Tools#5640 Fixes #5981
Description
When the task payload is a struct the SPIR-V backend generates multiple variables with TaskPayloadWorkgroupEXT (one variable per member of the struct actually). The spec states that only a single TaskPayloadWorkgroupEXT variable can exist.
Steps to Reproduce
Here is a simple task shader:
Compiling with
-T as_6_7 -E main -spirv -fspv-target-env=vulkan1.1spirv1.4
it gives the following SPIR-V:You can play with the shader in compiler explorer: https://godbolt.org/z/hPEnx68E3
As you can see there are two TaskPayloadWorkgroupEXT variables (
out_var_index1
andout_var_index2
) which is wrong.Note no1: It seems the code generated is not generally optimal. The s_payload is decorated as groupshared in SPIR-V and at DispatchMesh() the compiler will emit copies from s_payload to a new set of TaskPayloadWorkgroupEXT variables. It would have been preferable if s_payload was decorated as TaskPayloadWorkgroupEXT and the extra copies are removed.
Note no2: Similar problem exists in the mesh shaders where DXC will take the struct of a
payload
and create multiple global TaskPayloadWorkgroupEXT variables.Actual Behavior
Ideally the
s_payload
is not decorated as groupshared but as TaskPayloadWorkgroupEXT and the copies from groupshared to TaskPayloadWorkgroupEXT are removed.Environment
The text was updated successfully, but these errors were encountered: