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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
export const description = `
This tests entry point validation of compute/render pipelines and their shader modules.
The entryPoint in shader module include standard "main" and others.
The entryPoint assigned in descriptor include:
- Matching case (control case)
- Empty string
- Mistyping
- Containing invalid char, including space and control codes (Null character)
- Unicode entrypoints and their ASCIIfied version
TODO:
- Test unicode normalization (gpuweb/gpuweb#1160)
- Fine-tune test cases to reduce number by removing trivially similiar cases
`;
import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { kDefaultVertexShaderCode, getShaderWithEntryPoint } from '../../../util/shader.js';
import { ValidationTest } from '../validation_test.js';
export const g = makeTestGroup(ValidationTest);
const kEntryPointTestCases = [
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: '' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\0' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\0a' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'mian' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main ' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'ma in' },
{ shaderModuleEntryPoint: 'main', stageEntryPoint: 'main\n' },
{ shaderModuleEntryPoint: 'mian', stageEntryPoint: 'mian' },
{ shaderModuleEntryPoint: 'mian', stageEntryPoint: 'main' },
{ shaderModuleEntryPoint: 'mainmain', stageEntryPoint: 'mainmain' },
{ shaderModuleEntryPoint: 'mainmain', stageEntryPoint: 'foo' },
{ shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: 'main_t12V3' },
{ shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: 'main_t12V5' },
{ shaderModuleEntryPoint: 'main_t12V3', stageEntryPoint: '_main_t12V3' },
{ shaderModuleEntryPoint: 'séquençage', stageEntryPoint: 'séquençage' },
{ shaderModuleEntryPoint: 'séquençage', stageEntryPoint: 'sequencage' },
];
g.test('compute')
.desc(
`
Tests calling createComputePipeline(Async) with valid vertex stage shader and different entryPoints,
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
.fn(async t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const descriptor: GPUComputePipelineDescriptor = {
layout: 'auto',
compute: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('compute', shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
t.doCreateComputePipelineTest(isAsync, _success, descriptor);
});
g.test('vertex')
.desc(
`
Tests calling createRenderPipeline(Async) with valid vertex stage shader and different entryPoints,
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
.fn(async t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const descriptor: GPURenderPipelineDescriptor = {
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('vertex', shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
});
g.test('fragment')
.desc(
`
Tests calling createRenderPipeline(Async) with valid fragment stage shader and different entryPoints,
and check that the APIs only accept matching entryPoint.
`
)
.params(u => u.combine('isAsync', [true, false]).combineWithParams(kEntryPointTestCases))
.fn(async t => {
const { isAsync, shaderModuleEntryPoint, stageEntryPoint } = t.params;
const descriptor: GPURenderPipelineDescriptor = {
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: kDefaultVertexShaderCode,
}),
entryPoint: 'main',
},
fragment: {
module: t.device.createShaderModule({
code: getShaderWithEntryPoint('fragment', shaderModuleEntryPoint),
}),
entryPoint: stageEntryPoint,
targets: [{ format: 'rgba8unorm' }],
},
};
const _success = shaderModuleEntryPoint === stageEntryPoint;
t.doCreateRenderPipelineTest(isAsync, _success, descriptor);
});
|