From 73bcf42aac5de60bb62e7c7b0ee2f6365612d672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Tue, 24 Oct 2023 19:25:27 +0200 Subject: [PATCH] depthCompare is not required for depth attachments if not used (#3069) * depthCompare is not required for depth attachments if not used * Refactor for success * Refactor success definition --- .../depth_stencil_state.spec.ts | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/webgpu/api/validation/render_pipeline/depth_stencil_state.spec.ts b/src/webgpu/api/validation/render_pipeline/depth_stencil_state.spec.ts index c8c42146456f..eaaf78af66f9 100644 --- a/src/webgpu/api/validation/render_pipeline/depth_stencil_state.spec.ts +++ b/src/webgpu/api/validation/render_pipeline/depth_stencil_state.spec.ts @@ -34,7 +34,8 @@ g.test('format') g.test('depthCompare_optional') .desc( - `The depthCompare in depthStencilState is optional for stencil-only formats but required for formats with a depth.` + `The depthCompare in depthStencilState is optional for stencil-only formats but + required for formats with a depth if depthCompare is not used for anything.` ) .params(u => u @@ -42,6 +43,9 @@ g.test('depthCompare_optional') .combine('format', kDepthStencilFormats) .beginSubcases() .combine('depthCompare', ['always', undefined] as const) + .combine('depthWriteEnabled', [false, true, undefined] as const) + .combine('stencilFrontDepthFailOp', ['keep', 'zero'] as const) + .combine('stencilBackDepthFailOp', ['keep', 'zero'] as const) ) .beforeAllSubcases(t => { const { format } = t.params; @@ -50,13 +54,43 @@ g.test('depthCompare_optional') t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => { - const { isAsync, format, depthCompare } = t.params; + const { + isAsync, + format, + depthCompare, + depthWriteEnabled, + stencilFrontDepthFailOp, + stencilBackDepthFailOp, + } = t.params; const info = kTextureFormatInfo[format]; const descriptor = t.getDescriptor({ - depthStencil: { format, depthCompare, depthWriteEnabled: false }, + depthStencil: { + format, + depthCompare, + depthWriteEnabled, + stencilFront: { depthFailOp: stencilFrontDepthFailOp }, + stencilBack: { depthFailOp: stencilBackDepthFailOp }, + }, }); - t.doCreateRenderPipelineTest(isAsync, !(info.depth && depthCompare === undefined), descriptor); + const depthFailOpsAreKeep = + stencilFrontDepthFailOp === 'keep' && stencilBackDepthFailOp === 'keep'; + const stencilStateIsDefault = depthFailOpsAreKeep; + let success = true; + if (depthWriteEnabled || (depthCompare && depthCompare !== 'always')) { + if (!info.depth) success = false; + } + if (!stencilStateIsDefault) { + if (!info.stencil) success = false; + } + if (info.depth) { + if (depthWriteEnabled === undefined) success = false; + if (depthWriteEnabled || !depthFailOpsAreKeep) { + if (depthCompare === undefined) success = false; + } + } + + t.doCreateRenderPipelineTest(isAsync, success, descriptor); }); g.test('depthWriteEnabled_optional')