Skip to content

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

Merged
Keenuts merged 3 commits intomicrosoft:mainfrom
Keenuts:fix-7681
Aug 28, 2025
Merged

[SPIR-V] Fix invalid codegen for empty cbuffers#7717
Keenuts merged 3 commits intomicrosoft:mainfrom
Keenuts:fix-7681

Conversation

@Keenuts
Copy link
Collaborator

@Keenuts Keenuts commented Aug 26, 2025

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 Keenuts requested a review from s-perron August 26, 2025 15:58
@Keenuts
Copy link
Collaborator Author

Keenuts commented Aug 27, 2025

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

@Keenuts Keenuts enabled auto-merge (squash) August 28, 2025 08:14
@Keenuts Keenuts merged commit 4e18ca3 into microsoft:main Aug 28, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Aug 28, 2025
@Keenuts 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

Status: Done

Development

Successfully merging this pull request may close these issues.

[SPIR-V] Invalid codegen for empty cbuffer resources

2 participants