-
Notifications
You must be signed in to change notification settings - Fork 335
Compat: update new limits proposal #5034
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
See the proposal: Effectively, in both compat and core, requesting limits for `maxStorageBuffersInFragmentStage` and/or `maxStorageBuffersInVertexStage` that are greater than `maxStorageBuffersPerShaderStage` is an error. Similarly, in both compat and core, requesting limit for `maxStorageTexturesInFragmentStage` and/or `maxStorageTexturesInVertexStage` that are greater than `maxStorageTexturesPerShaderStage` is an error. Assume the adapter supports 16 of each: ```js requiredLimits: { maxStorageBuffersInFragmentStage: 3, } ``` In compat this return a device with ```js limits: { maxStorageBuffersInFragmentStage: 3, maxStorageBuffersPerShaderStage: 4, } ``` In core it returns a device with ```js limits: { maxStorageBuffersInFragmentStage: 4, maxStorageBuffersPerShaderStage: 4, } ``` Another example: ```js requiredLimits: { maxStorageBuffersInFragmentStage: 9, maxStorageBuffersPerShaderStage: 10, } ``` In compat this return a device with ```js limits: { maxStorageBuffersInFragmentStage: 9, maxStorageBuffersPerShaderStage: 10, } ``` In core it returns a device with ```js limits: { maxStorageBuffersInFragmentStage: 10, maxStorageBuffersPerShaderStage: 10, } ```
Previews, as seen when this build job started (241f25f): |
To add to this, maybe another way talk about it is to list what happens in each situation
What's valid for
|
Same validation makes sense to me, it's a bit less surprising. In both compat and core there's a theoretical possibility of someone doing something like
We don't actually have to write in the spec that they're ignored, right? |
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.
LGTM so far, might add some of the details you posted in comments though
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Sigh.... this topic is being discussed in about 9 places. I wrote a bunch of comments in one of them but I can't find them today. Maybe I forgot to submit. I know Kai wrote a comment I was responding to but I can't find that one either. Mine was about suggesting Places I checked #5033 #5013 #5029 #5037 #5036 #5018 In any case, trying to update the CTS has pointed out some issues. Namely that you can write code that runs locally but fails elsewhere. Since requiredLimits: {
maxXXXInShaderStage: adapter.limits.maxXXXInShaderStage,
} If the value is less <= 4 you don't get an error so you think your code works but it doesn't. It occured to me last night, maybe instead of it being a validation error, if the requested wdyt? |
Great point, seems like a validation error won't work. Without a validation error, if you ask for PerStage < InFragmentStage then I think there's 3 other possibilities:
1 and 2 have the same result except for whether |
|
Ah right, it would require a carveout that says core just ignores those. Not sure if there are any other problems. Fine with me to not consider this further.
It depends on whether you consider the limit by itself (which yes will be lower than requested) or the limits as a whole. It wouldn't change the enforced limit (which is still |
Maybe I'm misunderstanding but, it feels like this code is valid const numNeeded = 6;
if (adapter.limits.maxSomeLimit < numNeeded) {
// tell user they can't run my app
}
const device = adapter.requestDevice({
requiredLimits: { maxSomeLimit: numNeed },
});
// use numNeeded My understanding of (2) is that, no, this code won't work. Because Did I misunderstand (2)? |
Co-authored-by: Jim Blandy <[email protected]>
I think better in code so here's the proposal in code requestDevice({ requestedLimits }) {
// make a copy of the requested limits
const effectiveRequestedLimits = { ...requestedLimits };
// update the effective requested limits
effectiveRequestedLimits.maxStorageBuffersPerShaderStage = Math.max(
requestedLimits.maxStorageBuffersInFragmentStage,
requestedLimits.maxStorageBuffersInVertexStage,
requestedLimits.maxStorageBuffersPerShaderStage);
effectiveRequestedLimits.maxStorageTexturesPerShaderStage = Math.max(
requestedLimits.maxStorageTexturesInFragmentStage,
requestedLimits.maxStorageTexturesInVertexStage,
requestedLimits.maxStorageTexturesPerShaderStage);
// request the device using the effectiveRequestedLimits following the normal
// validation rules. If any requested limit exceeds the adapter's limit then
// throw an OperationError
// device creation succeeded
if (featureLevel === 'core') {
// this effectively leaves core validation the same as it has always been.
device.limits.maxStorageBuffersInFragmentStage = device.limit.maxStorageBuffersPerShaderStage;
device.limits.maxStorageBuffersInVertexStage = device.limit.maxStorageBufferPerShaderStage;
device.limits.maxStorageTexturesInFragmentStage = device.limit.maxStorageTexturesPerShaderStage;
device.limits.maxStorageTexturesInVertexStage = device.limit.maxStorageTexturesPerShaderStage;
} With the limits set as above, apply the validation as specified in the proposal at |
GPU Web WG 2025-01-22 Atlantic-time
|
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.
small nits, LGTM
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Effectively, in both compat and core, requesting limits for
maxStorageBuffersInFragmentStage
and/ormaxStorageBuffersInVertexStage
that are greater thanmaxStorageBuffersPerShaderStage
is an error.Similarly, in both compat and core, requesting limit for
maxStorageTexturesInFragmentStage
and/ormaxStorageTexturesInVertexStage
that are greater thanmaxStorageTexturesPerShaderStage
is an error.Assume the adapter supports 16 of each:
In compat this return a device with
In core it returns a device with
Another example:
In compat this return a device with
In core it returns a device with
This reflects what is actually enforced. Another option is to have core report the same as compat even though it would not enforce the
maxStorageXXXInXXXStage
limits.