summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/BPStructs.cpp
diff options
context:
space:
mode:
authorNeoBrainX <NeoBrainX@googlemail.com>2013-03-01 01:07:34 +0100
committerNeoBrainX <NeoBrainX@googlemail.com>2013-03-01 01:07:34 +0100
commit7682ed22c6d584bd276c1049c9b5068b1610da61 (patch)
treeea65d89f5b4b172bc1bbbd437ebc28752f336332 /Source/Core/VideoCommon/Src/BPStructs.cpp
parent0f617183a8a74f066d1d01a3ed50042cc9824bf8 (diff)
parentbc15919e2ebefe327ce6330f7abdaccaa2fd2004 (diff)
Merge branch 'master' into perfqueries.
Conflicts: Source/Core/VideoCommon/Src/VideoConfig.h Source/Core/VideoCommon/VideoCommon.vcxproj.filters Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp
Diffstat (limited to 'Source/Core/VideoCommon/Src/BPStructs.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/BPStructs.cpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp
index cda0f7c7c0..a8d081666f 100644
--- a/Source/Core/VideoCommon/Src/BPStructs.cpp
+++ b/Source/Core/VideoCommon/Src/BPStructs.cpp
@@ -35,9 +35,9 @@
using namespace BPFunctions;
-u32 mapTexAddress;
-bool mapTexFound;
-int numWrites;
+static u32 mapTexAddress;
+static bool mapTexFound;
+static int numWrites;
extern volatile bool g_bSkipCurrentFrame;
@@ -81,6 +81,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
+ g_video_backend->CheckInvalidState();
// Debugging only, this lets you skip a bp update
//static int times = 0;
@@ -359,9 +362,9 @@ void BPWritten(const BPCmd& bp)
PixelShaderManager::SetFogColorChanged();
break;
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
- PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alphaFunc.ref0,
- bpmem.alphaFunc.ref1, bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic);
- PixelShaderManager::SetAlpha(bpmem.alphaFunc);
+ PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alpha_test.ref0,
+ bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1, bpmem.alpha_test.logic);
+ PixelShaderManager::SetAlpha(bpmem.alpha_test);
break;
case BPMEM_BIAS: // BIAS
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias);
@@ -458,6 +461,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
+ g_renderer->SetBlendMode(true);
OnPixelFormatChange();
break;
@@ -500,18 +504,39 @@ void BPWritten(const BPCmd& bp)
// 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)
+ // TODO: Not quite sure if this is completely correct (likely not)
+ // NOTE: libogc's implementation of GX_PreloadEntireTexture seems flawed, so it's not necessarily a good reference for RE'ing this feature.
+
BPS_TmemConfig& tmem_cfg = bpmem.tmem_config;
- u8* ram_ptr = Memory::GetPointer(tmem_cfg.preload_addr << 5);
- u32 tmem_addr = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
- u32 size = tmem_cfg.preload_tile_info.count * 32;
+ u8* src_ptr = Memory::GetPointer(tmem_cfg.preload_addr << 5); // TODO: Should we add mask here on GC?
+ u32 size = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE;
+ u32 tmem_addr_even = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
- // 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)
- if ((tmem_addr + size) > TMEM_SIZE)
- size = TMEM_SIZE - tmem_addr;
+ if (tmem_cfg.preload_tile_info.type != 3)
+ {
+ if (tmem_addr_even + size > TMEM_SIZE)
+ size = TMEM_SIZE - tmem_addr_even;
- memcpy(texMem + tmem_addr, ram_ptr, size);
+ memcpy(texMem + tmem_addr_even, src_ptr, size);
+ }
+ else // RGBA8 tiles (and CI14, but that might just be stupid libogc!)
+ {
+ // AR and GB tiles are stored in separate TMEM banks => can't use a single memcpy for everything
+ u32 tmem_addr_odd = tmem_cfg.preload_tmem_odd * TMEM_LINE_SIZE;
+
+ for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i)
+ {
+ if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE ||
+ tmem_addr_odd + TMEM_LINE_SIZE > TMEM_SIZE)
+ break;
+
+ memcpy(texMem + tmem_addr_even, src_ptr, TMEM_LINE_SIZE);
+ memcpy(texMem + tmem_addr_odd, src_ptr + TMEM_LINE_SIZE, TMEM_LINE_SIZE);
+ tmem_addr_even += TMEM_LINE_SIZE;
+ tmem_addr_odd += TMEM_LINE_SIZE;
+ src_ptr += TMEM_LINE_SIZE * 2;
+ }
+ }
}
break;