Vulkan support for SHADER_EARLY_DEPTH_TEST
and fix to conservative depth optimizations
#7676
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connections
#3961: Resolves for Vulkan and GL backends
#4408: Resolves for Vulkan backend
Description
@early_depth_test
attributeOriginally, I had only planned to do the first, but while reviewing the specs and doing research for this change, I discovered that the current design of Naga's
EarlyDepthTest
doesn't make sense. There are two use cases for early fragment tests:frag_depth
in a predictable way, allowing an additional early depth/stencil test to optimize away unnecessary shader invocations without changing behaviorThese use cases are incompatible with each other. In both Vulkan and GLSL, forcing early fragment tests disables late tests, which means that writing to
frag_depth
is either useless or an error. Currently, Naga doesn't allow writing a conservative depth specifier without also forcing early fragment tests, invalidating the conservative depth specifier.To salvage conservative depth optimizations, I have reworked
EarlyDepthTest
into an enum with variants corresponding to the two use cases above. To make this more explicit,@early_depth_test(force)
is now required to force early fragment tests.Testing
Squash or Rebase?
Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.