Skip to content

[SPIR-V] Fix invalid codegen for empty cbuffers - #7717

Merged
Nathan Gauër (Keenuts) merged 3 commits into
microsoft:mainfrom
Keenuts:fix-7681
Aug 28, 2025
Merged

Nathan Gauër (Keenuts) merged 3 commits into
microsoft:mainfrom
Keenuts:fix-7681

Conversation

@Keenuts

Copy link
Copy Markdown
Collaborator

Each variable in the Uniform/Uniform Constant storage class must be decorated with DescriptorSet + Binding.
-> VUID-StandaloneSpirv-UniformConstant-06677

When a cbuffer was empty (or only contained resources), an empty struct and variable in the uniform storage class was created. Because the cbuffer was empty, no binding/descriptor set was assigned, hence no decoration was emitted.

This was fine as long as we compiled with optimizations on, as DCE would get rid of this unused cbuffer. But compiling with -O0 would yield a validation error.

Fixes #7681

Each variable in the Uniform/Uniform Constant storage class must be
decorated with DescriptorSet + Binding.
-> VUID-StandaloneSpirv-UniformConstant-06677

When a cbuffer was empty (or only contained resources), an empty
struct and variable in the uniform storage class was created.
Because the cbuffer was empty, no binding/descriptor set was assigned,
hence no decoration was emitted.

This was fine as long as we compiled with optimizations on, as DCE would
get rid of this unused cbuffer. But compiling with -O0 would yield a
validation error.

Fixes microsoft#7681
@Keenuts

Copy link
Copy Markdown
Collaborator Author

The 2 failures in the CI are due to apt-get failing to get some dependencies. Not related to this PR.

@Keenuts
Nathan Gauër (Keenuts) enabled auto-merge (squash) August 28, 2025 08:14
@Keenuts
Nathan Gauër (Keenuts) merged commit 4e18ca3 into microsoft:main Aug 28, 2025
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Aug 28, 2025
@Keenuts
Nathan Gauër (Keenuts) deleted the fix-7681 branch August 28, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[SPIR-V] Invalid codegen for empty cbuffer resources

2 participants