-
Notifications
You must be signed in to change notification settings - Fork 350
Fix std430 layout support for cbuffers in .slang files #8432
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: bmillsNV <[email protected]>
Co-authored-by: bmillsNV <[email protected]>
Co-authored-by: bmillsNV <[email protected]>
Copilot, I think it needs to warn when layout (std430) etc are used when compiling for other targets (warn instead of error to make it a non-breaking PR), and accept these layout modifiers when compiling for GLSL/SPIRV without requiring |
// Check for GLSL layout qualifiers when GLSL input is allowed | ||
if (parser->options.allowGLSLInput && parser->pendingModifiers) | ||
// Check for GLSL layout qualifiers (layout modifiers can be used even without allowGLSLInput) | ||
if (parser->pendingModifiers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot, I think it needs to warn when layout (std430) etc are used when compiling for other targets (warn instead of error to make it a non-breaking PR), and accept these layout modifiers when compiling for GLSL/SPIRV without requiring -allow-glsl
int2 a[2]; | ||
}; | ||
|
||
ConstantBuffer<B, Std430DataLayout> c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot, for simplicity this ConstantBuffer can be dropped
The
layout(std430) cbuffer
syntax was not working correctly in.slang
files, causing incorrect ArrayStride values in generated SPIR-V. Arrays ofint2
were getting ArrayStride 16 (std140 layout) instead of ArrayStride 8 (std430 layout).The issue occurred because the
parseHLSLCBufferDecl
function only processed GLSL layout qualifiers whenallowGLSLInput
was enabled, but layout parsing itself is always available. This meant that whilelayout(std430)
was parsed and attached as a modifier, it was ignored during cbuffer processing in.slang
files.Before:
After:
This fix ensures that
layout(std430) cbuffer
declarations work consistently whether using.slang
or.glsl
files, and that the generated SPIR-V uses the correct layout rules for buffer members.Fixes #8373.
💡 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.