From 923f09c435c5de5bac85f110ea3e3ea60fb9302d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= <beaufort.francois@gmail.com>
Date: Tue, 17 Oct 2023 09:54:27 +0200
Subject: [PATCH] Refactor for success

---
 .../depth_stencil_state.spec.ts               | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 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 a374a4412332..e1aa4caf7fd1 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
@@ -75,15 +75,21 @@ g.test('depthCompare_optional')
 
     const areDepthFailOpKeep =
       stencilFrontDepthFailOp === 'keep' && stencilBackDepthFailOp === 'keep';
-    const success =
+
+    let success = false;
+    if (!info.depth) {
       // depthCompare is optional for stencil-only formats.
-      (!info.depth && depthWriteEnabled !== true) ||
-      // depthCompare is optional for formats with a depth if it is not used for anything.
-      (!!info.depth &&
-        ((depthWriteEnabled === false && areDepthFailOpKeep) ||
-          (!!depthCompare &&
-            ((!!info.stencil && depthWriteEnabled !== undefined) ||
-              (!!depthWriteEnabled && areDepthFailOpKeep)))));
+      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;
+      }
+    }
 
     t.doCreateRenderPipelineTest(isAsync, success, descriptor);
   });