From 6bad17b1706940afd616cfc07f3b8c3997bbb515 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 29 Oct 2023 17:54:51 -0700 Subject: [PATCH] Rename bpmem.copyMipMapStrideChannels to bpmem.copyDestStride As far as I can tell, it has nothing to do with the mipmap/half_scale functionality, but does change based on the width of the destination texture (and the destination texture is half the width if half_scale is set). The comment that was there (which dates back to the initial megacommit) seems to not have accounted for the width aspect; it was first used as an actual stride in bbbe898839467c312c31456334540c20fedc7be3 (the first commit that used it at all). --- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 4 +- .../VideoBackends/Software/TextureEncoder.cpp | 2 +- Source/Core/VideoCommon/BPMemory.h | 57 +++++++++---------- Source/Core/VideoCommon/BPStructs.cpp | 10 ++-- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 9187728c29..32980927dc 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -605,7 +605,7 @@ void FifoPlayer::ClearEfb() wh.x = EFB_WIDTH - 1; wh.y = EFB_HEIGHT - 1; LoadBPReg(BPMEM_EFB_WH, wh.hex); - LoadBPReg(BPMEM_MIPMAP_STRIDE, 0x140); + LoadBPReg(BPMEM_EFB_STRIDE, 0x140); // The clear color and Z value have already been loaded via LoadRegisters() LoadBPReg(BPMEM_EFB_ADDR, 0); UPE_Copy copy = bpmem.triggerEFBCopy; @@ -627,7 +627,7 @@ void FifoPlayer::ClearEfb() // probably a good idea. LoadBPReg(BPMEM_EFB_TL, m_File->GetBPMem()[BPMEM_EFB_TL]); LoadBPReg(BPMEM_EFB_WH, m_File->GetBPMem()[BPMEM_EFB_WH]); - LoadBPReg(BPMEM_MIPMAP_STRIDE, m_File->GetBPMem()[BPMEM_MIPMAP_STRIDE]); + LoadBPReg(BPMEM_EFB_STRIDE, m_File->GetBPMem()[BPMEM_EFB_STRIDE]); LoadBPReg(BPMEM_EFB_ADDR, m_File->GetBPMem()[BPMEM_EFB_ADDR]); // Wait for the EFB copy to finish. That way, the EFB copy (which will be performed at a later // time) won't clobber any memory updates. diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index 2624bf0e04..19880312ac 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -231,7 +231,7 @@ static void SetSpans(int sBlkSize, int tBlkSize, s32* tSpan, s32* sBlkSpan, s32* *tBlkSpan = ((640 * tBlkSize) - alignedWidth) * readStride; // bytes to advance src pointer after each row of blocks - *writeStride = bpmem.copyMipMapStrideChannels * 32; + *writeStride = bpmem.copyDestStride << 5; } #define ENCODE_LOOP_BLOCKS \ diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h index 0df5c6ee20..c157c1814f 100644 --- a/Source/Core/VideoCommon/BPMemory.h +++ b/Source/Core/VideoCommon/BPMemory.h @@ -56,7 +56,7 @@ enum BPMEM_EFB_TL = 0x49, BPMEM_EFB_WH = 0x4A, BPMEM_EFB_ADDR = 0x4B, - BPMEM_MIPMAP_STRIDE = 0x4D, + BPMEM_EFB_STRIDE = 0x4D, BPMEM_COPYYSCALE = 0x4E, BPMEM_CLEAR_AR = 0x4F, BPMEM_CLEAR_GB = 0x50, @@ -2426,35 +2426,32 @@ struct BPMemory // the 3 offset matrices can either be indirect type, S-type, or T-type // 6bit scale factor s is distributed across IND_MTXA/B/C. // before using matrices scale by 2^-(s-17) - IND_MTX indmtx[3]; // 0x06-0x0e: GXSetIndTexMtx, 2x3 matrices - IND_IMASK imask; // 0x0f - TevStageIndirect tevind[16]; // 0x10-0x1f: GXSetTevIndirect - ScissorPos scissorTL; // 0x20 - ScissorPos scissorBR; // 0x21 - LPSize lineptwidth; // 0x22 - u32 sucounter; // 0x23 - u32 rascounter; // 0x24 - TEXSCALE texscale[2]; // 0x25,0x26: GXSetIndTexCoordScale - RAS1_IREF tevindref; // 0x27: GXSetIndTexOrder - TwoTevStageOrders tevorders[8]; // 0x28-0x2f - TCoordInfo texcoords[8]; // 0x30-0x3f: s,t,s,t,s,t,s,t... - ZMode zmode; // 0x40 - BlendMode blendmode; // 0x41 - ConstantAlpha dstalpha; // 0x42 - PEControl zcontrol; // 0x43: GXSetZCompLoc, GXPixModeSync - FieldMask fieldmask; // 0x44 - u32 drawdone; // 0x45: bit1=1 if end of list - u32 unknown5; // 0x46: clock? - u32 petoken; // 0x47 - u32 petokenint; // 0x48 - X10Y10 copyTexSrcXY; // 0x49 - X10Y10 copyTexSrcWH; // 0x4a - u32 copyTexDest; // 0x4b: CopyAddress (GXDispCopy and GXTexCopy use it) - u32 unknown6; // 0x4c - // usually set to 4 when dest is single channel, 8 when dest is 2 channel, 16 when dest is RGBA - // also, doubles whenever mipmap box filter option is set (excent on RGBA). Probably to do - // with number of bytes to look at when smoothing - u32 copyMipMapStrideChannels; // 0x4d + IND_MTX indmtx[3]; // 0x06-0x0e: GXSetIndTexMtx, 2x3 matrices + IND_IMASK imask; // 0x0f + TevStageIndirect tevind[16]; // 0x10-0x1f: GXSetTevIndirect + ScissorPos scissorTL; // 0x20 + ScissorPos scissorBR; // 0x21 + LPSize lineptwidth; // 0x22 + u32 sucounter; // 0x23 + u32 rascounter; // 0x24 + TEXSCALE texscale[2]; // 0x25,0x26: GXSetIndTexCoordScale + RAS1_IREF tevindref; // 0x27: GXSetIndTexOrder + TwoTevStageOrders tevorders[8]; // 0x28-0x2f + TCoordInfo texcoords[8]; // 0x30-0x3f: s,t,s,t,s,t,s,t... + ZMode zmode; // 0x40 + BlendMode blendmode; // 0x41 + ConstantAlpha dstalpha; // 0x42 + PEControl zcontrol; // 0x43: GXSetZCompLoc, GXPixModeSync + FieldMask fieldmask; // 0x44 + u32 drawdone; // 0x45: bit1=1 if end of list + u32 unknown5; // 0x46: clock? + u32 petoken; // 0x47 + u32 petokenint; // 0x48 + X10Y10 copyTexSrcXY; // 0x49 + X10Y10 copyTexSrcWH; // 0x4a + u32 copyTexDest; // 0x4b: CopyAddress (GXDispCopy and GXTexCopy use it) + u32 unknown6; // 0x4c + u32 copyDestStride; // 0x4d u32 dispcopyyscale; // 0x4e u32 clearcolorAR; // 0x4f u32 clearcolorGB; // 0x50 diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 0beb464eae..091c09ee13 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -246,7 +246,7 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, // this function u32 destAddr = bpmem.copyTexDest << 5; - u32 destStride = bpmem.copyMipMapStrideChannels << 5; + u32 destStride = bpmem.copyDestStride << 5; MathUtil::Rectangle srcRect; srcRect.left = bpmem.copyTexSrcXY.x; @@ -515,8 +515,8 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, pixel_shader_manager.SetZModeControl(); return; - case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel - case BPMEM_COPYYSCALE: // Display Copy Y Scale + case BPMEM_EFB_STRIDE: // Display Copy Stride + case BPMEM_COPYYSCALE: // Display Copy Y Scale /* 24 RID * 21 BC3 - Ind. Tex Stage 3 NTexCoord @@ -982,8 +982,8 @@ std::pair GetBPRegInfo(u8 cmd, u32 cmddata) RegName(BPMEM_EFB_ADDR), fmt::format("EFB Target address (32 byte aligned): 0x{:06X}", cmddata << 5)); - case BPMEM_MIPMAP_STRIDE: // 0x4D - return DescriptionlessReg(BPMEM_MIPMAP_STRIDE); + case BPMEM_EFB_STRIDE: // 0x4D + return DescriptionlessReg(BPMEM_EFB_STRIDE); // TODO: Description case BPMEM_COPYYSCALE: // 0x4E