-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix fragment shader subgroup builtin io test #4024
Fix fragment shader subgroup builtin io test #4024
Conversation
This PR fix the expectation of fragment shader subgroup_invocation_id, which can be assigned to inactivate invocations between active ones and therefore go larger than active subgroup invocations number but still smaller than subgroup size. This PR also fix the draw call for fragment subgroup tests.
A more detailed explanation: I have write a webpage to help illustrating the subgroup dispatching in fragment shader, and a screenshot of drawing lower-right triangle of framebuffer of size 17*5 on Intel UHD770 is as below. In this case subgroup size is 16. The invocations of a subgroup are marked with same background color, and I mark the inactive invocations together with active ones for subgroup "43" (representation Id). The 2x2 pattern is clear, and we can see how inactivate invocations take some subgroups ids. |
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.
The changes to the checker code look sound, but they don't seem to match the code that is run. If we can resolve that this definitely looks more robust.
src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts
Outdated
Show resolved
Hide resolved
Tried to assert all outputs are zero for fragment that I thought this is due to currently we get the I think I need to change the way we get |
Things could be tricky since we don't know which invocation will be active in compile time, and |
There is |
A terrible but workable (should it?) solution is:
And also store the subgroup ballot result of each fragment to indicate which results comes from inactive invocation and should be ignored.
|
This still rely on subgroup ballot to filter the result, and it would be wrong if helper lane also take part in the ballot (will it?) but don't compute the correct |
Here's an alternative maybe:
Then we can check that for all pixels, What do you think? |
This would check that each And we can also check |
I suppose if the invocation is inactive it doesn't really matter which id it is assigned, but I agree the select condition is better formulated as an inequality. The secondary check makes sense too. |
Please take a look, thanks! |
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.
Thanks for this fix! I also tested it on my Macbook M1.
Thanks for reviewing! |
This PR fix the expectation of fragment shader
subgroup_invocation_id
, which can be assigned to inactivate invocations between active ones and therefore go larger than active subgroup invocations number but still smaller than subgroup size. This PR also fix the draw call for fragment subgroup tests. With this PR, tests can passed on Intel devices.