From 110265d90ce5929e27bea6bff9828d7f8f26ed1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Thu, 19 Oct 2023 10:07:57 +0200 Subject: [PATCH] Refactor success definition --- .../depth_stencil_state.spec.ts | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 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 e1aa4caf7fd1..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 @@ -73,21 +73,20 @@ g.test('depthCompare_optional') }, }); - const areDepthFailOpKeep = + const depthFailOpsAreKeep = stencilFrontDepthFailOp === 'keep' && stencilBackDepthFailOp === 'keep'; - - let success = false; - if (!info.depth) { - // depthCompare is optional for stencil-only formats. - if (!depthWriteEnabled) success = true; - } else { - // depthCompare is optional for formats with a depth if it's not used for anything. - if (depthWriteEnabled === false && areDepthFailOpKeep) success = true; - if (depthCompare) { - // validation will succeed normally for formats with depth aspect. - if (depthWriteEnabled && areDepthFailOpKeep) success = true; - // validation will succeed as well for formats with stencil and depth aspect. - if (info.stencil && depthWriteEnabled !== undefined) success = true; + 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; } }