From 5e1c8a6b582c289792756ddcb1b9f5066fa75442 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Mon, 24 Sep 2018 21:39:42 +0700 Subject: [PATCH] Do not use clearDepthBuffer in FillRect. Use drawRect only. --- .../GLSL/glsl_CombinerProgramUniformFactory.cpp | 3 +-- src/GraphicsDrawer.cpp | 2 +- src/gDP.cpp | 14 ++++++++------ src/gDP.h | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp index 4e750e0d..1659247a 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramUniformFactory.cpp @@ -671,8 +671,7 @@ public: void update(bool _force) override { int renderTarget = 0; - if ((gDP.colorImage.address == gDP.depthImageAddress ) || - (gDP.fillColor.color == DepthClearColor && gDP.otherMode.cycleType == G_CYC_FILL)) { + if (isCurrentColorImageDepthImage()) { renderTarget = gDP.otherMode.depthCompare + 1; } uRenderTarget.set(renderTarget, _force); diff --git a/src/GraphicsDrawer.cpp b/src/GraphicsDrawer.cpp index b26a5e74..c624c32d 100644 --- a/src/GraphicsDrawer.cpp +++ b/src/GraphicsDrawer.cpp @@ -657,7 +657,7 @@ void GraphicsDrawer::_updateStates(DrawingState _drawingState) const if (!config.generalEmulation.enableFragmentDepthWrite) return; - if (gDP.colorImage.address == gDP.depthImageAddress && + if (isCurrentColorImageDepthImage() && config.generalEmulation.enableFragmentDepthWrite != 0 && config.frameBufferEmulation.N64DepthCompare == 0 && (config.generalEmulation.hacks & hack_ZeldaMM) == 0 diff --git a/src/gDP.cpp b/src/gDP.cpp index 4f0ff539..d2124965 100644 --- a/src/gDP.cpp +++ b/src/gDP.cpp @@ -27,6 +27,12 @@ using namespace std; gDPInfo gDP; +bool isCurrentColorImageDepthImage() +{ + return (gDP.colorImage.address == gDP.depthImageAddress) || + (gDP.fillColor.color == DepthClearColor && gDP.otherMode.cycleType == G_CYC_FILL); +} + void gDPSetOtherMode( u32 mode0, u32 mode1 ) { gDP.otherMode.h = mode0; @@ -705,9 +711,7 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry ) if (gDP.fillColor.color == DepthClearColor) { frameBufferList().fillRDRAM(ulx, uly, lrx, lry); depthBuffer = dbFound; - if (config.frameBufferEmulation.N64DepthCompare == 0 && - (config.generalEmulation.enableFragmentDepthWrite == 0 || - (ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry))) { + if (config.generalEmulation.enableFragmentDepthWrite == 0) { drawer.clearDepthBuffer(ulx, uly, lrx, lry); depthBuffer = dbCleared; } else @@ -717,9 +721,7 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry ) depthBuffer = dbFound; depthBufferList().saveBuffer(gDP.colorImage.address); frameBufferList().fillRDRAM(ulx, uly, lrx, lry); - if (config.frameBufferEmulation.N64DepthCompare == 0 && - (config.generalEmulation.enableFragmentDepthWrite == 0 || - (ulx == 0 && uly == 0 && lrx == gDP.scissor.lrx && lry == gDP.scissor.lry))) { + if (config.generalEmulation.enableFragmentDepthWrite == 0) { drawer.clearDepthBuffer(ulx, uly, lrx, lry); depthBuffer = dbCleared; } else diff --git a/src/gDP.h b/src/gDP.h index a66d4fb8..5d187582 100644 --- a/src/gDP.h +++ b/src/gDP.h @@ -295,5 +295,6 @@ void gDPTriShadeZ( u32 w0, u32 w1 ); void gDPTriTxtrZ( u32 w0, u32 w1 ); void gDPTriShadeTxtrZ( u32 w0, u32 w1 ); -#endif +bool isCurrentColorImageDepthImage(); +#endif