From 26de63a8cd3e0b05c1ca01bd19e25ace5631943f Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sun, 17 Jun 2012 19:49:48 +0200 Subject: [PATCH] Video_Software: Implement PE pixel metrics --- .../Plugin_VideoSoftware/Src/BPMemLoader.cpp | 9 ++++++++ .../Plugin_VideoSoftware/Src/Rasterizer.cpp | 15 ++++++++---- .../Plugin_VideoSoftware/Src/SWPixelEngine.h | 23 +++++++++++++++++++ .../Plugins/Plugin_VideoSoftware/Src/Tev.cpp | 18 +++++++++++---- 4 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp index 95ec555181..ad730a485c 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp @@ -90,6 +90,15 @@ void SWBPWritten(int address, int newvalue) SWPixelEngine::pereg.boxBottom = newvalue >> 10; SWPixelEngine::pereg.boxTop = newvalue & 0x3ff; break; + case BPMEM_CLEAR_PIXEL_PERF: + // TODO: Parameter? + SWPixelEngine::pereg.perfZcompInputZcomploc = 0; + SWPixelEngine::pereg.perfZcompOutputZcomploc = 0; + SWPixelEngine::pereg.perfZcompInput = 0; + SWPixelEngine::pereg.perfZcompOutput = 0; + SWPixelEngine::pereg.perfBlendInput = 0; + SWPixelEngine::pereg.perfEfbCopyClocks = 0; + break; case BPMEM_LOADTLUT0: // This one updates bpmem.tlutXferSrc, no need to do anything here. break; case BPMEM_LOADTLUT1: // Load a Texture Look Up Table diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp index c212c93601..a23d85f27f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp @@ -23,6 +23,7 @@ #include "BPMemLoader.h" #include "XFMemLoader.h" #include "Tev.h" +#include "SWPixelEngine.h" #include "SWStatistics.h" #include "SWVideoConfig.h" @@ -125,11 +126,17 @@ inline void Draw(s32 x, s32 y, s32 xi, s32 yi) if (z < 0 || z > 0x00ffffff) return; - if (bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) + if (bpmem.zcontrol.zcomploc) { - // early z - if (!EfbInterface::ZCompare(x, y, z)) - return; + // TODO: Verify that perf regs are being incremented even if test is disabled + SWPixelEngine::pereg.perfZcompInputZcomploc++; + if (bpmem.zmode.testenable) + { + // early z + if (!EfbInterface::ZCompare(x, y, z)) + return; + } + SWPixelEngine::pereg.perfZcompOutputZcomploc++; } RasterBlockPixel& pixel = rasterBlock.Pixel[xi][yi]; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h index 6a87143e8c..764488c32e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.h @@ -38,6 +38,21 @@ namespace SWPixelEngine PE_BBOX_RIGHT = 0x012, // Flip Right PE_BBOX_TOP = 0x014, // Flip Top PE_BBOX_BOTTOM = 0x016, // Flip Bottom + + // NOTE: Order not verified + // These indicate the number of quads that are being used as input/output for each particular stage + PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L = 0x18, + PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H = 0x1a, + PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L = 0x1c, + PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H = 0x1e, + PE_PERF_ZCOMP_INPUT_L = 0x20, + PE_PERF_ZCOMP_INPUT_H = 0x22, + PE_PERF_ZCOMP_OUTPUT_L = 0x24, + PE_PERF_ZCOMP_OUTPUT_H = 0x26, + PE_PERF_BLEND_INPUT_L = 0x28, + PE_PERF_BLEND_INPUT_H = 0x2a, + PE_PERF_EFB_COPY_CLOCKS_L = 0x2c, + PE_PERF_EFB_COPY_CLOCKS_H = 0x2e, }; union UPEZConfReg @@ -125,10 +140,18 @@ namespace SWPixelEngine UPECtrlReg ctrl; u16 unk0; u16 token; + u16 boxLeft; u16 boxRight; u16 boxTop; u16 boxBottom; + + u16 perfZcompInputZcomploc; + u16 perfZcompOutputZcomploc; + u16 perfZcompInput; + u16 perfZcompOutput; + u16 perfBlendInput; + u16 perfEfbCopyClocks; }; extern PEReg pereg; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp index c67ee53837..83d9de2784 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp @@ -20,6 +20,7 @@ #include "Tev.h" #include "EfbInterface.h" #include "TextureSampler.h" +#include "SWPixelEngine.h" #include "SWStatistics.h" #include "SWVideoConfig.h" #include "DebugUtil.h" @@ -784,11 +785,16 @@ void Tev::Draw() output[BLU_C] = (output[BLU_C] * invFog + fogInt * bpmem.fog.color.b) >> 8; } - if (!bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) - { - if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2])) - return; - } + if (!bpmem.zcontrol.zcomploc) + { + SWPixelEngine::pereg.perfZcompInput++; + if (bpmem.zmode.testenable) + { + if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2])) + return; + } + SWPixelEngine::pereg.perfZcompOutput++; + } #if ALLOW_TEV_DUMPS if (g_SWVideoConfig.bDumpTevStages) @@ -812,6 +818,8 @@ void Tev::Draw() INCSTAT(swstats.thisFrame.tevPixelsOut); + SWPixelEngine::pereg.perfBlendInput++; + EfbInterface::BlendTev(Position[0], Position[1], output); }