-
Notifications
You must be signed in to change notification settings - Fork 832
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
No compiler error thrown when a non-constant ID is passed to subgroupBroadcast #1591
Comments
I did not write this area, but the tests themselves don't use a constant, and are based on @sheredom, do you know? |
The fix, if it should be fixed, is shown in https://github.com/KhronosGroup/glslang/tree/subgroupBroadcast-const-id. |
So the way I wrote the spec it should be an integral constant expression. Does your fix work for specialisation constants too? |
Right. But, the tests heavily rely on non-constants and would have to be rewritten, hence questioning what's appropriate, especially if the test pattern is a realistic one.
That should work as it does generally, meaning yes, where specialization constants are a subclass of constants. |
Honestly I can't remember now why we required it to be an integral constant expression. For what its worth HLSL only requires their equivalent WaveReadLaneAt to be uniform https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/wavereadlaneat And on our implementation we only actually require it to be a uniform value. |
The tests are written exclusively in terms of an
|
Right, so that should never have been valid for subgroupBroadcast - that is the differentiation between subgroupBroadcast and subgroupShuffle -> shuffle allows a fully dynamic id. |
Okay, I will change the tests to use a constant. |
Can you sign off on #1592? |
GLSL: Fix #1591: Require the id in subgroupBroadcast to be constant.
Broadcasting the last lane results in an error (using today's ToT glslang):
|
@allanmac, that's correct. You really want to use Also, be careful doing that as you don't know that the last lane is actually active. Even in compute shaders, there is no guarantee that all lanes are active. |
gl_SubgroupSize is not a constant. See KhronosGroup/GLSL#19. |
Not being able to broadcast the final lane is unfortunate since a "prefix sum followed by a broadcast" is a very common compute idiom. It's creating more work for the developer to have to define what is essentially subgroupBroadcastLast(). |
These points should be made in KhronosGroup/GLSL#19. |
From the GL_KHR_shader_subgroup spec:
However, putting in a non-constant expression works fine in GLSLang. Incidentally, it also works fine in our driver so I could easily see shader authors (apparently myself included) mistaking
subgroupBroadcast
forsubgroupShuffle
and a compile error would significantly help.The text was updated successfully, but these errors were encountered: