-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compat: refactor maxStorage(Buffers/Textures)PerShaderStage test (#4122)
Refactor to handle maxStorage(Buffers/Textures)In(Vertex/Fragment)Stage being less than maxStorage(Buffers/Textures)PerShaderStage. Also maxDynamicStorageBuffersPerPipelineLayout. I noticed a test was missing there too so added it.
- Loading branch information
Showing
5 changed files
with
224 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 79 additions & 10 deletions
89
...api/validation/capability_checks/limits/maxDynamicStorageBuffersPerPipelineLayout.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,108 @@ | ||
import { range } from '../../../../../common/util/util.js'; | ||
import { assert, range } from '../../../../../common/util/util.js'; | ||
import { kShaderStageCombinationsWithStage } from '../../../../capability_info.js'; | ||
import { GPUConst } from '../../../../constants.js'; | ||
|
||
import { kMaximumLimitBaseParams, makeLimitTestGroup } from './limit_utils.js'; | ||
import { kMaximumLimitBaseParams, LimitsRequest, makeLimitTestGroup } from './limit_utils.js'; | ||
|
||
const kExtraLimits: LimitsRequest = { | ||
maxBindingsPerBindGroup: 'adapterLimit', | ||
maxBindGroups: 'adapterLimit', | ||
maxStorageBuffersPerShaderStage: 'adapterLimit', | ||
maxStorageBuffersInFragmentStage: 'adapterLimit', | ||
maxStorageBuffersInVertexStage: 'adapterLimit', | ||
}; | ||
|
||
const limit = 'maxDynamicStorageBuffersPerPipelineLayout'; | ||
export const { g, description } = makeLimitTestGroup(limit); | ||
|
||
g.test('createBindGroupLayout,at_over') | ||
.desc(`Test using createBindGroupLayout at and over ${limit} limit`) | ||
.params( | ||
kMaximumLimitBaseParams.combine('visibility', [ | ||
GPUConst.ShaderStage.FRAGMENT, | ||
GPUConst.ShaderStage.COMPUTE, | ||
GPUConst.ShaderStage.COMPUTE | GPUConst.ShaderStage.FRAGMENT, | ||
]) | ||
kMaximumLimitBaseParams | ||
.combine('visibility', kShaderStageCombinationsWithStage) | ||
.combine('type', ['storage', 'read-only-storage'] as GPUBufferBindingType[]) | ||
.filter( | ||
({ visibility, type }) => | ||
(visibility & GPUConst.ShaderStage.VERTEX) === 0 || type !== 'storage' | ||
) | ||
) | ||
.fn(async t => { | ||
const { limitTest, testValueName, visibility } = t.params; | ||
const { limitTest, testValueName, visibility, type } = t.params; | ||
await t.testDeviceWithRequestedMaximumLimits( | ||
limitTest, | ||
testValueName, | ||
async ({ device, testValue, shouldError }) => { | ||
t.skipIfNotEnoughStorageBuffersInStage(visibility, testValue); | ||
shouldError ||= testValue > t.device.limits.maxStorageBuffersPerShaderStage; | ||
await t.expectValidationError(() => { | ||
device.createBindGroupLayout({ | ||
entries: range(testValue, i => ({ | ||
binding: i, | ||
visibility, | ||
buffer: { | ||
type: 'storage', | ||
type, | ||
hasDynamicOffset: true, | ||
}, | ||
})), | ||
}); | ||
}, shouldError); | ||
} | ||
}, | ||
kExtraLimits | ||
); | ||
}); | ||
|
||
g.test('createPipelineLayout,at_over') | ||
.desc(`Test using at and over ${limit} limit in createPipelineLayout`) | ||
.params( | ||
kMaximumLimitBaseParams | ||
.combine('visibility', kShaderStageCombinationsWithStage) | ||
.combine('type', ['storage', 'read-only-storage'] as GPUBufferBindingType[]) | ||
.filter( | ||
({ visibility, type }) => | ||
(visibility & GPUConst.ShaderStage.VERTEX) === 0 || type !== 'storage' | ||
) | ||
) | ||
.fn(async t => { | ||
const { limitTest, testValueName, visibility, type } = t.params; | ||
|
||
await t.testDeviceWithRequestedMaximumLimits( | ||
limitTest, | ||
testValueName, | ||
async ({ device, testValue, shouldError, actualLimit }) => { | ||
t.skipIfNotEnoughStorageBuffersInStage(visibility, testValue); | ||
|
||
const maxBindingsPerBindGroup = Math.min( | ||
t.device.limits.maxBindingsPerBindGroup, | ||
actualLimit | ||
); | ||
|
||
const kNumGroups = Math.ceil(testValue / maxBindingsPerBindGroup); | ||
|
||
// Not sure what to do in this case but best we get notified if it happens. | ||
assert(kNumGroups <= t.device.limits.maxBindGroups); | ||
|
||
const bindGroupLayouts = range(kNumGroups, i => { | ||
const numInGroup = Math.min( | ||
testValue - i * maxBindingsPerBindGroup, | ||
maxBindingsPerBindGroup | ||
); | ||
return device.createBindGroupLayout({ | ||
entries: range(numInGroup, i => ({ | ||
binding: i, | ||
visibility, | ||
buffer: { | ||
type, | ||
hasDynamicOffset: true, | ||
}, | ||
})), | ||
}); | ||
}); | ||
|
||
await t.expectValidationError( | ||
() => device.createPipelineLayout({ bindGroupLayouts }), | ||
shouldError | ||
); | ||
}, | ||
kExtraLimits | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.