Skip to content

Commit

Permalink
depthCompare is not required for depth attachments if not used
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored and kainino0x committed Oct 17, 2023
1 parent b3cefa6 commit e94df2e
Showing 1 changed file with 33 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,38 @@ 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 areDepthFailOpKeep =
stencilFrontDepthFailOp === 'keep' && stencilBackDepthFailOp === 'keep';
const success =
// 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)))));

t.doCreateRenderPipelineTest(isAsync, success, descriptor);
});

g.test('depthWriteEnabled_optional')
Expand Down

0 comments on commit e94df2e

Please sign in to comment.