GPU: Avoid clears for non-simple depth values.

Some drivers don't round depth the same way for a clear vs for drawing,
which can cause mismatches.  We only do this if we see equals-style depth
comparison funcs used in drawing.
This commit is contained in:
Unknown W. Brackets committed 2022-11-08 20:06:08 -08:00
1 parent 818849c4b9
commit 3333f2a5aa
9 files changed
+38

No files matched your search

+4
View File
@@ -899,6 +899,10 @@ void DrawEngineVulkan::DoFlush() {
if (result.setSafeSize)
framebufferManager_->SetSafeSize(result.safeWidth, result.safeHeight);
// Non-zero depth clears are unusual, but some drivers don't match drawn depth values to cleared values.
// Games sometimes expect exact matches (see #12626, for example) for equal comparisons.
if (result.action == SW_CLEAR && everUsedEqualDepth_ && gstate.isClearModeDepthMask() && result.depth > 0.0f && result.depth < 1.0f)
result.action = SW_DRAW_PRIMITIVES;
// Only here, where we know whether to clear or to draw primitives, should we actually set the current framebuffer! Because that gives use the opportunity
// to use a "pre-clear" render pass, for high efficiency on tilers.