From d0dbcc6369b1482237521308982baf84cd5989d5 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Fri, 1 Mar 2013 00:52:15 +0100 Subject: [PATCH] VideoSoftware: Cleanup PE perf metrics; returning the proper value now. --- .../Plugin_VideoSoftware/Src/BPMemLoader.cpp | 2 +- .../Plugin_VideoSoftware/Src/Rasterizer.cpp | 9 ++-- .../Src/SWPixelEngine.cpp | 11 ----- .../Plugin_VideoSoftware/Src/SWPixelEngine.h | 48 +++++++++++++++++++ .../Plugins/Plugin_VideoSoftware/Src/Tev.cpp | 14 ++---- 5 files changed, 57 insertions(+), 27 deletions(-) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp index dde31ab7d3..0d7c77c767 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp @@ -91,7 +91,7 @@ void SWBPWritten(int address, int newvalue) SWPixelEngine::pereg.boxTop = newvalue & 0x3ff; break; case BPMEM_CLEAR_PIXEL_PERF: - // TODO: Parameter? + // TODO: I didn't test if the value written to this register affects the amount of cleared registers SWPixelEngine::pereg.perfZcompInputZcomplocLo = 0; SWPixelEngine::pereg.perfZcompInputZcomplocHi = 0; SWPixelEngine::pereg.perfZcompOutputZcomplocLo = 0; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp index d30c3d7033..badb123fa0 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp @@ -150,18 +150,15 @@ inline void Draw(s32 x, s32 y, s32 xi, s32 yi) if (bpmem.zcontrol.early_ztest && bpmem.zmode.testenable && g_SWVideoConfig.bZComploc) { - // TODO: Verify that perf regs are being incremented even if test is disabled - if (++SWPixelEngine::pereg.perfZcompInputZcomplocLo == 0) - SWPixelEngine::pereg.perfZcompInputZcomplocHi++; - + // TODO: Test if perf regs are incremented even if test is disabled + SWPixelEngine::pereg.IncZInputQuadCount(true); if (bpmem.zmode.testenable) { // early z if (!EfbInterface::ZCompare(x, y, z)) return; } - if (++SWPixelEngine::pereg.perfZcompOutputZcomplocLo == 0) - SWPixelEngine::pereg.perfZcompOutputZcomplocHi++; + SWPixelEngine::pereg.IncZOutputQuadCount(true); } RasterBlockPixel& pixel = rasterBlock.Pixel[xi][yi]; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp index a621542ea0..118e59629e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp @@ -81,17 +81,6 @@ void Read16(u16& _uReturnValue, const u32 _iAddress) if (address <= 0x2e) _uReturnValue = ((u16*)&pereg)[address >> 1]; - - if (address > 0x16) - { - ERROR_LOG(PIXELENGINE, "addr %#08x, ret %#04x; %#04x%04x, %#04x%04x, %#04x%04x, %#04x%04x, %#04x%04x, %#04x%04x\n", address, _uReturnValue, - pereg.perfZcompInputZcomplocHi, pereg.perfZcompInputZcomplocLo, - pereg.perfZcompOutputZcomplocHi, pereg.perfZcompOutputZcomplocLo, - pereg.perfZcompInputHi, pereg.perfZcompInputLo, - pereg.perfZcompOutputHi, pereg.perfZcompOutputLo, - pereg.perfBlendInputHi, pereg.perfBlendInputLo, - pereg.perfEfbCopyClocksHi, pereg.perfEfbCopyClocksLo); - } } void Write32(const u32 _iValue, const u32 _iAddress) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h index 7deb69a164..351e53456d 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h @@ -158,6 +158,54 @@ namespace SWPixelEngine u16 perfBlendInputHi; u16 perfEfbCopyClocksLo; u16 perfEfbCopyClocksHi; + + // NOTE: hardware doesn't process individual pixels but quads instead. Current software renderer architecture works on pixels though, so we have this "quad" hack here to only increment the registers on every fourth rendered pixel + void IncZInputQuadCount(bool early_ztest) + { + static int quad = 0; + if (++quad != 3) + return; + quad = 0; + + if (early_ztest) + { + if (++perfZcompInputZcomplocLo == 0) + perfZcompInputZcomplocHi++; + } + else + { + if (++perfZcompInputLo == 0) + perfZcompInputHi++; + } + } + void IncZOutputQuadCount(bool early_ztest) + { + static int quad = 0; + if (++quad != 3) + return; + quad = 0; + + if (early_ztest) + { + if (++perfZcompOutputZcomplocLo == 0) + perfZcompOutputZcomplocHi++; + } + else + { + if (++perfZcompOutputLo == 0) + perfZcompOutputHi++; + } + } + void IncBlendInputQuadCount() + { + static int quad = 0; + if (++quad != 3) + return; + quad = 0; + + if (++perfBlendInputLo == 0) + perfBlendInputHi++; + } }; extern PEReg pereg; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp index c9c408a623..3d5c0d7724 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp @@ -789,14 +789,12 @@ void Tev::Draw() if (late_ztest && bpmem.zmode.testenable) { // TODO: Check against hw if these values get incremented even if depth testing is disabled - if (++SWPixelEngine::pereg.perfZcompInputLo == 0) - SWPixelEngine::pereg.perfZcompInputHi++; + SWPixelEngine::pereg.IncZInputQuadCount(false); - if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2])) - return; + if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2])) + return; - if (++SWPixelEngine::pereg.perfZcompOutputLo == 0) - SWPixelEngine::pereg.perfZcompOutputHi++; + SWPixelEngine::pereg.IncZOutputQuadCount(false); } #if ALLOW_TEV_DUMPS @@ -820,9 +818,7 @@ void Tev::Draw() #endif INCSTAT(swstats.thisFrame.tevPixelsOut); - - if (++SWPixelEngine::pereg.perfBlendInputLo == 0) - SWPixelEngine::pereg.perfBlendInputHi++; + SWPixelEngine::pereg.IncBlendInputQuadCount(); EfbInterface::BlendTev(Position[0], Position[1], output); }