|
| 1 | +export const description = ` |
| 2 | +Tests that, in compat mode, you can not create a pipeline layout with with |
| 3 | +more than the max in stage limit even if the per stage limit is higher. |
| 4 | +`; |
| 5 | + |
| 6 | +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; |
| 7 | +import { range } from '../../../../../common/util/util.js'; |
| 8 | +import { RequiredLimitsTestMixin } from '../../../../gpu_test.js'; |
| 9 | +import { CompatibilityTest } from '../../../compatibility_test.js'; |
| 10 | + |
| 11 | +export const g = makeTestGroup( |
| 12 | + RequiredLimitsTestMixin(CompatibilityTest, { |
| 13 | + getRequiredLimits(adapter: GPUAdapter) { |
| 14 | + return { |
| 15 | + maxStorageBuffersInFragmentStage: adapter.limits.maxStorageBuffersInFragmentStage! / 2, |
| 16 | + maxStorageBuffersInVertexStage: adapter.limits.maxStorageBuffersInVertexStage! / 2, |
| 17 | + maxStorageBuffersPerShaderStage: adapter.limits.maxStorageBuffersPerShaderStage, |
| 18 | + maxStorageTexturesInFragmentStage: adapter.limits.maxStorageTexturesInFragmentStage! / 2, |
| 19 | + maxStorageTexturesInVertexStage: adapter.limits.maxStorageTexturesInVertexStage! / 2, |
| 20 | + maxStorageTexturesPerShaderStage: adapter.limits.maxStorageTexturesPerShaderStage, |
| 21 | + }; |
| 22 | + }, |
| 23 | + key() { |
| 24 | + return ` |
| 25 | + maxStorageBuffersInFragmentStage/2, |
| 26 | + maxStorageBuffersInVertexStage/2, |
| 27 | + maxStorageTexturesInFragmentStage/2, |
| 28 | + maxStorageTexturesInVertexStage/2, |
| 29 | + maxStorageBuffersPerShaderStage |
| 30 | + maxStorageTexturesPerShaderStage |
| 31 | + `; |
| 32 | + }, |
| 33 | + }) |
| 34 | +); |
| 35 | + |
| 36 | +g.test('maxStorageBuffersTexturesInVertexFragmentStage') |
| 37 | + .desc( |
| 38 | + ` |
| 39 | + Tests that you can't use more than maxStorage(Buffers/Textures)In(Fragment/Vertex)Stage when |
| 40 | + the limit is less than maxStorage(Buffers/Textures)PerShaderStage |
| 41 | + ` |
| 42 | + ) |
| 43 | + .params(u => |
| 44 | + u |
| 45 | + .combine('limit', [ |
| 46 | + 'maxStorageBuffersInFragmentStage', |
| 47 | + 'maxStorageBuffersInVertexStage', |
| 48 | + 'maxStorageTexturesInFragmentStage', |
| 49 | + 'maxStorageTexturesInVertexStage', |
| 50 | + ] as const) |
| 51 | + .beginSubcases() |
| 52 | + .combine('async', [false, true] as const) |
| 53 | + .combine('extra', [0, 1] as const) |
| 54 | + ) |
| 55 | + .fn(t => { |
| 56 | + const { limit, extra, async } = t.params; |
| 57 | + const { device } = t; |
| 58 | + |
| 59 | + const isBuffer = limit.includes('Buffers'); |
| 60 | + const inStageLimit = device.limits[limit]!; |
| 61 | + const perStageLimitName = isBuffer |
| 62 | + ? 'maxStorageBuffersPerShaderStage' |
| 63 | + : 'maxStorageTexturesPerShaderStage'; |
| 64 | + const perStageLimit = device.limits[perStageLimitName]; |
| 65 | + |
| 66 | + t.debug(`${limit}(${inStageLimit}), ${perStageLimitName}(${perStageLimit})`); |
| 67 | + |
| 68 | + t.skipIf(inStageLimit === 0, `${limit} is 0`); |
| 69 | + t.skipIf( |
| 70 | + !(inStageLimit < perStageLimit), |
| 71 | + `${limit}(${inStageLimit}) is not less than ${perStageLimitName}(${perStageLimit})` |
| 72 | + ); |
| 73 | + |
| 74 | + const typeWGSLFn = isBuffer |
| 75 | + ? (i: number) => `var<storage, read> v${i}: f32;` |
| 76 | + : (i: number) => `var v${i}: texture_storage_2d<r32float, read>;`; |
| 77 | + |
| 78 | + const count = inStageLimit + extra; |
| 79 | + const code = ` |
| 80 | + ${range(count, i => `@group(0) @binding(${i}) ${typeWGSLFn(i)}`).join('\n')} |
| 81 | +
|
| 82 | + fn useResources() { |
| 83 | + ${range(count, i => `_ = v${i};`).join('\n')} |
| 84 | + } |
| 85 | +
|
| 86 | + @vertex fn vsNoUse() -> @builtin(position) vec4f { |
| 87 | + return vec4f(0); |
| 88 | + } |
| 89 | +
|
| 90 | + @vertex fn vsUse() -> @builtin(position) vec4f { |
| 91 | + useResources(); |
| 92 | + return vec4f(0); |
| 93 | + } |
| 94 | +
|
| 95 | + @fragment fn fsNoUse() -> @location(0) vec4f { |
| 96 | + return vec4f(0); |
| 97 | + } |
| 98 | +
|
| 99 | + @fragment fn fsUse() -> @location(0) vec4f { |
| 100 | + useResources(); |
| 101 | + return vec4f(0); |
| 102 | + } |
| 103 | + `; |
| 104 | + |
| 105 | + const module = device.createShaderModule({ code }); |
| 106 | + |
| 107 | + const isFragment = limit.includes('Fragment'); |
| 108 | + const pipelineDescriptor: GPURenderPipelineDescriptor = { |
| 109 | + layout: 'auto', |
| 110 | + vertex: { |
| 111 | + module, |
| 112 | + entryPoint: isFragment ? 'vsNoUse' : 'vsUse', |
| 113 | + }, |
| 114 | + fragment: { |
| 115 | + module, |
| 116 | + entryPoint: isFragment ? 'fsUse' : 'fsNoUse', |
| 117 | + targets: [{ format: 'rgba8unorm' }], |
| 118 | + }, |
| 119 | + }; |
| 120 | + |
| 121 | + const success = extra === 0; |
| 122 | + t.doCreateRenderPipelineTest(async, success, pipelineDescriptor); |
| 123 | + }); |
0 commit comments