From 4aaea6776631418ca2bf539f93ff622c44cdf183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Dec 2024 23:25:40 +0100 Subject: [PATCH] Enable depth raster in all backends, not just Vulkan --- GPU/D3D11/DrawEngineD3D11.cpp | 10 ++++++++++ GPU/Directx9/DrawEngineDX9.cpp | 10 ++++++++++ GPU/GLES/DrawEngineGLES.cpp | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index acc41fcb22..a1238172bd 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -335,6 +335,9 @@ void DrawEngineD3D11::Flush() { context_->Draw(vertexCount, 0); } } + if (useDepthRaster_) { + DepthRasterTransform(prim, dec_, dec_->VertexType(), vertexCount); + } } else { PROFILE_THIS_SCOPE("soft"); VertexDecoder *swDec = dec_; @@ -388,6 +391,13 @@ void DrawEngineD3D11::Flush() { UpdateCachedViewportState(vpAndScissor); } + // At this point, rect and line primitives are still preserved as such. So, it's the best time to do software depth raster. + // We could piggyback on the viewport transform below, but it gets complicated since it's different per-backend. Which we really + // should clean up one day... + if (useDepthRaster_) { + DepthRasterPredecoded(prim, decoded_, numDecodedVerts_, swDec, vertexCount); + } + SoftwareTransform swTransform(params); const Lin::Vec3 trans(gstate_c.vpXOffset, -gstate_c.vpYOffset, gstate_c.vpZOffset * 0.5f + 0.5f); diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index a0cd0c5733..e6d7d3ab51 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -292,6 +292,9 @@ void DrawEngineDX9::Flush() { } } } + if (useDepthRaster_) { + DepthRasterTransform(prim, dec_, dec_->VertexType(), vertexCount); + } } else { VertexDecoder *swDec = dec_; if (swDec->nweights != 0) { @@ -344,6 +347,13 @@ void DrawEngineDX9::Flush() { UpdateCachedViewportState(vpAndScissor); } + // At this point, rect and line primitives are still preserved as such. So, it's the best time to do software depth raster. + // We could piggyback on the viewport transform below, but it gets complicated since it's different per-backend. Which we really + // should clean up one day... + if (useDepthRaster_) { + DepthRasterPredecoded(prim, decoded_, numDecodedVerts_, swDec, vertexCount); + } + int maxIndex = numDecodedVerts_; SoftwareTransform swTransform(params); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 93f8408f50..42fed50d2e 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -315,6 +315,9 @@ void DrawEngineGLES::Flush() { inputLayout, vertexBuffer, vertexBufferOffset, glprim[prim], 0, vertexCount); } + if (useDepthRaster_) { + DepthRasterTransform(prim, dec_, dec_->VertexType(), vertexCount); + } } else { PROFILE_THIS_SCOPE("soft"); VertexDecoder *swDec = dec_; @@ -371,6 +374,13 @@ void DrawEngineGLES::Flush() { } } + // At this point, rect and line primitives are still preserved as such. So, it's the best time to do software depth raster. + // We could piggyback on the viewport transform below, but it gets complicated since it's different per-backend. Which we really + // should clean up one day... + if (useDepthRaster_) { + DepthRasterPredecoded(prim, decoded_, numDecodedVerts_, swDec, vertexCount); + } + SoftwareTransform swTransform(params); const Lin::Vec3 trans(gstate_c.vpXOffset, gstate_c.vpYOffset, gstate_c.vpZOffset);