Skip to content

Commit 6ff5dc6

Browse files
Adding test for vertex-only render pipeline: Part 1 (#759)
In this patch a basic test for creating vertex-only render pipeline and a test plan for operation test for vertex-only render pipeline is added. Bug: dawn:1142
1 parent 1c7d6af commit 6ff5dc6

File tree

2 files changed

+79
-8
lines changed

2 files changed

+79
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const description = `
2+
Test vertex-only render pipeline.
3+
`;
4+
5+
import { makeTestGroup } from '../../../../common/framework/test_group.js';
6+
import { GPUTest } from '../../../gpu_test.js';
7+
8+
class F extends GPUTest {}
9+
10+
export const g = makeTestGroup(F);
11+
12+
g.test('draw_depth_and_stencil_with_vertex_only_pipeline')
13+
.desc(
14+
`
15+
TODO:
16+
- Test drawing depth and stencil with vertex-only render pipelines by
17+
1. Create a color attachment and depth-stencil attachment of 4 pixels in a line, clear the color
18+
to RGBA(0.0, 0.0, 0.0, 0.0), depth to 0.0 and stencil to 0x0
19+
2. Use a depth and stencil test disabled vertex-only render pipeline to modify the depth of middle
20+
2 pixels to 0.5, while leaving stencil unchanged
21+
3. Use another depth and stencil test disabled vertex-only render pipeline to modify the stencil
22+
of right 2 pixels to 0x1, while leaving depth unchanged
23+
4. Use a complete render pipeline to draw all 4 pixels with color RGBA(0.0, 1.0, 0.0, 1.0), but
24+
with depth test requiring depth no less than 0.5 and stencil test requiring stencil equals to 0x1
25+
5. Validate that only the third pixel is of color RGBA(0.0, 1.0, 0.0, 1.0), and all other pixels
26+
are RGBA(0.0, 0.0, 0.0, 0.0).
27+
`
28+
)
29+
.unimplemented();

src/webgpu/api/validation/createRenderPipeline.spec.ts

+50-8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class F extends ValidationTest {
9191
sampleCount?: number;
9292
depthStencil?: GPUDepthStencilState;
9393
fragmentShaderCode?: string;
94+
noFragment?: boolean;
9495
} = {}
9596
): GPURenderPipelineDescriptor {
9697
const defaultTargets: GPUColorTargetState[] = [{ format: 'rgba8unorm' }];
@@ -103,6 +104,7 @@ class F extends ValidationTest {
103104
kTextureFormatInfo[targets[0] ? targets[0].format : 'rgba8unorm'].sampleType,
104105
4
105106
),
107+
noFragment = false,
106108
} = options;
107109

108110
return {
@@ -115,13 +117,15 @@ class F extends ValidationTest {
115117
}),
116118
entryPoint: 'main',
117119
},
118-
fragment: {
119-
module: this.device.createShaderModule({
120-
code: fragmentShaderCode,
121-
}),
122-
entryPoint: 'main',
123-
targets,
124-
},
120+
fragment: noFragment
121+
? undefined
122+
: {
123+
module: this.device.createShaderModule({
124+
code: fragmentShaderCode,
125+
}),
126+
entryPoint: 'main',
127+
targets,
128+
},
125129
layout: this.getPipelineLayout(),
126130
primitive: { topology },
127131
multisample: { count: sampleCount },
@@ -174,7 +178,45 @@ g.test('basic_use_of_createRenderPipeline')
174178
t.doCreateRenderPipelineTest(isAsync, true, descriptor);
175179
});
176180

177-
g.test('at_least_one_color_state_is_required')
181+
g.test('create_vertex_only_pipeline_with_without_depth_stencil_state')
182+
.desc(
183+
`Test creating vertex-only render pipeline. A vertex-only render pipeline have no fragment
184+
state (and thus have no color state), and can be create with or without depth stencil state.`
185+
)
186+
.params(u =>
187+
u
188+
.combine('isAsync', [false, true])
189+
.beginSubcases()
190+
.combine('depthStencilFormat', [
191+
'depth24plus',
192+
'depth24plus-stencil8',
193+
'depth32float',
194+
'',
195+
] as const)
196+
.combine('haveColor', [false, true])
197+
)
198+
.fn(async t => {
199+
const { isAsync, depthStencilFormat, haveColor } = t.params;
200+
201+
let depthStencilState: GPUDepthStencilState | undefined;
202+
if (depthStencilFormat === '') {
203+
depthStencilState = undefined;
204+
} else {
205+
depthStencilState = { format: depthStencilFormat };
206+
}
207+
208+
// Having targets or not should have no effect in result, since it will not appear in the
209+
// descriptor in vertex-only render pipeline
210+
const descriptor = t.getDescriptor({
211+
noFragment: true,
212+
depthStencil: depthStencilState,
213+
targets: haveColor ? [{ format: 'rgba8unorm' }] : [],
214+
});
215+
216+
t.doCreateRenderPipelineTest(isAsync, true, descriptor);
217+
});
218+
219+
g.test('at_least_one_color_state_is_required_for_complete_pipeline')
178220
.params(u => u.combine('isAsync', [false, true]))
179221
.fn(async t => {
180222
const { isAsync } = t.params;

0 commit comments

Comments
 (0)