summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/BPStructs.cpp
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2023-11-12 07:59:32 +0000
committerGitHub <noreply@github.com>2023-11-12 07:59:32 +0000
commite7b922ee62bf8d4c68ae538a136f07f9506cbacc (patch)
tree8a686ad66069e6d25406f9638700d7321d94da61 /Source/Core/VideoCommon/BPStructs.cpp
parente5d2deb0174b5be00fbe95fb38942c65ba5d2d74 (diff)
parentda8407e01c8c535793d859e9878108ec0b7568d5 (diff)
Merge pull request #12286 from Pokechu22/more-bp-register-descriptions
Add descriptions for more BP registers
Diffstat (limited to 'Source/Core/VideoCommon/BPStructs.cpp')
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp76
1 files changed, 45 insertions, 31 deletions
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index 0beb464eae..13a445b94b 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<s32> srcRect;
srcRect.left = bpmem.copyTexSrcXY.x;
@@ -380,24 +380,32 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager,
return;
}
- case BPMEM_LOADTLUT0: // This one updates bpmem.tlutXferSrc, no need to do anything here.
+ case BPMEM_LOADTLUT0: // This updates bpmem.tmem_config.tlut_src, no need to do anything here.
return;
case BPMEM_LOADTLUT1: // Load a Texture Look Up Table
{
- u32 tlutTMemAddr = (bp.newvalue & 0x3FF) << 9;
- u32 tlutXferCount = (bp.newvalue & 0x1FFC00) >> 5;
+ u32 tmem_addr = bpmem.tmem_config.tlut_dest.tmem_addr << 9;
+ u32 tmem_transfer_count = bpmem.tmem_config.tlut_dest.tmem_line_count * TMEM_LINE_SIZE;
u32 addr = bpmem.tmem_config.tlut_src << 5;
// The GameCube ignores the upper bits of this address. Some games (WW, MKDD) set them.
if (!SConfig::GetInstance().bWii)
addr = addr & 0x01FFFFFF;
+ // The copy below will always be in bounds as tmem is bigger than the maximum address a TLUT can
+ // be loaded to.
+ static constexpr u32 MAX_LOADABLE_TMEM_ADDR =
+ (1 << bpmem.tmem_config.tlut_dest.tmem_addr.NumBits()) << 9;
+ static constexpr u32 MAX_TMEM_LINE_COUNT =
+ (1 << bpmem.tmem_config.tlut_dest.tmem_line_count.NumBits()) * TMEM_LINE_SIZE;
+ static_assert(MAX_LOADABLE_TMEM_ADDR + MAX_TMEM_LINE_COUNT < TMEM_SIZE);
+
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory();
- memory.CopyFromEmu(texMem + tlutTMemAddr, addr, tlutXferCount);
+ memory.CopyFromEmu(texMem + tmem_addr, addr, tmem_transfer_count);
if (OpcodeDecoder::g_record_fifo_data)
- FifoRecorder::GetInstance().UseMemory(addr, tlutXferCount, MemoryUpdate::Type::TMEM);
+ FifoRecorder::GetInstance().UseMemory(addr, tmem_transfer_count, MemoryUpdate::Type::TMEM);
TMEM::InvalidateAll();
@@ -515,8 +523,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,9 +990,10 @@ std::pair<std::string, std::string> 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);
- // TODO: Description
+ case BPMEM_EFB_STRIDE: // 0x4D
+ return std::make_pair(
+ RegName(BPMEM_EFB_STRIDE),
+ fmt::format("EFB destination stride (32 byte aligned): 0x{:06X}", cmddata << 5));
case BPMEM_COPYYSCALE: // 0x4E
return std::make_pair(
@@ -1030,12 +1039,14 @@ std::pair<std::string, std::string> GetBPRegInfo(u8 cmd, u32 cmddata)
}
case BPMEM_CLEARBBOX1: // 0x55
- return DescriptionlessReg(BPMEM_CLEARBBOX1);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_CLEARBBOX1),
+ fmt::format("Bounding Box index 0: {}\nBounding Box index 1: {}",
+ cmddata & 0x3ff, (cmddata >> 10) & 0x3ff));
case BPMEM_CLEARBBOX2: // 0x56
- return DescriptionlessReg(BPMEM_CLEARBBOX2);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_CLEARBBOX2),
+ fmt::format("Bounding Box index 2: {}\nBounding Box index 3: {}",
+ cmddata & 0x3ff, (cmddata >> 10) & 0x3ff));
case BPMEM_CLEAR_PIXEL_PERF: // 0x57
return DescriptionlessReg(BPMEM_CLEAR_PIXEL_PERF);
@@ -1050,28 +1061,33 @@ std::pair<std::string, std::string> GetBPRegInfo(u8 cmd, u32 cmddata)
fmt::to_string(ScissorOffset{.hex = cmddata}));
case BPMEM_PRELOAD_ADDR: // 0x60
- return DescriptionlessReg(BPMEM_PRELOAD_ADDR);
- // TODO: Description
+ return std::make_pair(
+ RegName(BPMEM_PRELOAD_ADDR),
+ fmt::format("Tmem preload address (32 byte aligned, in main memory): 0x{:06x}",
+ cmddata << 5));
case BPMEM_PRELOAD_TMEMEVEN: // 0x61
- return DescriptionlessReg(BPMEM_PRELOAD_TMEMEVEN);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_PRELOAD_TMEMEVEN),
+ fmt::format("Tmem preload even line: 0x{:04x} (byte 0x{:05x})", cmddata,
+ cmddata * TMEM_LINE_SIZE));
case BPMEM_PRELOAD_TMEMODD: // 0x62
- return DescriptionlessReg(BPMEM_PRELOAD_TMEMODD);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_PRELOAD_TMEMODD),
+ fmt::format("Tmem preload odd line: 0x{:04x} (byte 0x{:05x})", cmddata,
+ cmddata * TMEM_LINE_SIZE));
case BPMEM_PRELOAD_MODE: // 0x63
return std::make_pair(RegName(BPMEM_PRELOAD_MODE),
fmt::to_string(BPU_PreloadTileInfo{.hex = cmddata}));
case BPMEM_LOADTLUT0: // 0x64
- return DescriptionlessReg(BPMEM_LOADTLUT0);
- // TODO: Description
+ return std::make_pair(
+ RegName(BPMEM_LOADTLUT0),
+ fmt::format("TLUT load address (32 byte aligned, in main memory): 0x{:06x}", cmddata << 5));
case BPMEM_LOADTLUT1: // 0x65
- return DescriptionlessReg(BPMEM_LOADTLUT1);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_LOADTLUT1),
+ fmt::to_string(BPU_LoadTlutInfo{.hex = cmddata}));
case BPMEM_TEXINVALIDATE: // 0x66
return DescriptionlessReg(BPMEM_TEXINVALIDATE);
@@ -1269,12 +1285,11 @@ std::pair<std::string, std::string> GetBPRegInfo(u8 cmd, u32 cmddata)
return std::make_pair(RegName(BPMEM_FOGPARAM0), fmt::to_string(FogParam0{.hex = cmddata}));
case BPMEM_FOGBMAGNITUDE: // 0xEF
- return DescriptionlessReg(BPMEM_FOGBMAGNITUDE);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_FOGBMAGNITUDE), fmt::format("B magnitude: {}", cmddata));
case BPMEM_FOGBEXPONENT: // 0xF0
- return DescriptionlessReg(BPMEM_FOGBEXPONENT);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_FOGBEXPONENT),
+ fmt::format("B shift: 1>>{} (1/{})", cmddata, 1 << cmddata));
case BPMEM_FOGPARAM3: // 0xF1
return std::make_pair(RegName(BPMEM_FOGPARAM3), fmt::to_string(FogParam3{.hex = cmddata}));
@@ -1287,8 +1302,7 @@ std::pair<std::string, std::string> GetBPRegInfo(u8 cmd, u32 cmddata)
return std::make_pair(RegName(BPMEM_ALPHACOMPARE), fmt::to_string(AlphaTest{.hex = cmddata}));
case BPMEM_BIAS: // 0xF4
- return DescriptionlessReg(BPMEM_BIAS);
- // TODO: Description
+ return std::make_pair(RegName(BPMEM_BIAS), fmt::to_string(ZTex1{.hex = cmddata}));
case BPMEM_ZTEX2: // 0xF5
return std::make_pair(RegName(BPMEM_ZTEX2), fmt::to_string(ZTex2{.hex = cmddata}));