Compat: update new limits proposal#5034
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? |
kainino0x
left a comment
There was a problem hiding this comment.
LGTM so far, might add some of the details you posted in comments though
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
|
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 numNeededMy understanding of (2) is that, no, this code won't work. Because Did I misunderstand (2)? |
Co-authored-by: Jim Blandy <jimb@red-bean.com>
|
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
|
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Effectively, in both compat and core, requesting limits for
maxStorageBuffersInFragmentStageand/ormaxStorageBuffersInVertexStagethat are greater thanmaxStorageBuffersPerShaderStageis an error.Similarly, in both compat and core, requesting limit for
maxStorageTexturesInFragmentStageand/ormaxStorageTexturesInVertexStagethat are greater thanmaxStorageTexturesPerShaderStageis 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
maxStorageXXXInXXXStagelimits.