KhronosGroup / KhronosGroup/Vulkan-Docs
Ambiguous description of depth comparison function
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 2
Description
My confusion started by reading the specification for the `VkSamplerCreateInfo` struct. It has a field `VkCompareOp compareOp`, with a description:
> compareOp is a VkCompareOp value specifying the comparison operator to apply to fetched data before filtering as described in the Depth Compare Operation section.
Okay, so apparently there's a reference to a section describing a "Depth Compare Operation". Does this mean the compare op is not valid for color images (or other images of non-depth/stencil format)? If so, why is the field not called `depthCompareOp`?
Or should I read it as _"Its usage is described, by example generalizable, in the section on Depth Compare Operation"_?
---
Okay, I jump to the section "Depth Compare Operation" (16.3.4 in the spec I have, which is 1.3.253) and read:
> If the image view has a depth/stencil format, the depth component is selected by the aspectMask, and the operation is an OpImage*Dref* instruction, a depth comparison is performed. The result is 1.0 if the comparison evaluates to true, and 0.0 otherwise. This value replaces the depth component D.
What is an `OpImage*Dref*` instruction, and how is depth comparison performed? I can jump a bit around in the spec and read:
> OpImage*Dref* instructions apply depth comparison on the texel values.
I understand the concept of fetching a texel and performing an operation before filtering. But what are we comparing with here? Do we assume a bound depth (/stencil) buffer? Does the SPIR-V instruction translate to something in GLSL that takes two parameters?
---
I apologize if some of my questions are bad. I haven't really used depth comparison before, and I'm trying to write a small but reasonably flexible Vulkan library.
Contributor guide
Assessment
This issue has not been assessed yet.