Skip to content
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

Add EXT_mesh_shader validation support #5640

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

pmistryNV
Copy link
Contributor

@pmistryNV pmistryNV commented Apr 10, 2024

  1. Each OpEntryPoint with the MeshEXT Execution Model can have at most one global OpVariable of storage class TaskPayloadWorkgroupEXT.
  2. PerPrimitiveEXT only be used on a memory object declaration or a member of a structure type
  3. PerPrimitiveEXT only Input in Fragment and Output in MeshEXT
  4. Added Mesh vulkan validation support for following rules: VUID-Layer-Layer-07039 VUID-PrimitiveId-PrimitiveId-07040,VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042, VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048, VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07054, VUID-ViewportIndex-ViewportIndex-07060 VUID-StandaloneSpirv-ExecutionModel-07330 VUID-StandaloneSpirv-ExecutionModel-07331

For bug #4919

@pmistryNV pmistryNV force-pushed the mesh_shader_Validation branch 2 times, most recently from fdd61c9 to 7e583d0 Compare April 10, 2024 22:24
@pmistryNV
Copy link
Contributor Author

@spencer-lunarg kindly review.

Copy link
Contributor

@spencer-lunarg spencer-lunarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to do a deep review soon, but some small nits from a quick scan

source/val/validate_builtins.cpp Outdated Show resolved Hide resolved
source/val/validate_mesh_shading.cpp Outdated Show resolved Hide resolved
source/val/validate_builtins.cpp Outdated Show resolved Hide resolved
source/val/validate_annotation.cpp Outdated Show resolved Hide resolved
source/val/validate_annotation.cpp Outdated Show resolved Hide resolved
source/val/validate_builtins.cpp Outdated Show resolved Hide resolved
source/val/validate_decorations.cpp Outdated Show resolved Hide resolved
sudonatalie added a commit to sudonatalie/DirectXShaderCompiler that referenced this pull request Apr 12, 2024
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
sudonatalie added a commit to microsoft/DirectXShaderCompiler that referenced this pull request Apr 17, 2024
)

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
@spencer-lunarg
Copy link
Contributor

@pmistryNV any update on the changes for this PR?

@danginsburg
Copy link
Contributor

Any updates on when this might be completed? I'm adding VK_EXT_mesh_shader support to our engine and would like to make sure validation is hooked up properly.

@KarenGhavam-lunarG
Copy link

Any updates on when this might be completed? I'm adding VK_EXT_mesh_shader support to our engine and would like to make sure validation is hooked up properly.

It would be good to know when this will be completed. I have had people from the ecosystem complain about lack of validation support for this extension

@pmistryNV pmistryNV force-pushed the mesh_shader_Validation branch 2 times, most recently from b45cd0d to d46e54b Compare January 7, 2025 07:36
source/val/validate_builtins.cpp Show resolved Hide resolved
source/val/validate_builtins.cpp Show resolved Hide resolved
@pmistryNV pmistryNV force-pushed the mesh_shader_Validation branch from 1bdf304 to da790d9 Compare January 9, 2025 19:00
Copy link
Contributor

@alan-baker alan-baker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spencer-lunarg any outstanding issue from your POV?

@spencer-lunarg
Copy link
Contributor

@spencer-lunarg any outstanding issue from your POV?

No - will there are the 3 VUs todo yet, but will update the issue afterward, this PR as is good IMO

@alan-baker
Copy link
Contributor

@pmistryNV Can you please rebase and fix the formatting issues?

@pmistryNV
Copy link
Contributor Author

@pmistryNV Can you please rebase and fix the formatting issues?

Doing it right now

@alan-baker
Copy link
Contributor

There are still some formatting errors.

1. Each OpEntryPoint with the MeshEXT Execution Model can have at most one global OpVariable of storage class TaskPayloadWorkgroupEXT.
2. PerPrimitiveEXT only be used on a memory object declaration or a member of a structure type
3. PerPrimitiveEXT only Input in Fragment and Output in MeshEXT
4. Added Mesh vulkan validation support for following rules:
   VUID-Layer-Layer-07039 VUID-PrimitiveId-PrimitiveId-07040
   VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07042
   VUID-PrimitivePointIndicesEXT-PrimitivePointIndicesEXT-07046
   VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07048
   VUID-PrimitiveLineIndicesEXT-PrimitiveLineIndicesEXT-07052
   VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07054
   VUID-PrimitiveTriangleIndicesEXT-PrimitiveTriangleIndicesEXT-07058
   VUID-ViewportIndex-ViewportIndex-07060
   VUID-StandaloneSpirv-ExecutionModel-07330
   VUID-StandaloneSpirv-ExecutionModel-07331
   VUID-PrimitiveId-PrimitiveId-04336
   VUID-Layer-Layer-07039
   VUID-ViewportIndex-ViewportIndex-07060

   VUID-CullPrimitiveEXT-CullPrimitiveEXT-07034
   VUID-CullPrimitiveEXT-CullPrimitiveEXT-07035
   VUID-CullPrimitiveEXT-CullPrimitiveEXT-07036
@pmistryNV pmistryNV force-pushed the mesh_shader_Validation branch from 0d398a4 to c7f3a1e Compare January 14, 2025 19:30
@alan-baker alan-baker merged commit fdea641 into KhronosGroup:main Jan 15, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants