Skip to content

Commit

Permalink
Compat: refactor maxStorageTexturesPerShaderStage test
Browse files Browse the repository at this point in the history
Refactor to handle maxStorageTexturesInFragmentStage being less than
maxStorageTexturesPerShaderStage
  • Loading branch information
greggman committed Dec 27, 2024
1 parent ba2bd8a commit 5e6fa3b
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import {
getPipelineTypeForBindingCombination,
BindingCombination,
LimitsRequest,
LimitTestsImpl,
} from './limit_utils.js';

const kExtraLimits: LimitsRequest = {
maxBindingsPerBindGroup: 'adapterLimit',
maxBindGroups: 'adapterLimit',
maxStorageTexturesInFragmentStage: 'adapterLimit',
};

const limit = 'maxStorageTexturesPerShaderStage';
Expand All @@ -43,6 +45,25 @@ function createBindGroupLayout(
});
}

function skipIfNotEnoughStorageTexturesInStage(
t: LimitTestsImpl,
visibility: GPUShaderStageFlags,
testValue: number
) {
t.skipIf(
t.isCompatibility &&
// If we're using the fragment stage
(visibility & GPUConst.ShaderStage.FRAGMENT) !== 0 &&
// If perShaderStage and inFragment stage are equal we want to
// allow the test to run as otherwise we can't test overMaximum and overLimit
t.device.limits.maxStorageTexturesPerShaderStage >
t.device.limits.maxStorageTexturesInFragmentStage! &&
// They aren't equal so if there aren't enough supported in the fragment then skip
!(t.device.limits.maxStorageTexturesInFragmentStage! >= testValue),
`maxStorageTexturesInVertexShader = ${t.adapter.limits.maxStorageTexturesInVertexStage} which is less than ${testValue}`
);
}

g.test('createBindGroupLayout,at_over')
.desc(
`
Expand Down Expand Up @@ -71,7 +92,7 @@ g.test('createBindGroupLayout,at_over')
t.adapter.limits.maxBindingsPerBindGroup < testValue,
`maxBindingsPerBindGroup = ${t.adapter.limits.maxBindingsPerBindGroup} which is less than ${testValue}`
);

skipIfNotEnoughStorageTexturesInStage(t, visibility, testValue);
await t.expectValidationError(
() => createBindGroupLayout(device, visibility, order, testValue),
shouldError
Expand Down Expand Up @@ -105,6 +126,8 @@ g.test('createPipelineLayout,at_over')
limitTest,
testValueName,
async ({ device, testValue, shouldError, actualLimit }) => {
skipIfNotEnoughStorageTexturesInStage(t, visibility, testValue);

const maxBindingsPerBindGroup = Math.min(
t.device.limits.maxBindingsPerBindGroup,
actualLimit
Expand Down

0 comments on commit 5e6fa3b

Please sign in to comment.