-
Notifications
You must be signed in to change notification settings - Fork 329
Add uniformity analysis opt-out for derivative-using builtins #3644
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
Conversation
1. Localized opt-out: Add unchecked_uniformity attribute It's a fine-grain control that disables uniformity errors for fragment shader builtins that ordinarily are required to execute in uniform control flow. Updates those functions to say they yield an indeterminate value when invoked in non-uniform control flow. 2. Coarse-grain opt out: Add 'fragmentShaderDerivativesCheckedUniformity' boolean field defaulting `true`, in GPUShaderModuleDescriptor When false, weakens the uniformity analysis so no uniformity error is generated for derivative-based collective operations. Fixed: gpuweb#3554
Previews, as seen when this build job started (a78757c): |
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.
As we said in the previous meeting, Mozilla has concerns about the global opt-out. Ignoring those, this looks good, just some suggestions.
wgsl/index.bs
Outdated
Subsequent subsections describe the analysis. | ||
|
||
If [=uniformity analysis=] cannot prove that a particular [[#collective-operations|collective operation]] executes in [=uniform control flow=], then: | ||
* If the operation is a [[#barrier|barrier]], a [=shader-creation error=] results. |
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.
At the moment, we have two alternatives: barriers, and other stuff. But it's specifically derivatives that we believe to have tolerable behavior when things go wrong, so the alternatives should be structured the other way: derivatives get special consideration, consulting the descriptor option; and everything else generates an error.
[=shader-creation error|Must=] only be invoked in [=uniform control flow=], | ||
or the call must have an [=attribute/unchecked_uniformity=] attribute, | ||
or the [=option/fragmentShaderDerivativesCheckedUniformity=] option must be `false`. |
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.
Editorially, it would be nice to define a term that captures these conditions, and then just use that. I think the conditions are going to get worse, not better.
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.
Yeah, there's a balance to be struck.
For now I left it as-is because it's fully explicit. Adding another term for this would cause a cognitive indirection, and many folks like seeing the repetition and explicitness.
If/when these things land I'm open to editorial suggestions, starting with a name for the condition.
Then use it in various places.
Put derivatives first
FYI. I've addressed all the feedback, and in all but one case incorporated it. I also added the ability to put TODO: Write an example showing use of the attribute. |
@@ -6222,6 +6225,7 @@ dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { | |||
required USVString code; | |||
object sourceMap; | |||
record<USVString, GPUShaderModuleCompilationHint> hints; | |||
boolean fragmentShaderDerivativesCheckedUniformity = true; |
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.
u-nit: I think in general it is better to make default values false if we can because undefined
may look like it would coerce to false
, so uncheckedFragmentShaderDerivativeUniformity
?
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.
Right.
Normally I try to define things in the positive sense because I find them easier to understand. I find things like "NDEBUG" confusing.
But I can see that JS practice could supercede that rule of thumb.
WGSL 2022-11-29 Minutes
|
Google is withdrawing this PR in favour of #3683 |
Add unchecked_uniformity attribute
It's a fine-grain control that disables uniformity errors for fragment shader builtins that ordinarily are required to execute in uniform control flow.
Updates those functions to say they yield an indeterminate value when invoked in non-uniform control flow.
true
, in GPUShaderModuleDescriptorWhen false, weakens the uniformity analysis so no uniformity error is generated for derivative-based collective operations.
Fixed: #3554