Skip to content

Commit

Permalink
depthCompare is not required for depth attachments if not used (#3069)
Browse files Browse the repository at this point in the history
* depthCompare is not required for depth attachments if not used

* Refactor for success

* Refactor success definition
  • Loading branch information
beaufortfrancois authored Oct 24, 2023
1 parent d491499 commit 73bcf42
Showing 1 changed file with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ 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
.combine('isAsync', [false, true])
.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;
Expand All @@ -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')
Expand Down

0 comments on commit 73bcf42

Please sign in to comment.