From 428adb446fc5a29b289e5563f47faefc3d0266c5 Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Wed, 17 Jul 2024 10:08:58 -0700 Subject: [PATCH] Add CTS test for new depthBias validation (#3863) * Add CTS test for new depthBias validation * Lint * Apply Kai's suggestsions * Fix TS error --- .../depth_stencil_state.spec.ts | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) 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 403f463943ab..165e6f9c405b 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 @@ -4,7 +4,11 @@ This test dedicatedly tests validation of GPUDepthStencilState of createRenderPi import { makeTestGroup } from '../../../../common/framework/test_group.js'; import { unreachable } from '../../../../common/util/util.js'; -import { kCompareFunctions, kStencilOperations } from '../../../capability_info.js'; +import { + kCompareFunctions, + kPrimitiveTopology, + kStencilOperations, +} from '../../../capability_info.js'; import { kAllTextureFormats, kTextureFormatInfo, @@ -205,6 +209,47 @@ g.test('depth_write,frag_depth') t.doCreateRenderPipelineTest(isAsync, hasDepth, descriptor); }); +g.test('depth_bias') + .desc(`Depth bias parameters are only valid with triangle topologies.`) + .params(u => + u + .combine('isAsync', [false, true]) + .combine('topology', kPrimitiveTopology) + .beginSubcases() + .combineWithParams([ + {}, + { depthBias: -1 }, + { depthBias: 0 }, + { depthBias: 1 }, + { depthBiasSlopeScale: -1 }, + { depthBiasSlopeScale: 0 }, + { depthBiasSlopeScale: 1 }, + { depthBiasClamp: -1 }, + { depthBiasClamp: 0 }, + { depthBiasClamp: 1 }, + ]) + ) + .fn(t => { + const { isAsync, topology, depthBias, depthBiasSlopeScale, depthBiasClamp } = t.params; + + const isTriangleTopology = topology === 'triangle-list' || topology === 'triangle-strip'; + const hasDepthBias = !!depthBias || !!depthBiasSlopeScale || !!depthBiasClamp; + const shouldSucceed = !hasDepthBias || isTriangleTopology; + + const descriptor = t.getDescriptor({ + primitive: { topology }, + depthStencil: { + format: 'depth24plus', + depthWriteEnabled: true, + depthCompare: 'less-equal', + depthBias, + depthBiasSlopeScale, + depthBiasClamp, + }, + }); + t.doCreateRenderPipelineTest(isAsync, shouldSucceed, descriptor); + }); + g.test('stencil_test') .desc( `Stencil aspect must be contained in the format if stencil test is enabled in depthStencilState.`