-
Notifications
You must be signed in to change notification settings - Fork 829
Add GroupSharedLimit attribute support for Mesh, Amp and Node shaders #8140
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: main
Are you sure you want to change the base?
Add GroupSharedLimit attribute support for Mesh, Amp and Node shaders #8140
Conversation
JoeCitizen
commented
Feb 4, 2026
- Adds support for the GroupSharedLimit feature for Mesh, Amplification and Node shaders.
- Tests for each of those shader types
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimitAmplification.hlsl
Outdated
Show resolved
Hide resolved
tex3d
left a comment
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.
With minor suggested changes from earlier resolved comment, tests could easily check some more interesting edge cases that I've pointed out. As it stands, I'm not sure the update truly addressed the resolved comment from earlier.
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimitAmplification.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimitMesh.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimitNode.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimitNodeError.hlsl
Outdated
Show resolved
Hide resolved
tools/clang/test/HLSLFileCheckLit/hlsl/entry/attributes/GroupSharedLimit.hlsl
Outdated
Show resolved
Hide resolved
tex3d
left a comment
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.
Diagnostics need overhaul, but I've provided a suggested implementation.
V-FEXrt
left a comment
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.
Generally LGTM but the more I sat with it, the more I think we need to do something about the -1 magic. Happy to leave it up to you on exactly what to do but it should be named in some manner
include/dxc/DXIL/DxilFunctionProps.h
Outdated
| Node.LaunchType = DXIL::NodeLaunchType::Invalid; | ||
| Node.LocalRootArgumentsTableIndex = -1; | ||
| groupSharedLimitBytes = 0; | ||
| groupSharedLimitBytes = -1; |
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.
I won't block on this, but I feel that using magic numbers to encode information is generally a bad idea.
If you want to encode so notion of "not-set" using something like std::optional is more appropriate
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.
I think I've now deduced that -1 -> Use max size? That seems a bit counterintuitive to me but probably a named constant is enough to clear that up
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.
I generally I agree, I was following the convention that appears to be set in the line above where LocalRootArgumentsTableIndex is initialised to -1
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.
Generally, we either need a special value for "unset" or an additional flag somewhere. We can add a define for this to make the code semantically better, or we can add another field/flag. Adding a flag won't change or require more metadata because this should be preserved by whether the extended metadata tag is present at all, not by any special value. We could even add accessors (get/set/isSet/unset) to keep the flag in sync. Though just adding a special defined value for "unset" seems like the simplest solution.
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.
@V-FEXrt: -1 doesn't mean "max size", it means the default isn't overridden for the shader entry. The max size used when not overridden by the shader is a long-standing default value from defines (32k for compute-like shaders except mesh shader which is 28k). The shader can set a larger size than that default, and if it uses more than the default, the runtime will check device capability to make sure the shader can run.
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.
Oh yeah, given this definition, I think std::optional would work fine instead of an explicit flag and extra accessors defined in this class.
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.
Makes sense, to be clear, I'm not specifically set on std:optional, I would be happy with a simple #define, we just have a lot of -1s floating around in the PR. even something like GS_USE_DEFAULT_SIZE would make the later code a lot easier to read
lib/DXIL/DxilMetadataHelper.cpp
Outdated
|
|
||
| const hlsl::ShaderModel *SM = GetShaderModel(); | ||
| if (SM->IsSMAtLeast(6, 10)) { | ||
| if (SM->IsSMAtLeast(6, 10) && props.groupSharedLimitBytes != -1) { |
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.
More important than using std::optional, this should be named in some manner[1]. What does it mean that grouSharedLimitBytes is -1?
[1]: my personal preference would be a tiny helper function but I'm flexible. Another option is defining as constant for -1 with a name that gives enough context to the meaning
Co-authored-by: Damyan Pepper <[email protected]>
Co-authored-by: Damyan Pepper <[email protected]>
|
✅ With the latest revision this PR passed the C/C++ code formatter. |