Skip to content

Commit

Permalink
Add CTS test for new depthBias validation (#3863)
Browse files Browse the repository at this point in the history
* Add CTS test for new depthBias validation

* Lint

* Apply Kai's suggestsions

* Fix TS error
  • Loading branch information
toji authored Jul 17, 2024
1 parent 20425f6 commit 428adb4
Showing 1 changed file with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.`
Expand Down

0 comments on commit 428adb4

Please sign in to comment.