From d26bcb0847ad27235020ecaf749154d388f0e162 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 8 Jan 2013 17:18:45 +0100 Subject: Move alpha pretest to BPMemory.h and rename a bunch of alpha testing related stuff --- 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 0bde9cc613..88556cbee8 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -357,9 +357,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); -- cgit v1.2.3 From e7c883d6be5979cc142c942efef354317998fcbc Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Thu, 10 Jan 2013 15:12:21 +0100 Subject: VideoCommon: Implement proper RGBA8 texture loading from tmem. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 39 ++++++++++++++++++++++++------- 1 file changed, 30 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 88556cbee8..c975b12240 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -497,18 +497,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; + + if (tmem_cfg.preload_tile_info.type != 3) + { + if (tmem_addr_even + size > TMEM_SIZE) + size = TMEM_SIZE - tmem_addr_even; - // 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; + 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; - memcpy(texMem + tmem_addr, ram_ptr, size); + for (int i = 0; i < tmem_cfg.preload_tile_info.count; ++i) + { + if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || + tmem_addr_even + 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; -- cgit v1.2.3 From ddf23094c299cb061baaa7a110ecb7413130d094 Mon Sep 17 00:00:00 2001 From: lioncash Date: Tue, 15 Jan 2013 21:15:31 -0500 Subject: Fix two unsigned/signed mismatch warnings. --- Source/Core/VideoCommon/Src/BPStructs.cpp | 2 +- 1 file changed, 1 insertion(+), 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 c975b12240..9ba2afbbd1 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -517,7 +517,7 @@ void BPWritten(const BPCmd& bp) // 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 (int i = 0; i < tmem_cfg.preload_tile_info.count; ++i) + for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i) { if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE) -- cgit v1.2.3 From 2db0c4270eda2e652bb39e394aa8a576785a2354 Mon Sep 17 00:00:00 2001 From: lioncash Date: Thu, 24 Jan 2013 08:21:08 -0500 Subject: Fix a potential memory leak on non-windows systems. Also added a FIXME to BPStructs.cpp and BPMemLoader.cpp --- Source/Core/VideoCommon/Src/BPStructs.cpp | 1 + 1 file changed, 1 insertion(+) (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 9ba2afbbd1..add40d99c3 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -519,6 +519,7 @@ void BPWritten(const BPCmd& bp) for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i) { + // FIXME: Duplicate conditions. if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE) break; -- cgit v1.2.3