-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
depthCompare is not required for depth attachments if not used #3069
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -50,13 +54,44 @@ 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'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let success = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!info.depth) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// depthCompare is optional for stencil-only formats. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies for another big change. It is much easier to think about written this way, but I still find it quite hard to pick apart where the different rules from the spec appear here. (I probably shouldn't have suggested inverting the usual pattern, as I realize there's a good reason we usually have I think the most readable form would stick close to the spec:
Suggested change
I would need you to test this to make sure it's right, but it follows the spec very closely so I hope it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kainino0x Thanks for the detailed answer. I followed your last suggestion with one nit: - if (depthWriteEnabled || depthCompare !== 'always') {
+ if (depthWriteEnabled || (depthCompare && depthCompare !== 'always')) { I'm updating spec to make it clear as well. See gpuweb/gpuweb#4345 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kainino0x (gentle ping) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
t.doCreateRenderPipelineTest(isAsync, success, descriptor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
g.test('depthWriteEnabled_optional') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This confused me a little because depthWriteEnabled=true is not even allowed with stencil-only formats. Then I realized this check is here because of that. Digging further it's quite hard to see how all of the validation rules from the spec appear here. [continued in other comment]