1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
import { range } from '../../../../../common/util/util.js';
import { kRenderEncoderTypes, kMaximumLimitBaseParams, makeLimitTestGroup } from './limit_utils.js';
const kPipelineTypes = ['withoutLocations', 'withLocations'] as const;
type PipelineType = (typeof kPipelineTypes)[number];
function getPipelineDescriptor(
device: GPUDevice,
pipelineType: PipelineType,
testValue: number
): GPURenderPipelineDescriptor {
const code =
pipelineType === 'withLocations'
? `
struct VSInput {
${range(testValue, i => `@location(${i}) p${i}: f32,`).join('\n')}
}
@vertex fn vs(v: VSInput) -> @builtin(position) vec4f {
let x = ${range(testValue, i => `v.p${i}`).join(' + ')};
return vec4f(x, 0, 0, 1);
}
`
: `
@vertex fn vs() -> @builtin(position) vec4f {
return vec4f(0);
}
`;
const module = device.createShaderModule({ code });
return {
layout: 'auto',
vertex: {
module,
entryPoint: 'vs',
buffers: range(testValue, i => ({
arrayStride: 32,
attributes: [{ shaderLocation: i, offset: 0, format: 'float32' }],
})),
},
};
}
const limit = 'maxVertexBuffers';
export const { g, description } = makeLimitTestGroup(limit);
g.test('createRenderPipeline,at_over')
.desc(`Test using at and over ${limit} limit in createRenderPipeline(Async)`)
.params(
kMaximumLimitBaseParams.combine('async', [false, true]).combine('pipelineType', kPipelineTypes)
)
.fn(async t => {
const { limitTest, testValueName, async, pipelineType } = t.params;
await t.testDeviceWithRequestedMaximumLimits(
limitTest,
testValueName,
async ({ device, testValue, shouldError }) => {
const pipelineDescriptor = getPipelineDescriptor(device, pipelineType, testValue);
await t.testCreateRenderPipeline(pipelineDescriptor, async, shouldError);
}
);
});
g.test('setVertexBuffer,at_over')
.desc(`Test using at and over ${limit} limit in setVertexBuffer`)
.params(kMaximumLimitBaseParams.combine('encoderType', kRenderEncoderTypes))
.fn(async t => {
const { limitTest, testValueName, encoderType } = t.params;
await t.testDeviceWithRequestedMaximumLimits(
limitTest,
testValueName,
async ({ device, testValue, shouldError, actualLimit }) => {
const lastIndex = testValue - 1;
const buffer = device.createBuffer({
size: 16,
usage: GPUBufferUsage.VERTEX,
});
await t.testGPURenderCommandsMixin(
encoderType,
({ mixin }) => {
mixin.setVertexBuffer(lastIndex, buffer);
},
shouldError,
`lastIndex: ${lastIndex}, actualLimit: ${actualLimit}, shouldError: ${shouldError}`
);
buffer.destroy();
}
);
});
g.test('validate,maxBindGroupsPlusVertexBuffers')
.desc(`Test that ${limit} <= maxBindGroupsPlusVertexBuffers`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxBindGroupsPlusVertexBuffers'));
t.expect(adapterLimit <= adapter.limits.maxBindGroupsPlusVertexBuffers);
});
|