Compat: Limit the number of texture+sampler combinations - #4989
Conversation
|
Previews, as seen when this build job started (a9a0f02): |
|
|
||
| ## 20. Limit the number of texture+sampler combinations in a pipeline. | ||
|
|
||
| If the number of texture+sampler combinations used a in single stage in a pipeline exceeds |
There was a problem hiding this comment.
Should we clarify that combinations includes textures without samplers as well?
There was a problem hiding this comment.
Yikes. That's an interesting issue. A texture used without a sampler counts as 1 but only if it's not used somewhere else? Or do we keep it simple? In other words, if you have
@group(0) @binding(0) var t: texture_2d<f32>;
@group(0) @binding(1) var s: sampler;
x = textureLoad(t);
y = textureSampler(t, s);That's seems like it only counts as 1 combo
I'm not sure the easiest way to state that.
The number of texture+sampler combinations is counted by first counting the number of texture+sampler combinations, then adding 1 for every texture used without a sampler that's not already counted.
or something like that?
Or do we count the example above as 2 combos? [(t+s), (t)]
There was a problem hiding this comment.
Checking dawn with the code above it only created 1 uniform sampler2D
There was a problem hiding this comment.
I think it should be 1 combo. Probably can be stated as essentially max(used without sampler ? 1 : 0, number of texture sampler combos)
There was a problem hiding this comment.
Is this also complicated by external texture? It seems like it is like maybe it should be min(maxSampledTexturesPerShaderStage - numExternalTexturesUsedInStage * 4, maxSamplersPerShaderStage - numExternalTexturesUsageInStage * 2)
There was a problem hiding this comment.
I'm not sure max(used without sampler ? 1 : 0, number of texture sampler combos) is correct. I reverted it back to how it was before for now
max(used without sampler ? 1 : 0, number of texture sampler combos) would make sense if it said something like,
The number of texture+sampler combinations is counted as follows:
sum = 0; for each texture used in entry point sum += max(texture+sampler combos for texture, texture used without sampler ? 1 : 0)
or something like that
There was a problem hiding this comment.
I think that is what I had in mind, I didn't sketch it very carefully. Though just realizing, the 0/1 is accounted for by the bind group layouts, and it doesn't matter if it's actually used with textureLoad? So:
for each stage of the pipeline:
sum = 0
for each texture binding in the pipeline layout which is visible to that stage:
sum += max(1, number of texture sampler combos for that texture binding)
Good point about external texture, that definitely needs to be explicit about how it interacts with this limit. The internal resources of an external texture are explained in the note here: https://gpuweb.github.io/gpuweb/#gpuexternaltexture
So the accounting (https://gpuweb.github.io/gpuweb/#exceeds-the-binding-slot-limits) would add something like this, via the logic above:
sum += 1 // for LUT texture + LUT sampler
sum += 3 * max(1, number of external_texture sampler combos) // for Y+U+V
Note: this test would have surfaced a compat issue if it already existed. The issue gpuweb/gpuweb#4989 was raised and this test tests in both compat and core that an implemation can use all the texture and sample combinations it is supposed to.
ec4ef7d to
a9a0f02
Compare
Note: this test would have surfaced a compat issue if it already existed. The issue gpuweb/gpuweb#4989 was raised and this test tests in both compat and core that an implemation can use all the texture and sample combinations it is supposed to.
Note: this test would have surfaced a compat issue if it already existed. The issue gpuweb/gpuweb#4989 was raised and this test tests in both compat and core that an implemation can use all the texture and sample combinations it is supposed to.
Resolves #4986