From 5a77cae2e3434fa5cbb3710f183328e36620fa5f Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Fri, 18 May 2012 23:13:53 +0200 Subject: Check if BP and XF changes actually change values before flushing --- Source/Core/VideoCommon/Src/BPStructs.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index d59523e117..84f2426f26 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -128,7 +128,17 @@ void BPWritten(const BPCmd& bp) FlushPipeline(); } } // END ZTP SPEEDUP HACK - else FlushPipeline(); + else + { + if (((s32*)&bpmem)[bp.address] != bp.newvalue) + { + FlushPipeline(); + } + else if (bp.address == BPMEM_TRIGGER_EFB_COPY + || bp.address == BPMEM_CLEARBBOX1 + || bp.address == BPMEM_CLEARBBOX2) + FlushPipeline(); + } ((u32*)&bpmem)[bp.address] = bp.newvalue; -- cgit v1.2.3 From c95baf614d2699233b7bf7a474d96aa6c4cf2b78 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 20 May 2012 20:56:03 +0200 Subject: Avoid changing video state on useless BP writes When a game writes the same value that was already configured to a BP register, Dolphin previously flushed the GPU pipeline and reconfigured the internal video state (calling SetScissor/SetLineWidth/SetDepthMode). Some of these useless writes still need to perform actions, for example writes to the EFB copy trigger or the texture preload registers (which need to reload the texture from memory). --- Source/Core/VideoCommon/Src/BPStructs.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 84f2426f26..160ee1a61b 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -130,14 +130,24 @@ void BPWritten(const BPCmd& bp) } // END ZTP SPEEDUP HACK else { - if (((s32*)&bpmem)[bp.address] != bp.newvalue) + if (((s32*)&bpmem)[bp.address] == bp.newvalue) { - FlushPipeline(); + if (!(bp.address == BPMEM_TRIGGER_EFB_COPY + || bp.address == BPMEM_CLEARBBOX1 + || bp.address == BPMEM_CLEARBBOX2 + || bp.address == BPMEM_SETDRAWDONE + || bp.address == BPMEM_PE_TOKEN_ID + || bp.address == BPMEM_PE_TOKEN_INT_ID + || bp.address == BPMEM_LOADTLUT0 + || bp.address == BPMEM_LOADTLUT1 + || bp.address == BPMEM_TEXINVALIDATE + || bp.address == BPMEM_PRELOAD_MODE)) + { + return; + } } - else if (bp.address == BPMEM_TRIGGER_EFB_COPY - || bp.address == BPMEM_CLEARBBOX1 - || bp.address == BPMEM_CLEARBBOX2) - FlushPipeline(); + + FlushPipeline(); } ((u32*)&bpmem)[bp.address] = bp.newvalue; -- cgit v1.2.3 From 2be579e8bad372e7a7433a7d6300939ecef4c654 Mon Sep 17 00:00:00 2001 From: nitsuja Date: Sun, 1 Jan 2012 12:46:02 -0800 Subject: fixed some graphics problems with loading savestates (for example, wrong colors on title screen of metroid prime 3) --- Source/Core/VideoCommon/Src/BPStructs.cpp | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 160ee1a61b..fb22975631 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -160,7 +160,7 @@ void BPWritten(const BPCmd& bp) bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.numindstages, bpmem.genMode.zfreeze); - SetGenerationMode(bp); + SetGenerationMode(); break; } case BPMEM_IND_MTXA: // Index Matrix Changed @@ -188,12 +188,12 @@ void BPWritten(const BPCmd& bp) SetScissor(); break; case BPMEM_LINEPTWIDTH: // Line Width - SetLineWidth(bp); + SetLineWidth(); break; case BPMEM_ZMODE: // Depth Control PRIM_LOG("zmode: test=%d, func=%d, upd=%d", bpmem.zmode.testenable, bpmem.zmode.func, bpmem.zmode.updateenable); - SetDepthMode(bp); + SetDepthMode(); break; case BPMEM_BLENDMODE: // Blending Control { @@ -204,16 +204,16 @@ void BPWritten(const BPCmd& bp) bpmem.blendmode.dstfactor, bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode); // Set LogicOp Blending Mode if (bp.changes & 2) - SetLogicOpMode(bp); + SetLogicOpMode(); // Set Dithering Mode if (bp.changes & 4) - SetDitherMode(bp); + SetDitherMode(); // Set Blending Mode if (bp.changes & 0xFE1) - SetBlendMode(bp); + SetBlendMode(); // Set Color Mask if (bp.changes & 0x18) - SetColorMask(bp); + SetColorMask(); } break; } @@ -306,7 +306,7 @@ void BPWritten(const BPCmd& bp) // Clear the rectangular region after copying it. if (PE_copy.clear) { - ClearScreen(bp, rc); + ClearScreen(rc); } break; @@ -455,7 +455,7 @@ void BPWritten(const BPCmd& bp) case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format g_renderer->SetColorMask(); // alpha writing needs to be disabled if the new pixel format doesn't have an alpha channel - OnPixelFormatChange(bp); + OnPixelFormatChange(); break; case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel @@ -680,3 +680,35 @@ void BPWritten(const BPCmd& bp) } } +// Called when loading a saved state. +void BPReload() +{ + // restore anything that goes straight to the renderer. + // let's not risk actually replaying any writes. + // note that PixelShaderManager is already covered since it has its own DoState. + SetGenerationMode(); + SetScissor(); + SetLineWidth(); + SetDepthMode(); + SetLogicOpMode(); + SetDitherMode(); + SetBlendMode(); + SetColorMask(); + OnPixelFormatChange(); + { + BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_TX_SETMODE0]}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_TX_SETMODE0_4]}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_FIELDMASK]}; + SetInterlacingMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_FIELDMODE]}; + SetInterlacingMode(bp); + } +} -- cgit v1.2.3 From d74c50b9426233fd2afff92dcfbe3a1173c0f9f9 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 2 Jun 2012 11:28:43 +1000 Subject: OSX build fix for BPStructs. Thanks to pauldacheez for the fix. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index fb22975631..d65c873158 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -696,19 +696,19 @@ void BPReload() SetColorMask(); OnPixelFormatChange(); { - BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_TX_SETMODE0]}; + BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; SetTextureMode(bp); } { - BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_TX_SETMODE0_4]}; + BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; SetTextureMode(bp); } { - BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_FIELDMASK]}; + BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMASK])}; SetInterlacingMode(bp); } { - BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, ((u32*)&bpmem)[BPMEM_FIELDMODE]}; + BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMODE])}; SetInterlacingMode(bp); } } -- cgit v1.2.3 From 0d577d886a7dff77a0e39758a2823106415606f8 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sat, 2 Jun 2012 19:23:20 +0200 Subject: Remove some TODOs. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index d65c873158..4f2f6bed25 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -331,8 +331,6 @@ void BPWritten(const BPCmd& bp) else PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tmem_config.tlut_src, bpmem.tmem_config.tlut_src << 5, (bpmem.tmem_config.tlut_src & 0xFFFFF)<< 5); - // TODO(ector) : kill all textures that use this palette - // Not sure if it's a good idea, though. For now, we hash texture palettes break; } case BPMEM_FOGRANGE: // Fog Settings Control @@ -504,7 +502,6 @@ void BPWritten(const BPCmd& bp) // Check if the game has overflowed TMEM, and copy up to the limit. // Paper Mario does this when entering the Great Boogly Tree (Chap 2) - // TODO: Does this wrap? if ((tmem_addr + size) > TMEM_SIZE) size = TMEM_SIZE - tmem_addr; -- cgit v1.2.3 From 6e02ad55bc228ca2af9a695dc404f64765b7472a Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 7 Aug 2012 18:57:53 +0200 Subject: Maintenance. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 4f2f6bed25..179196e412 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -447,8 +447,8 @@ void BPWritten(const BPCmd& bp) } } break; - case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow - DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue); + case BPMEM_TEXINVALIDATE: + // TODO: Needs some restructuring in TextureCacheBase. break; case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format @@ -491,7 +491,7 @@ void BPWritten(const BPCmd& bp) break; case BPMEM_PRELOAD_MODE: // Set to 0 when GX_TexModeSync() is called. - // if this is different from 0, manual TMEM management is used. + // if this is different from 0, manual TMEM management is used (GX_PreloadEntireTexture). if (bp.newvalue != 0) { // NOTE(neobrain): Apparently tmemodd doesn't affect hardware behavior at all (libogc uses it just as a buffer and switches its contents with tmemeven whenever this is called) -- cgit v1.2.3 From 2df0c31d13372bc29d488cf7e80d4adb9cf28b46 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 21 Dec 2012 21:04:53 +0100 Subject: add invalid flag for BPStructs (fix issue 5790) this flag will be set on loading a state and checked before every rendering. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 75 ++++++++++++++++++------------- 1 file changed, 45 insertions(+), 30 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 179196e412..1e13a36f96 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -34,9 +34,10 @@ using namespace BPFunctions; -u32 mapTexAddress; -bool mapTexFound; -int numWrites; +static u32 mapTexAddress; +static bool mapTexFound; +static int numWrites; +static bool s_invalid; extern volatile bool g_bSkipCurrentFrame; @@ -56,6 +57,7 @@ void BPInit() mapTexAddress = 0; numWrites = 0; mapTexFound = false; + s_invalid = false; } void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight, float gamma) @@ -81,6 +83,9 @@ void BPWritten(const BPCmd& bp) just stuff geometry in them and don't put state changes there ---------------------------------------------------------------------------------------------------------------- */ + + // check for invalid state, else unneeded configuration are built + BPReload(); // Debugging only, this lets you skip a bp update //static int times = 0; @@ -680,32 +685,42 @@ void BPWritten(const BPCmd& bp) // Called when loading a saved state. void BPReload() { - // restore anything that goes straight to the renderer. - // let's not risk actually replaying any writes. - // note that PixelShaderManager is already covered since it has its own DoState. - SetGenerationMode(); - SetScissor(); - SetLineWidth(); - SetDepthMode(); - SetLogicOpMode(); - SetDitherMode(); - SetBlendMode(); - SetColorMask(); - OnPixelFormatChange(); - { - BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; - SetTextureMode(bp); - } - { - BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; - SetTextureMode(bp); - } - { - BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMASK])}; - SetInterlacingMode(bp); - } - { - BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMODE])}; - SetInterlacingMode(bp); + if(s_invalid) { + s_invalid = false; + + // restore anything that goes straight to the renderer. + // let's not risk actually replaying any writes. + // note that PixelShaderManager is already covered since it has its own DoState. + SetGenerationMode(); + SetScissor(); + SetLineWidth(); + SetDepthMode(); + SetLogicOpMode(); + SetDitherMode(); + SetBlendMode(); + SetColorMask(); + OnPixelFormatChange(); + { + BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMASK])}; + SetInterlacingMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMODE])}; + SetInterlacingMode(bp); + } } } + +void BPInvalidate() +{ + s_invalid = true; +} + -- cgit v1.2.3 From bd0abb3d2fe5047554bb6b87fa8e3f6aa3f42e0b Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 23 Dec 2012 13:32:23 +0100 Subject: revert last commit, add CheckInvalidState to VideoBackend --- Source/Core/VideoCommon/Src/BPStructs.cpp | 68 +++++++++++++------------------ 1 file changed, 28 insertions(+), 40 deletions(-) (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp') diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 1e13a36f96..0bde9cc613 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -37,7 +37,6 @@ using namespace BPFunctions; static u32 mapTexAddress; static bool mapTexFound; static int numWrites; -static bool s_invalid; extern volatile bool g_bSkipCurrentFrame; @@ -57,7 +56,6 @@ void BPInit() mapTexAddress = 0; numWrites = 0; mapTexFound = false; - s_invalid = false; } void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight, float gamma) @@ -85,7 +83,7 @@ void BPWritten(const BPCmd& bp) */ // check for invalid state, else unneeded configuration are built - BPReload(); + g_video_backend->CheckInvalidState(); // Debugging only, this lets you skip a bp update //static int times = 0; @@ -685,42 +683,32 @@ void BPWritten(const BPCmd& bp) // Called when loading a saved state. void BPReload() { - if(s_invalid) { - s_invalid = false; - - // restore anything that goes straight to the renderer. - // let's not risk actually replaying any writes. - // note that PixelShaderManager is already covered since it has its own DoState. - SetGenerationMode(); - SetScissor(); - SetLineWidth(); - SetDepthMode(); - SetLogicOpMode(); - SetDitherMode(); - SetBlendMode(); - SetColorMask(); - OnPixelFormatChange(); - { - BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; - SetTextureMode(bp); - } - { - BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; - SetTextureMode(bp); - } - { - BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMASK])}; - SetInterlacingMode(bp); - } - { - BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMODE])}; - SetInterlacingMode(bp); - } + // restore anything that goes straight to the renderer. + // let's not risk actually replaying any writes. + // note that PixelShaderManager is already covered since it has its own DoState. + SetGenerationMode(); + SetScissor(); + SetLineWidth(); + SetDepthMode(); + SetLogicOpMode(); + SetDitherMode(); + SetBlendMode(); + SetColorMask(); + OnPixelFormatChange(); + { + BPCmd bp = {BPMEM_TX_SETMODE0, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0])}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_TX_SETMODE0_4, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_TX_SETMODE0_4])}; + SetTextureMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMASK, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMASK])}; + SetInterlacingMode(bp); + } + { + BPCmd bp = {BPMEM_FIELDMODE, 0xFFFFFF, static_cast(((u32*)&bpmem)[BPMEM_FIELDMODE])}; + SetInterlacingMode(bp); } } - -void BPInvalidate() -{ - s_invalid = true; -} - -- cgit v1.2.3