Skip to content

Commit

Permalink
Reduce draw validation test parameterization (#3122)
Browse files Browse the repository at this point in the history
* Reduce buffer_binding_overlap subcases by 89%

* vertex_buffer_OOB: no-op refactor subcase parameterization

* vertex_buffer_OOB: reduce subcases by 43%

* vertex_buffer_OOB: reduce subcases by 50%

* vertex_buffer_OOB: more subcases per case

This helps a lot in standalone (18s -> 12s) but it probably won't help
quite as much in other modes.

* vertex_buffer_OOB: reduce cases by 44%

* Revert buffer_binding_overlap changes, add TODO
  • Loading branch information
kainino0x authored Nov 2, 2023
1 parent 0fac55f commit a71c816
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions src/webgpu/api/validation/encoding/cmds/render/draw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,27 +404,46 @@ success/error as expected. Such set of buffer parameters should include cases li
u
// type of draw call
.combine('type', ['draw', 'drawIndexed', 'drawIndirect', 'drawIndexedIndirect'] as const)
// the state of vertex step mode vertex buffer bound size
.combine('VBSize', ['zero', 'exile', 'enough'] as const)
// the state of instance step mode vertex buffer bound size
.combine('IBSize', ['zero', 'exile', 'enough'] as const)
// VBSize: the state of vertex step mode vertex buffer bound size
// IBSize: the state of instance step mode vertex buffer bound size
.combineWithParams([
{ VBSize: 'exact', IBSize: 'exact' },
{ VBSize: 'zero', IBSize: 'exact' },
{ VBSize: 'oneTooSmall', IBSize: 'exact' },
{ VBSize: 'exact', IBSize: 'zero' },
{ VBSize: 'exact', IBSize: 'oneTooSmall' },
] as const)
// the state of array stride
.combine('AStride', ['zero', 'exact', 'oversize'] as const)
.beginSubcases()
// should the vertex stride count be zero
.combine('VStride0', [false, true] as const)
// should the instance stride count be zero
.combine('IStride0', [false, true] as const)
// the state of array stride
.combine('AStride', ['zero', 'exact', 'oversize'] as const)
// the factor for offset of attributes in vertex layout
.combine('offset', [0, 1, 2, 7]) // the offset of attribute will be factor * MIN(4, sizeof(vertexFormat))
.beginSubcases()
.combine('setBufferOffset', [0, 200]) // must be a multiple of 4
.combine('setBufferOffset', [200]) // must be a multiple of 4
.combine('attributeFormat', ['snorm8x2', 'float32', 'float16x4'] as GPUVertexFormat[])
.combine('vertexCount', [0, 1, 10000])
.combine('firstVertex', [0, 10000])
.filter(p => p.VStride0 === (p.firstVertex + p.vertexCount === 0))
.combine('instanceCount', [0, 1, 10000])
.combine('firstInstance', [0, 10000])
.filter(p => p.IStride0 === (p.firstInstance + p.instanceCount === 0))
.expandWithParams(p =>
p.VStride0
? [{ firstVertex: 0, vertexCount: 0 }]
: [
{ firstVertex: 0, vertexCount: 1 },
{ firstVertex: 0, vertexCount: 10000 },
{ firstVertex: 10000, vertexCount: 0 },
{ firstVertex: 10000, vertexCount: 10000 },
]
)
.expandWithParams(p =>
p.IStride0
? [{ firstInstance: 0, instanceCount: 0 }]
: [
{ firstInstance: 0, instanceCount: 1 },
{ firstInstance: 0, instanceCount: 10000 },
{ firstInstance: 10000, instanceCount: 0 },
{ firstInstance: 10000, instanceCount: 10000 },
]
)
.unless(p => p.vertexCount === 10000 && p.instanceCount === 10000)
)
.fn(t => {
Expand Down Expand Up @@ -459,7 +478,7 @@ success/error as expected. Such set of buffer parameters should include cases li
}

const calcSetBufferSize = (
boundBufferSizeState: 'zero' | 'exile' | 'enough',
boundBufferSizeState: 'zero' | 'oneTooSmall' | 'exact',
strideCount: number
): number => {
let requiredBufferSize: number;
Expand All @@ -475,11 +494,11 @@ success/error as expected. Such set of buffer parameters should include cases li
setBufferSize = 0;
break;
}
case 'exile': {
case 'oneTooSmall': {
setBufferSize = requiredBufferSize - 1;
break;
}
case 'enough': {
case 'exact': {
setBufferSize = requiredBufferSize;
break;
}
Expand Down Expand Up @@ -566,11 +585,11 @@ success/error as expected. Such set of buffer parameters should include cases li
}

const isVertexBufferOOB =
boundVertexBufferSizeState !== 'enough' &&
boundVertexBufferSizeState !== 'exact' &&
drawType === 'draw' && // drawIndirect, drawIndexed, and drawIndexedIndirect do not validate vertex step mode buffer
!zeroVertexStrideCount; // vertex step mode buffer never OOB if stride count = 0
const isInstanceBufferOOB =
boundInstanceBufferSizeState !== 'enough' &&
boundInstanceBufferSizeState !== 'exact' &&
(drawType === 'draw' || drawType === 'drawIndexed') && // drawIndirect and drawIndexedIndirect do not validate instance step mode buffer
!zeroInstanceStrideCount; // vertex step mode buffer never OOB if stride count = 0
const isFinishSuccess = !isVertexBufferOOB && !isInstanceBufferOOB;
Expand All @@ -586,6 +605,11 @@ g.test(`buffer_binding_overlap`)
In this test we test that binding one GPU buffer to multiple vertex buffer slot or both vertex
buffer slot and index buffer will cause no validation error, with completely/partial overlap.
- x= all draw types
TODO: The "Factor" parameters don't necessarily guarantee that we test all configurations
of buffers overlapping or not. This test should be refactored to test specific overlap cases,
and have fewer total parameterizations.
See https://github.com/gpuweb/cts/pull/3122#discussion_r1378623214
`
)
.params(u =>
Expand Down

0 comments on commit a71c816

Please sign in to comment.