Fix WGSL location indices generation for varying parameters #8429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where WGSL location indices were not being generated for struct fields in varying parameters, leading to invalid WGSL output with missing
@location()
attributes.Problem
When compiling to WGSL, some struct fields in varying parameters would not receive
@location()
attributes, resulting in invalid WGSL code that fails to parse:Expected output should include location attributes:
Root Cause
The issue occurred in edge cases during the WGSL legalization process where struct fields might not receive semantic decorations. Specifically, in the
ensureStructHasUserSemantic
function, if a field layout didn't have an offset attribute, no semantic decoration would be assigned, causing the WGSL emitter to skip generating@location()
attributes for those fields.Solution
Enhanced the
ensureStructHasUserSemantic
function to ensure robust semantic decoration assignment:Changes
The fix ensures that all varying struct fields receive proper semantic decorations during legalization, which are then correctly emitted as
@location()
attributes in the final WGSL output.Fixes #8388.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.