2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoCommon/BPStructs.h"
|
|
|
|
|
2021-09-11 16:44:25 +00:00
|
|
|
#include <algorithm>
|
2009-06-22 09:31:30 +00:00
|
|
|
#include <cmath>
|
2016-01-17 21:54:31 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2019-11-22 22:10:41 +00:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2022-02-07 20:11:15 +00:00
|
|
|
#include "Common/EnumMap.h"
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/Logging/Log.h"
|
2021-03-07 23:42:10 +00:00
|
|
|
|
2014-09-09 04:24:49 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2017-08-13 04:10:21 +00:00
|
|
|
#include "Core/CoreTiming.h"
|
2021-03-07 23:42:10 +00:00
|
|
|
#include "Core/DolphinAnalytics.h"
|
2017-06-26 19:49:32 +00:00
|
|
|
#include "Core/FifoPlayer/FifoPlayer.h"
|
2015-09-07 15:05:47 +00:00
|
|
|
#include "Core/FifoPlayer/FifoRecorder.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2017-06-26 19:49:32 +00:00
|
|
|
#include "Core/HW/VideoInterface.h"
|
2022-11-26 08:29:46 +00:00
|
|
|
#include "Core/System.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
|
|
|
|
#include "VideoCommon/BPFunctions.h"
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
2014-09-17 01:04:37 +00:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2014-07-08 14:49:33 +00:00
|
|
|
#include "VideoCommon/Fifo.h"
|
2019-03-02 07:05:38 +00:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
2014-12-14 20:23:13 +00:00
|
|
|
#include "VideoCommon/GeometryShaderManager.h"
|
2019-12-05 13:11:52 +00:00
|
|
|
#include "VideoCommon/OpcodeDecoding.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
|
|
|
#include "VideoCommon/PixelEngine.h"
|
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2023-01-31 04:29:16 +00:00
|
|
|
#include "VideoCommon/Present.h"
|
2022-09-26 23:11:12 +00:00
|
|
|
#include "VideoCommon/Statistics.h"
|
2019-09-06 09:22:47 +00:00
|
|
|
#include "VideoCommon/TMEM.h"
|
2015-08-31 14:41:16 +00:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/TextureDecoder.h"
|
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2023-01-30 10:59:54 +00:00
|
|
|
#include "VideoCommon/VideoEvents.h"
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
using namespace BPFunctions;
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2022-02-07 20:11:15 +00:00
|
|
|
static constexpr Common::EnumMap<float, GammaCorrection::Invalid2_2> s_gammaLUT = {1.0f, 1.7f, 2.2f,
|
|
|
|
2.2f};
|
2010-12-31 07:06:53 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
void BPInit()
|
|
|
|
{
|
2020-12-16 14:01:20 +00:00
|
|
|
memset(reinterpret_cast<u8*>(&bpmem), 0, sizeof(bpmem));
|
2010-06-05 01:38:22 +00:00
|
|
|
bpmem.bpMask = 0xFFFFFF;
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2022-12-28 14:38:46 +00:00
|
|
|
static void BPWritten(PixelShaderManager& pixel_shader_manager,
|
2022-12-29 14:27:48 +00:00
|
|
|
VertexShaderManager& vertex_shader_manager,
|
|
|
|
GeometryShaderManager& geometry_shader_manager, const BPCmd& bp,
|
2022-12-27 16:42:02 +00:00
|
|
|
int cycles_into_future)
|
2009-06-22 09:31:30 +00:00
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
/*
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
|
|
Purpose: Writes to the BP registers
|
|
|
|
Called: At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg
|
|
|
|
How It Works: First the pipeline is flushed then update the bpmem with the new value.
|
|
|
|
Some of the BP cases have to call certain functions while others just update the bpmem.
|
|
|
|
some bp cases check the changes variable, because they might not have to be updated all
|
|
|
|
the time
|
|
|
|
NOTE: it seems not all bp cases like checking changes, so calling if (bp.changes == 0 ? false :
|
|
|
|
true)
|
|
|
|
had to be ditched and the games seem to work fine with out it.
|
2014-06-07 02:30:39 +00:00
|
|
|
NOTE2: Yet Another GameCube Documentation calls them Bypass Raster State Registers but possibly
|
|
|
|
completely wrong
|
2010-06-05 01:38:22 +00:00
|
|
|
NOTE3: This controls the register groups: RAS1/2, SU, TF, TEV, C/Z, PEC
|
|
|
|
TODO: Turn into function table. The (future) DisplayList (DL) jit can then call the functions
|
|
|
|
directly,
|
|
|
|
getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\
|
|
|
|
just stuff geometry in them and don't put state changes there
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
|
|
*/
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-01-15 21:22:28 +00:00
|
|
|
if (((s32*)&bpmem)[bp.address] == bp.newvalue)
|
2012-05-18 21:13:53 +00:00
|
|
|
{
|
2014-03-10 11:30:55 +00:00
|
|
|
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 ||
|
|
|
|
bp.address == BPMEM_CLEAR_PIXEL_PERF))
|
2012-05-18 21:13:53 +00:00
|
|
|
{
|
2014-01-15 21:22:28 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2012-05-18 21:13:53 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-01-15 21:22:28 +00:00
|
|
|
FlushPipeline();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
((u32*)&bpmem)[bp.address] = bp.newvalue;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
switch (bp.address)
|
|
|
|
{
|
|
|
|
case BPMEM_GENMODE: // Set the Generation Mode
|
2020-11-14 03:33:26 +00:00
|
|
|
PRIM_LOG("genmode: texgen={}, col={}, multisampling={}, tev={}, cullmode={}, ind={}, zfeeze={}",
|
2021-02-11 02:11:31 +00:00
|
|
|
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.multisampling,
|
|
|
|
bpmem.genMode.numtevstages + 1, bpmem.genMode.cullmode, bpmem.genMode.numindstages,
|
|
|
|
bpmem.genMode.zfreeze);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-07-20 05:25:24 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetGenModeChanged();
|
2017-07-20 05:25:24 +00:00
|
|
|
|
2014-05-20 15:28:08 +00:00
|
|
|
// Only call SetGenerationMode when cull mode changes.
|
|
|
|
if (bp.changes & 0xC000)
|
|
|
|
SetGenerationMode();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_IND_MTXA: // Index Matrix Changed
|
|
|
|
case BPMEM_IND_MTXB:
|
|
|
|
case BPMEM_IND_MTXC:
|
|
|
|
case BPMEM_IND_MTXA + 3:
|
|
|
|
case BPMEM_IND_MTXB + 3:
|
|
|
|
case BPMEM_IND_MTXC + 3:
|
|
|
|
case BPMEM_IND_MTXA + 6:
|
|
|
|
case BPMEM_IND_MTXB + 6:
|
|
|
|
case BPMEM_IND_MTXC + 6:
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetIndTexScaleChanged(false);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetIndTexScaleChanged(true);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-07-26 09:52:35 +00:00
|
|
|
// ----------------
|
|
|
|
// Scissor Control
|
|
|
|
// ----------------
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_SCISSORTL: // Scissor Rectable Top, Left
|
|
|
|
case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right
|
|
|
|
case BPMEM_SCISSOROFFSET: // Scissor Offset
|
2022-12-28 14:38:46 +00:00
|
|
|
vertex_shader_manager.SetViewportChanged();
|
2022-12-29 14:27:48 +00:00
|
|
|
geometry_shader_manager.SetViewportChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_LINEPTWIDTH: // Line Width
|
2022-12-29 14:27:48 +00:00
|
|
|
geometry_shader_manager.SetLinePtWidthChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_ZMODE: // Depth Control
|
2021-02-11 02:11:31 +00:00
|
|
|
PRIM_LOG("zmode: test={}, func={}, upd={}", bpmem.zmode.testenable, bpmem.zmode.func,
|
|
|
|
bpmem.zmode.updateenable);
|
2012-01-01 20:46:02 +00:00
|
|
|
SetDepthMode();
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetZModeControl();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_BLENDMODE: // Blending Control
|
2014-05-20 15:28:08 +00:00
|
|
|
if (bp.changes & 0xFFFF)
|
2009-06-22 09:31:30 +00:00
|
|
|
{
|
2020-11-14 03:33:26 +00:00
|
|
|
PRIM_LOG("blendmode: en={}, open={}, colupd={}, alphaupd={}, dst={}, src={}, sub={}, mode={}",
|
2021-02-11 02:11:31 +00:00
|
|
|
bpmem.blendmode.blendenable, bpmem.blendmode.logicopenable,
|
|
|
|
bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.blendmode.dstfactor,
|
|
|
|
bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-04-29 14:57:09 +00:00
|
|
|
SetBlendMode();
|
2017-07-20 05:25:24 +00:00
|
|
|
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetBlendModeChanged();
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2014-05-20 15:28:08 +00:00
|
|
|
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
|
2021-02-11 02:11:31 +00:00
|
|
|
PRIM_LOG("constalpha: alp={}, en={}", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
2017-07-20 05:25:24 +00:00
|
|
|
if (bp.changes)
|
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetAlpha();
|
|
|
|
pixel_shader_manager.SetDestAlphaChanged();
|
2017-07-20 05:25:24 +00:00
|
|
|
}
|
2014-05-20 15:28:08 +00:00
|
|
|
if (bp.changes & 0x100)
|
|
|
|
SetBlendMode();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
// This is called when the game is done drawing the new frame (eg: like in DX: Begin(); Draw();
|
|
|
|
// End();)
|
2009-06-28 17:58:52 +00:00
|
|
|
// Triggers an interrupt on the PPC side so that the game knows when the GPU has finished drawing.
|
|
|
|
// Tokens are similar.
|
2010-06-05 01:38:22 +00:00
|
|
|
case BPMEM_SETDRAWDONE:
|
2009-06-22 09:31:30 +00:00
|
|
|
switch (bp.newvalue & 0xFF)
|
2010-06-05 01:38:22 +00:00
|
|
|
{
|
|
|
|
case 0x02:
|
2022-12-09 19:01:25 +00:00
|
|
|
{
|
2022-09-26 23:11:12 +00:00
|
|
|
INCSTAT(g_stats.this_frame.num_draw_done);
|
2018-11-02 14:17:00 +00:00
|
|
|
g_texture_cache->FlushEFBCopies();
|
2022-07-25 05:20:33 +00:00
|
|
|
g_texture_cache->FlushStaleBinds();
|
2019-03-02 07:05:38 +00:00
|
|
|
g_framebuffer_manager->InvalidatePeekCache(false);
|
2022-09-26 21:41:56 +00:00
|
|
|
g_framebuffer_manager->RefreshPeekCache();
|
2022-12-09 19:01:25 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (!system.GetFifo().UseDeterministicGPUThread())
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetFinish(system, cycles_into_future); // may generate interrupt
|
2020-11-14 03:33:26 +00:00
|
|
|
DEBUG_LOG_FMT(VIDEO, "GXSetDrawDone SetPEFinish (value: {:#04X})", bp.newvalue & 0xFFFF);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2022-12-09 19:01:25 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
default:
|
2020-11-14 03:33:26 +00:00
|
|
|
WARN_LOG_FMT(VIDEO, "GXSetDrawDone ??? (value {:#04X})", bp.newvalue & 0xFFFF);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID
|
2022-12-09 19:01:25 +00:00
|
|
|
{
|
2022-09-26 23:11:12 +00:00
|
|
|
INCSTAT(g_stats.this_frame.num_token);
|
2018-11-02 14:17:00 +00:00
|
|
|
g_texture_cache->FlushEFBCopies();
|
2022-07-25 05:20:33 +00:00
|
|
|
g_texture_cache->FlushStaleBinds();
|
2019-03-02 07:05:38 +00:00
|
|
|
g_framebuffer_manager->InvalidatePeekCache(false);
|
2022-09-26 21:41:56 +00:00
|
|
|
g_framebuffer_manager->RefreshPeekCache();
|
2022-12-09 19:01:25 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (!system.GetFifo().UseDeterministicGPUThread())
|
2022-12-10 15:35:07 +00:00
|
|
|
{
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetToken(system, static_cast<u16>(bp.newvalue & 0xFFFF), false,
|
2022-12-10 15:35:07 +00:00
|
|
|
cycles_into_future);
|
|
|
|
}
|
2020-11-14 03:33:26 +00:00
|
|
|
DEBUG_LOG_FMT(VIDEO, "SetPEToken {:#06X}", bp.newvalue & 0xFFFF);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2022-12-09 19:01:25 +00:00
|
|
|
}
|
2010-06-05 01:38:22 +00:00
|
|
|
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
|
2022-12-09 19:01:25 +00:00
|
|
|
{
|
2022-09-26 23:11:12 +00:00
|
|
|
INCSTAT(g_stats.this_frame.num_token_int);
|
2018-11-02 14:17:00 +00:00
|
|
|
g_texture_cache->FlushEFBCopies();
|
2022-07-25 05:20:33 +00:00
|
|
|
g_texture_cache->FlushStaleBinds();
|
2019-03-02 07:05:38 +00:00
|
|
|
g_framebuffer_manager->InvalidatePeekCache(false);
|
2022-09-26 21:41:56 +00:00
|
|
|
g_framebuffer_manager->RefreshPeekCache();
|
2022-12-09 19:01:25 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (!system.GetFifo().UseDeterministicGPUThread())
|
2022-12-10 15:35:07 +00:00
|
|
|
{
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetToken(system, static_cast<u16>(bp.newvalue & 0xFFFF), true,
|
2022-12-10 15:35:07 +00:00
|
|
|
cycles_into_future);
|
|
|
|
}
|
2020-11-14 03:33:26 +00:00
|
|
|
DEBUG_LOG_FMT(VIDEO, "SetPEToken + INT {:#06X}", bp.newvalue & 0xFFFF);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2022-12-09 19:01:25 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
// ------------------------
|
|
|
|
// EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to
|
|
|
|
// XFB as YUYV.
|
|
|
|
// It can also optionally clear the EFB while copying from it. To emulate this, we of course copy
|
|
|
|
// first and clear afterwards.
|
2010-06-05 01:38:22 +00:00
|
|
|
case BPMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen.
|
2009-06-22 09:31:30 +00:00
|
|
|
{
|
|
|
|
// The bottom right is within the rectangle
|
|
|
|
// The values in bpmem.copyTexSrcXY and bpmem.copyTexSrcWH are updated in case 0x49 and 0x4a in
|
|
|
|
// this function
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 21:16:18 +00:00
|
|
|
u32 destAddr = bpmem.copyTexDest << 5;
|
2023-10-30 00:54:51 +00:00
|
|
|
u32 destStride = bpmem.copyDestStride << 5;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-04-19 12:20:37 +00:00
|
|
|
MathUtil::Rectangle<s32> srcRect;
|
|
|
|
srcRect.left = bpmem.copyTexSrcXY.x;
|
|
|
|
srcRect.top = bpmem.copyTexSrcXY.y;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-12-18 18:23:22 +00:00
|
|
|
// Here Width+1 like Height, otherwise some textures are corrupted already since the native
|
|
|
|
// resolution.
|
2021-04-19 12:20:37 +00:00
|
|
|
srcRect.right = bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1;
|
|
|
|
srcRect.bottom = bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-09-18 05:29:46 +00:00
|
|
|
const UPE_Copy PE_copy = bpmem.triggerEFBCopy;
|
|
|
|
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
// Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a copy region up
|
|
|
|
// to 1024x1024. Hardware tests have found that the number of bytes written does not depend on
|
|
|
|
// the configured stride, instead it is based on the size registers, writing beyond the length
|
|
|
|
// of a single row. The data written for the pixels which lie outside the EFB bounds does not
|
|
|
|
// wrap around instead returning different colors based on the pixel format of the EFB. This
|
|
|
|
// suggests it's not based on coordinates, but instead on memory addresses. The effect of a
|
|
|
|
// within-bounds size but out-of-bounds offset (e.g. offset 320,0, size 640,480) are the same.
|
|
|
|
|
|
|
|
// As it would be difficult to emulate the exact behavior of out-of-bounds reads, instead of
|
|
|
|
// writing the junk data, we don't write anything to RAM at all for over-sized copies, and clamp
|
|
|
|
// to the EFB borders for over-offset copies. The arcade virtual console games (e.g. 1942) are
|
|
|
|
// known for configuring these out-of-range copies.
|
2021-09-11 16:44:25 +00:00
|
|
|
|
|
|
|
if (u32(srcRect.right) > EFB_WIDTH || u32(srcRect.bottom) > EFB_HEIGHT)
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
{
|
2021-09-11 16:44:25 +00:00
|
|
|
WARN_LOG_FMT(VIDEO, "Oversized EFB copy: {}x{} (offset {},{} stride {})", srcRect.GetWidth(),
|
|
|
|
srcRect.GetHeight(), srcRect.left, srcRect.top, destStride);
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
|
2021-09-17 00:39:06 +00:00
|
|
|
if (u32(srcRect.left) >= EFB_WIDTH || u32(srcRect.top) >= EFB_HEIGHT)
|
|
|
|
{
|
|
|
|
// This is not a sane src rectangle, it doesn't touch any valid image data at all
|
|
|
|
// Just ignore it
|
|
|
|
// Apparently Mario Kart Wii in wifi mode can generate a deformed EFB copy of size 4x4
|
|
|
|
// at offset (328,1020)
|
2021-09-18 05:29:46 +00:00
|
|
|
if (PE_copy.copy_to_xfb == 1)
|
|
|
|
{
|
|
|
|
// Make sure we disable Bounding box to match the side effects of the non-failure path
|
2023-01-29 14:40:15 +00:00
|
|
|
g_bounding_box->Disable(pixel_shader_manager);
|
2021-09-18 05:29:46 +00:00
|
|
|
}
|
|
|
|
|
2021-09-17 00:39:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-11 16:44:25 +00:00
|
|
|
// Clamp the copy region to fit within EFB. So that we don't end up with a stretched image.
|
|
|
|
srcRect.right = std::clamp<int>(srcRect.right, 0, EFB_WIDTH);
|
|
|
|
srcRect.bottom = std::clamp<int>(srcRect.bottom, 0, EFB_HEIGHT);
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-09-14 23:54:40 +00:00
|
|
|
const u32 copy_width = srcRect.GetWidth();
|
|
|
|
const u32 copy_height = srcRect.GetHeight();
|
2021-09-11 16:44:25 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
// Check if we are to copy from the EFB or draw to the XFB
|
|
|
|
if (PE_copy.copy_to_xfb == 0)
|
|
|
|
{
|
2021-02-11 02:11:31 +00:00
|
|
|
// bpmem.zcontrol.pixel_format to PixelFormat::Z24 is when the game wants to copy from ZBuffer
|
2015-08-31 14:41:16 +00:00
|
|
|
// (Zbuffer uses 24-bit Format)
|
2021-02-11 02:11:31 +00:00
|
|
|
bool is_depth_copy = bpmem.zcontrol.pixel_format == PixelFormat::Z24;
|
2017-12-23 11:44:01 +00:00
|
|
|
g_texture_cache->CopyRenderTargetToTexture(
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
destAddr, PE_copy.tp_realFormat(), copy_width, copy_height, destStride, is_depth_copy,
|
2022-02-07 20:11:15 +00:00
|
|
|
srcRect, PE_copy.intensity_fmt && PE_copy.auto_conv, PE_copy.half_scale, 1.0f,
|
|
|
|
s_gammaLUT[PE_copy.gamma], bpmem.triggerEFBCopy.clamp_top,
|
|
|
|
bpmem.triggerEFBCopy.clamp_bottom, bpmem.copyfilter.GetCoefficients());
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-28 20:04:07 +00:00
|
|
|
// We should be able to get away with deactivating the current bbox tracking
|
|
|
|
// here. Not sure if there's a better spot to put this.
|
2009-06-22 09:31:30 +00:00
|
|
|
// the number of lines copied is determined by the y scale * source efb height
|
2023-01-29 14:40:15 +00:00
|
|
|
g_bounding_box->Disable(pixel_shader_manager);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-07-18 20:38:35 +00:00
|
|
|
float yScale;
|
2009-07-19 08:24:30 +00:00
|
|
|
if (PE_copy.scale_invert)
|
2017-12-22 03:16:21 +00:00
|
|
|
yScale = 256.0f / static_cast<float>(bpmem.dispcopyyscale);
|
2009-07-18 20:38:35 +00:00
|
|
|
else
|
2017-12-22 03:16:21 +00:00
|
|
|
yScale = static_cast<float>(bpmem.dispcopyyscale) / 256.0f;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-09-04 13:32:30 +00:00
|
|
|
float num_xfb_lines = 1.0f + bpmem.copyTexSrcWH.y * yScale;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-08-20 03:16:50 +00:00
|
|
|
u32 height = static_cast<u32>(num_xfb_lines);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2020-11-14 03:33:26 +00:00
|
|
|
DEBUG_LOG_FMT(VIDEO,
|
|
|
|
"RenderToXFB: destAddr: {:08x} | srcRect [{} {} {} {}] | fbWidth: {} | "
|
|
|
|
"fbStride: {} | fbHeight: {} | yScale: {}",
|
|
|
|
destAddr, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom,
|
|
|
|
bpmem.copyTexSrcWH.x + 1, destStride, height, yScale);
|
2017-05-29 22:02:09 +00:00
|
|
|
|
2021-02-11 02:11:31 +00:00
|
|
|
bool is_depth_copy = bpmem.zcontrol.pixel_format == PixelFormat::Z24;
|
2018-04-29 08:52:30 +00:00
|
|
|
g_texture_cache->CopyRenderTargetToTexture(
|
BPStructs: Gracefully handle out-of-range EFB copies
Since the copy X and Y coordinates/sizes are 10-bit, the game can configure a
copy region up to 1024x1024. Hardware tests have found that the number of bytes
written does not depend on the configured stride, instead it is based on the
size registers, writing beyond the length of a single row. The data written
for the pixels which lie outside the EFB bounds does not wrap around instead
returning different colors based on the pixel format of the EFB.
This suggests it's not based on coordinates, but instead on memory addresses.
The effect of a within-bounds size but out-of-bounds offset
(e.g. offset 320,0, size 640,480) are the same.
As it would be difficult to emulate the exact behavior of out-of-bounds reads,
instead of writing the junk data, we don't write anything to RAM at all for
over-sized copies, and clamp to the EFB borders for over-offset copies.
2019-03-31 11:39:04 +00:00
|
|
|
destAddr, EFBCopyFormat::XFB, copy_width, height, destStride, is_depth_copy, srcRect,
|
|
|
|
false, false, yScale, s_gammaLUT[PE_copy.gamma], bpmem.triggerEFBCopy.clamp_top,
|
2018-04-29 08:52:30 +00:00
|
|
|
bpmem.triggerEFBCopy.clamp_bottom, bpmem.copyfilter.GetCoefficients());
|
2017-05-29 22:02:09 +00:00
|
|
|
|
2023-01-30 10:59:54 +00:00
|
|
|
// This is as closest as we have to an "end of the frame"
|
|
|
|
// It works 99% of the time.
|
2023-02-03 00:01:18 +00:00
|
|
|
// But sometimes games want to render an XFB larger than the EFB's 640x528 pixel resolution
|
|
|
|
// (especially when using the 3xMSAA mode, which cuts EFB resolution to 640x264). So they
|
|
|
|
// render multiple sub-frames and arrange the XFB copies in next to each-other in main memory
|
|
|
|
// so they form a single completed XFB.
|
|
|
|
// See https://dolphin-emu.org/blog/2017/11/19/hybridxfb/ for examples and more detail.
|
2023-01-30 10:59:54 +00:00
|
|
|
AfterFrameEvent::Trigger();
|
|
|
|
|
2023-02-03 00:01:18 +00:00
|
|
|
// Note: Theoretically, in the future we could track the VI configuration and try to detect
|
|
|
|
// when an XFB is the last XFB copy of a frame. Not only would we get a clean "end of
|
|
|
|
// the frame", but we would also be able to use ImmediateXFB even for these games.
|
|
|
|
// Might also clean up some issues with games doing XFB copies they don't intend to
|
|
|
|
// display.
|
|
|
|
|
2017-08-13 04:10:21 +00:00
|
|
|
if (g_ActiveConfig.bImmediateXFB)
|
2017-06-26 19:49:32 +00:00
|
|
|
{
|
2017-08-13 04:10:21 +00:00
|
|
|
// below div two to convert from bytes to pixels - it expects width, not stride
|
2023-01-30 11:59:17 +00:00
|
|
|
u64 ticks = Core::System::GetInstance().GetCoreTiming().GetTicks();
|
|
|
|
g_presenter->ImmediateSwap(destAddr, destStride / 2, destStride, height, ticks);
|
2017-08-13 04:10:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FifoPlayer::GetInstance().IsRunningWithFakeVideoInterfaceUpdates())
|
|
|
|
{
|
2023-03-10 21:14:54 +00:00
|
|
|
auto& vi = Core::System::GetInstance().GetVideoInterface();
|
|
|
|
vi.FakeVIUpdate(destAddr, srcRect.GetWidth(), destStride, height);
|
2017-08-13 04:10:21 +00:00
|
|
|
}
|
2017-06-26 19:49:32 +00:00
|
|
|
}
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-09-13 21:18:04 +00:00
|
|
|
// Clear the rectangular region after copying it.
|
2009-06-22 09:31:30 +00:00
|
|
|
if (PE_copy.clear)
|
2009-09-13 21:18:04 +00:00
|
|
|
{
|
2014-05-03 21:16:18 +00:00
|
|
|
ClearScreen(srcRect);
|
2009-09-13 21:18:04 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2023-10-30 02:24:40 +00:00
|
|
|
case BPMEM_LOADTLUT0: // This updates bpmem.tmem_config.tlut_src, no need to do anything here.
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-12-28 19:13:06 +00:00
|
|
|
case BPMEM_LOADTLUT1: // Load a Texture Look Up Table
|
2010-06-05 01:38:22 +00:00
|
|
|
{
|
2023-10-30 02:24:40 +00:00
|
|
|
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;
|
2014-10-28 13:20:49 +00:00
|
|
|
u32 addr = bpmem.tmem_config.tlut_src << 5;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-10-28 13:20:49 +00:00
|
|
|
// The GameCube ignores the upper bits of this address. Some games (WW, MKDD) set them.
|
2015-06-12 11:56:53 +00:00
|
|
|
if (!SConfig::GetInstance().bWii)
|
2014-10-28 13:20:49 +00:00
|
|
|
addr = addr & 0x01FFFFFF;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2023-10-30 02:24:40 +00:00
|
|
|
// 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);
|
|
|
|
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
2023-10-30 02:24:40 +00:00
|
|
|
memory.CopyFromEmu(texMem + tmem_addr, addr, tmem_transfer_count);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-12-05 13:11:52 +00:00
|
|
|
if (OpcodeDecoder::g_record_fifo_data)
|
2023-10-30 02:24:40 +00:00
|
|
|
FifoRecorder::GetInstance().UseMemory(addr, tmem_transfer_count, MemoryUpdate::Type::TMEM);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::InvalidateAll();
|
2017-06-29 21:09:32 +00:00
|
|
|
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2010-06-05 01:38:22 +00:00
|
|
|
}
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_FOGRANGE: // Fog Settings Control
|
2010-05-24 14:53:27 +00:00
|
|
|
case BPMEM_FOGRANGE + 1:
|
|
|
|
case BPMEM_FOGRANGE + 2:
|
|
|
|
case BPMEM_FOGRANGE + 3:
|
|
|
|
case BPMEM_FOGRANGE + 4:
|
|
|
|
case BPMEM_FOGRANGE + 5:
|
2014-05-03 19:08:11 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetFogRangeAdjustChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_FOGPARAM0:
|
|
|
|
case BPMEM_FOGBMAGNITUDE:
|
|
|
|
case BPMEM_FOGBEXPONENT:
|
|
|
|
case BPMEM_FOGPARAM3:
|
2014-05-03 19:08:11 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetFogParamChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_FOGCOLOR: // Fog Color
|
2014-05-03 19:08:11 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetFogColorChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
|
2021-02-11 02:11:31 +00:00
|
|
|
PRIM_LOG("alphacmp: ref0={}, ref1={}, comp0={}, comp1={}, logic={}", bpmem.alpha_test.ref0,
|
|
|
|
bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1,
|
|
|
|
bpmem.alpha_test.logic);
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes & 0xFFFF)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetAlpha();
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes)
|
2016-12-29 17:03:22 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetAlphaTestChanged();
|
2016-12-29 17:03:22 +00:00
|
|
|
SetBlendMode();
|
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_BIAS: // BIAS
|
2021-02-11 02:11:31 +00:00
|
|
|
PRIM_LOG("ztex bias={:#x}", bpmem.ztex1.bias);
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetZTextureBias();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_ZTEX2: // Z Texture type
|
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
if (bp.changes & 3)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetZTextureTypeChanged();
|
2017-02-24 14:16:28 +00:00
|
|
|
if (bp.changes & 12)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetZTextureOpChanged();
|
2021-02-11 02:11:31 +00:00
|
|
|
PRIM_LOG("ztex op={}, type={}", bpmem.ztex2.op, bpmem.ztex2.type);
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
// ----------------------------------
|
2009-07-26 09:52:35 +00:00
|
|
|
// Display Copy Filtering Control - GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8
|
|
|
|
// vfilter[7])
|
2009-06-22 09:31:30 +00:00
|
|
|
// Fields: Destination, Frame2Field, Gamma, Source
|
|
|
|
// ----------------------------------
|
2014-05-03 19:53:42 +00:00
|
|
|
case BPMEM_DISPLAYCOPYFILTER: // if (aa) { use sample_pattern } else { use 666666 }
|
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 1: // if (aa) { use sample_pattern } else { use 666666 }
|
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 2: // if (aa) { use sample_pattern } else { use 666666 }
|
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 3: // if (aa) { use sample_pattern } else { use 666666 }
|
2014-05-20 15:23:47 +00:00
|
|
|
case BPMEM_COPYFILTER0: // if (vf) { use vfilter } else { use 595000 }
|
|
|
|
case BPMEM_COPYFILTER1: // if (vf) { use vfilter } else { use 000015 }
|
|
|
|
return;
|
2009-07-26 09:52:35 +00:00
|
|
|
// -----------------------------------
|
|
|
|
// Interlacing Control
|
|
|
|
// -----------------------------------
|
|
|
|
case BPMEM_FIELDMASK: // GX_SetFieldMask(u8 even_mask,u8 odd_mask)
|
|
|
|
case BPMEM_FIELDMODE: // GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio)
|
2014-05-20 15:23:47 +00:00
|
|
|
// TODO
|
|
|
|
return;
|
2009-07-26 09:52:35 +00:00
|
|
|
// ----------------------------------------
|
|
|
|
// Unimportant regs (Clock, Perf, ...)
|
|
|
|
// ----------------------------------------
|
|
|
|
case BPMEM_BUSCLOCK0: // TB Bus Clock ?
|
|
|
|
case BPMEM_BUSCLOCK1: // TB Bus Clock ?
|
|
|
|
case BPMEM_PERF0_TRI: // Perf: Triangles
|
|
|
|
case BPMEM_PERF0_QUAD: // Perf: Quads
|
|
|
|
case BPMEM_PERF1: // Perf: Some Clock, Texels, TX, TC
|
2018-10-07 15:08:18 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
// ----------------
|
|
|
|
// EFB Copy config
|
|
|
|
// ----------------
|
|
|
|
case BPMEM_EFB_TL: // EFB Source Rect. Top, Left
|
2021-02-07 20:32:45 +00:00
|
|
|
case BPMEM_EFB_WH: // EFB Source Rect. Width, Height - 1
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_EFB_ADDR: // EFB Target Address
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
// --------------
|
|
|
|
// Clear Config
|
|
|
|
// --------------
|
|
|
|
case BPMEM_CLEAR_AR: // Alpha and Red Components
|
|
|
|
case BPMEM_CLEAR_GB: // Green and Blue Components
|
|
|
|
case BPMEM_CLEAR_Z: // Z Components (24-bit Zbuffer)
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2009-06-22 09:31:30 +00:00
|
|
|
// -------------------------
|
2009-07-26 09:52:35 +00:00
|
|
|
// Bounding Box Control
|
2009-06-22 09:31:30 +00:00
|
|
|
// -------------------------
|
|
|
|
case BPMEM_CLEARBBOX1:
|
2010-07-06 13:14:51 +00:00
|
|
|
case BPMEM_CLEARBBOX2:
|
2016-10-08 02:55:47 +00:00
|
|
|
{
|
2019-12-05 15:58:03 +00:00
|
|
|
const u8 offset = bp.address & 2;
|
2023-01-29 14:40:15 +00:00
|
|
|
g_bounding_box->Enable(pixel_shader_manager);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2023-01-29 14:40:15 +00:00
|
|
|
g_bounding_box->Set(offset, bp.newvalue & 0x3ff);
|
|
|
|
g_bounding_box->Set(offset + 1, bp.newvalue >> 10);
|
2016-10-08 02:55:47 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2012-08-07 16:57:53 +00:00
|
|
|
case BPMEM_TEXINVALIDATE:
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::Invalidate(bp.newvalue);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-06-29 00:52:54 +00:00
|
|
|
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
|
2012-01-01 20:46:02 +00:00
|
|
|
OnPixelFormatChange();
|
2014-03-10 11:30:55 +00:00
|
|
|
if (bp.changes & 7)
|
2013-01-17 23:44:35 +00:00
|
|
|
SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetZModeControl();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2023-10-30 00:54:51 +00:00
|
|
|
case BPMEM_EFB_STRIDE: // Display Copy Stride
|
|
|
|
case BPMEM_COPYYSCALE: // Display Copy Y Scale
|
2023-10-29 23:51:53 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:28:08 +00:00
|
|
|
/* 24 RID
|
|
|
|
* 21 BC3 - Ind. Tex Stage 3 NTexCoord
|
|
|
|
* 18 BI3 - Ind. Tex Stage 3 NTexMap
|
|
|
|
* 15 BC2 - Ind. Tex Stage 2 NTexCoord
|
|
|
|
* 12 BI2 - Ind. Tex Stage 2 NTexMap
|
|
|
|
* 9 BC1 - Ind. Tex Stage 1 NTexCoord
|
|
|
|
* 6 BI1 - Ind. Tex Stage 1 NTexMap
|
|
|
|
* 3 BC0 - Ind. Tex Stage 0 NTexCoord
|
|
|
|
* 0 BI0 - Ind. Tex Stage 0 NTexMap */
|
|
|
|
case BPMEM_IREF:
|
2017-07-20 05:25:24 +00:00
|
|
|
{
|
|
|
|
if (bp.changes)
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevIndirectChanged();
|
2017-07-20 05:25:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:28:08 +00:00
|
|
|
case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
|
|
|
|
case BPMEM_TEV_KSEL + 1: // Texture Environment Swap Mode Table 1
|
|
|
|
case BPMEM_TEV_KSEL + 2: // Texture Environment Swap Mode Table 2
|
|
|
|
case BPMEM_TEV_KSEL + 3: // Texture Environment Swap Mode Table 3
|
|
|
|
case BPMEM_TEV_KSEL + 4: // Texture Environment Swap Mode Table 4
|
|
|
|
case BPMEM_TEV_KSEL + 5: // Texture Environment Swap Mode Table 5
|
|
|
|
case BPMEM_TEV_KSEL + 6: // Texture Environment Swap Mode Table 6
|
|
|
|
case BPMEM_TEV_KSEL + 7: // Texture Environment Swap Mode Table 7
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevKSel(bp.address - BPMEM_TEV_KSEL, bp.newvalue);
|
2017-07-20 05:25:24 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:26:31 +00:00
|
|
|
/* This Register can be used to limit to which bits of BP registers is
|
|
|
|
* actually written to. The mask is only valid for the next BP write,
|
|
|
|
* and will reset itself afterwards. It's handled as a special case in
|
|
|
|
* LoadBPReg. */
|
|
|
|
case BPMEM_BP_MASK:
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
case BPMEM_IND_IMASK: // Index Mask ?
|
2009-07-26 09:52:35 +00:00
|
|
|
case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called.
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-05-29 11:54:20 +00:00
|
|
|
case BPMEM_CLEAR_PIXEL_PERF:
|
|
|
|
// GXClearPixMetric writes 0xAAA here, Sunshine alternates this register between values 0x000
|
|
|
|
// and 0xAAA
|
2014-03-10 11:30:55 +00:00
|
|
|
if (PerfQueryBase::ShouldEmulate())
|
2014-02-04 19:16:03 +00:00
|
|
|
g_perf_query->ResetQuery();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-01-29 20:17:22 +00:00
|
|
|
case BPMEM_PRELOAD_ADDR:
|
|
|
|
case BPMEM_PRELOAD_TMEMEVEN:
|
|
|
|
case BPMEM_PRELOAD_TMEMODD: // Used when PRELOAD_MODE is set
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-01-29 20:17:22 +00:00
|
|
|
case BPMEM_PRELOAD_MODE: // Set to 0 when GX_TexModeSync() is called.
|
2012-08-07 16:57:53 +00:00
|
|
|
// if this is different from 0, manual TMEM management is used (GX_PreloadEntireTexture).
|
2012-01-29 20:17:22 +00:00
|
|
|
if (bp.newvalue != 0)
|
|
|
|
{
|
2013-01-10 14:12:21 +00:00
|
|
|
// 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.
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2012-01-29 20:17:22 +00:00
|
|
|
BPS_TmemConfig& tmem_cfg = bpmem.tmem_config;
|
2014-10-19 13:51:01 +00:00
|
|
|
u32 src_addr = tmem_cfg.preload_addr << 5; // TODO: Should we add mask here on GC?
|
2015-09-07 15:05:47 +00:00
|
|
|
u32 bytes_read = 0;
|
2013-01-10 14:12:21 +00:00
|
|
|
u32 tmem_addr_even = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2013-01-10 14:12:21 +00:00
|
|
|
if (tmem_cfg.preload_tile_info.type != 3)
|
|
|
|
{
|
2015-09-07 15:05:47 +00:00
|
|
|
bytes_read = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE;
|
|
|
|
if (tmem_addr_even + bytes_read > TMEM_SIZE)
|
|
|
|
bytes_read = TMEM_SIZE - tmem_addr_even;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
memory.CopyFromEmu(texMem + tmem_addr_even, src_addr, bytes_read);
|
2013-01-10 14:12:21 +00:00
|
|
|
}
|
|
|
|
else // RGBA8 tiles (and CI14, but that might just be stupid libogc!)
|
|
|
|
{
|
2022-12-02 19:07:30 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
auto& memory = system.GetMemory();
|
|
|
|
u8* src_ptr = memory.GetPointer(src_addr);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2013-01-10 14:12:21 +00:00
|
|
|
// 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;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2013-01-16 02:15:31 +00:00
|
|
|
for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i)
|
2013-01-10 14:12:21 +00:00
|
|
|
{
|
2015-09-07 15:05:47 +00:00
|
|
|
if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE ||
|
|
|
|
tmem_addr_odd + TMEM_LINE_SIZE > TMEM_SIZE)
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-09-07 15:05:47 +00:00
|
|
|
memcpy(texMem + tmem_addr_even, src_ptr + bytes_read, TMEM_LINE_SIZE);
|
|
|
|
memcpy(texMem + tmem_addr_odd, src_ptr + bytes_read + TMEM_LINE_SIZE, TMEM_LINE_SIZE);
|
2013-01-10 14:12:21 +00:00
|
|
|
tmem_addr_even += TMEM_LINE_SIZE;
|
|
|
|
tmem_addr_odd += TMEM_LINE_SIZE;
|
2015-09-07 15:05:47 +00:00
|
|
|
bytes_read += TMEM_LINE_SIZE * 2;
|
2013-01-10 14:12:21 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-05 13:11:52 +00:00
|
|
|
if (OpcodeDecoder::g_record_fifo_data)
|
2023-08-30 02:27:59 +00:00
|
|
|
FifoRecorder::GetInstance().UseMemory(src_addr, bytes_read, MemoryUpdate::Type::TMEM);
|
2017-06-29 21:09:32 +00:00
|
|
|
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::InvalidateAll();
|
2012-01-29 20:17:22 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-09-17 16:46:23 +00:00
|
|
|
// ---------------------------------------------------
|
|
|
|
// Set the TEV Color
|
|
|
|
// ---------------------------------------------------
|
2016-06-24 08:43:46 +00:00
|
|
|
//
|
2014-09-17 16:46:23 +00:00
|
|
|
// NOTE: Each of these registers actually maps to two variables internally.
|
|
|
|
// There's a bit that specifies which one is currently written to.
|
|
|
|
//
|
|
|
|
// NOTE: Some games write only to the RA register (or only to the BG register).
|
|
|
|
// We may not assume that the unwritten register holds a valid value, hence
|
|
|
|
// both component pairs need to be loaded individually.
|
|
|
|
case BPMEM_TEV_COLOR_RA:
|
|
|
|
case BPMEM_TEV_COLOR_RA + 2:
|
|
|
|
case BPMEM_TEV_COLOR_RA + 4:
|
|
|
|
case BPMEM_TEV_COLOR_RA + 6:
|
|
|
|
{
|
|
|
|
int num = (bp.address >> 1) & 0x3;
|
2021-02-11 02:11:31 +00:00
|
|
|
if (bpmem.tevregs[num].ra.type == TevRegType::Constant)
|
2014-09-17 16:46:23 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevKonstColor(num, 0, bpmem.tevregs[num].ra.red);
|
|
|
|
pixel_shader_manager.SetTevKonstColor(num, 3, bpmem.tevregs[num].ra.alpha);
|
2014-09-17 16:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevColor(num, 0, bpmem.tevregs[num].ra.red);
|
|
|
|
pixel_shader_manager.SetTevColor(num, 3, bpmem.tevregs[num].ra.alpha);
|
2014-09-17 16:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-09-17 16:46:23 +00:00
|
|
|
case BPMEM_TEV_COLOR_BG:
|
|
|
|
case BPMEM_TEV_COLOR_BG + 2:
|
|
|
|
case BPMEM_TEV_COLOR_BG + 4:
|
|
|
|
case BPMEM_TEV_COLOR_BG + 6:
|
|
|
|
{
|
|
|
|
int num = (bp.address >> 1) & 0x3;
|
2021-02-11 02:11:31 +00:00
|
|
|
if (bpmem.tevregs[num].bg.type == TevRegType::Constant)
|
2014-09-17 16:46:23 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevKonstColor(num, 1, bpmem.tevregs[num].bg.green);
|
|
|
|
pixel_shader_manager.SetTevKonstColor(num, 2, bpmem.tevregs[num].bg.blue);
|
2014-09-17 16:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevColor(num, 1, bpmem.tevregs[num].bg.green);
|
|
|
|
pixel_shader_manager.SetTevColor(num, 2, bpmem.tevregs[num].bg.blue);
|
2014-09-17 16:46:23 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:23:47 +00:00
|
|
|
default:
|
2009-07-26 09:52:35 +00:00
|
|
|
break;
|
2014-05-20 15:23:47 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:23:47 +00:00
|
|
|
switch (bp.address & 0xFC) // Texture sampler filter
|
|
|
|
{
|
|
|
|
// -------------------------
|
|
|
|
// Texture Environment Order
|
|
|
|
// -------------------------
|
|
|
|
case BPMEM_TREF:
|
|
|
|
case BPMEM_TREF + 4:
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevOrder(bp.address - BPMEM_TREF, bp.newvalue);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
|
|
|
// ----------------------
|
|
|
|
// Set wrap size
|
|
|
|
// ----------------------
|
2016-09-03 02:42:02 +00:00
|
|
|
case BPMEM_SU_SSIZE: // Matches BPMEM_SU_TSIZE too
|
2014-05-20 15:23:47 +00:00
|
|
|
case BPMEM_SU_SSIZE + 4:
|
|
|
|
case BPMEM_SU_SSIZE + 8:
|
|
|
|
case BPMEM_SU_SSIZE + 12:
|
|
|
|
if (bp.changes)
|
2014-12-14 20:44:33 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
2022-12-29 14:27:48 +00:00
|
|
|
geometry_shader_manager.SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
2014-12-14 20:44:33 +00:00
|
|
|
}
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
2021-09-12 06:12:51 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-09-12 06:12:51 +00:00
|
|
|
if ((bp.address & 0xc0) == 0x80)
|
|
|
|
{
|
|
|
|
auto tex_address = TexUnitAddress::FromBPAddress(bp.address);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-09-12 06:12:51 +00:00
|
|
|
switch (tex_address.Reg)
|
|
|
|
{
|
|
|
|
// ------------------------
|
|
|
|
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS,
|
|
|
|
// DiagLoad, Min Filter, Mag Filter, Wrap T, S
|
|
|
|
// BPMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD
|
|
|
|
// ------------------------
|
|
|
|
case TexUnitAddress::Register::SETMODE0:
|
|
|
|
case TexUnitAddress::Register::SETMODE1:
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::ConfigurationChanged(tex_address, bp.newvalue);
|
2021-09-12 06:12:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
// BPMEM_TX_SETIMAGE0 - Texture width, height, format
|
|
|
|
// BPMEM_TX_SETIMAGE1 - even LOD address in TMEM - Image Type, Cache Height, Cache Width,
|
|
|
|
// TMEM Offset
|
|
|
|
// BPMEM_TX_SETIMAGE2 - odd LOD address in TMEM - Cache Height, Cache Width, TMEM Offset
|
|
|
|
// BPMEM_TX_SETIMAGE3 - Address of Texture in main memory
|
|
|
|
// --------------------------------------------
|
|
|
|
case TexUnitAddress::Register::SETIMAGE0:
|
|
|
|
case TexUnitAddress::Register::SETIMAGE1:
|
|
|
|
case TexUnitAddress::Register::SETIMAGE2:
|
|
|
|
case TexUnitAddress::Register::SETIMAGE3:
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::ConfigurationChanged(tex_address, bp.newvalue);
|
2021-09-12 06:12:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// -------------------------------
|
|
|
|
// Set a TLUT
|
|
|
|
// BPMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5)
|
|
|
|
// -------------------------------
|
|
|
|
case TexUnitAddress::Register::SETTLUT:
|
2019-09-06 09:22:47 +00:00
|
|
|
TMEM::ConfigurationChanged(tex_address, bp.newvalue);
|
2021-09-12 06:12:51 +00:00
|
|
|
return;
|
|
|
|
case TexUnitAddress::Register::UNKNOWN:
|
|
|
|
break; // Not handled
|
|
|
|
}
|
2009-06-22 09:31:30 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-20 15:23:47 +00:00
|
|
|
switch (bp.address & 0xF0)
|
|
|
|
{
|
|
|
|
// --------------
|
|
|
|
// Indirect Tev
|
|
|
|
// --------------
|
2017-07-20 05:25:24 +00:00
|
|
|
case BPMEM_IND_CMD:
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevIndirectChanged();
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
|
|
|
// --------------------------------------------------
|
|
|
|
// Set Color/Alpha of a Tev
|
|
|
|
// BPMEM_TEV_COLOR_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D
|
|
|
|
// BPMEM_TEV_ALPHA_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D, T Swap, R Swap
|
|
|
|
// --------------------------------------------------
|
2017-07-20 05:25:24 +00:00
|
|
|
case BPMEM_TEV_COLOR_ENV: // Texture Environment 1
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 16:
|
2022-12-27 16:42:02 +00:00
|
|
|
pixel_shader_manager.SetTevCombiner((bp.address - BPMEM_TEV_COLOR_ENV) >> 1,
|
|
|
|
(bp.address - BPMEM_TEV_COLOR_ENV) & 1, bp.newvalue);
|
2014-05-20 15:23:47 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-03-07 23:42:10 +00:00
|
|
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_BP_COMMAND);
|
2020-11-14 03:33:26 +00:00
|
|
|
WARN_LOG_FMT(VIDEO, "Unknown BP opcode: address = {:#010x} value = {:#010x}", bp.address,
|
|
|
|
bp.newvalue);
|
2009-07-22 22:50:52 +00:00
|
|
|
}
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2021-04-23 03:57:56 +00:00
|
|
|
// Call browser: OpcodeDecoding.cpp RunCallback::OnBP()
|
|
|
|
void LoadBPReg(u8 reg, u32 value, int cycles_into_future)
|
2014-05-03 20:36:29 +00:00
|
|
|
{
|
2022-12-27 16:42:02 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
|
2021-04-23 03:57:56 +00:00
|
|
|
int oldval = ((u32*)&bpmem)[reg];
|
|
|
|
int newval = (oldval & ~bpmem.bpMask) | (value & bpmem.bpMask);
|
2014-05-03 20:36:29 +00:00
|
|
|
int changes = (oldval ^ newval) & 0xFFFFFF;
|
|
|
|
|
2021-04-23 03:57:56 +00:00
|
|
|
BPCmd bp = {reg, changes, newval};
|
2014-05-03 20:36:29 +00:00
|
|
|
|
|
|
|
// Reset the mask register if we're not trying to set it ourselves.
|
2021-04-23 03:57:56 +00:00
|
|
|
if (reg != BPMEM_BP_MASK)
|
2014-05-03 20:36:29 +00:00
|
|
|
bpmem.bpMask = 0xFFFFFF;
|
|
|
|
|
2022-12-29 14:27:48 +00:00
|
|
|
BPWritten(system.GetPixelShaderManager(), system.GetVertexShaderManager(),
|
|
|
|
system.GetGeometryShaderManager(), bp, cycles_into_future);
|
2014-05-03 20:36:29 +00:00
|
|
|
}
|
|
|
|
|
2021-04-23 03:57:56 +00:00
|
|
|
void LoadBPRegPreprocess(u8 reg, u32 value, int cycles_into_future)
|
Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...
The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data. Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic. Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.
My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point). Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much. However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all. (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)
With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done). Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.
Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render. That makes up the bulk of this commit.
In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.
The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.
Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches. When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.
* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame. For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-08-28 02:56:19 +00:00
|
|
|
{
|
2022-12-10 16:10:14 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
|
2021-04-23 03:57:56 +00:00
|
|
|
// masking via BPMEM_BP_MASK could hypothetically be a problem
|
|
|
|
u32 newval = value & 0xffffff;
|
|
|
|
switch (reg)
|
Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...
The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data. Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic. Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.
My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point). Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much. However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all. (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)
With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done). Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.
Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render. That makes up the bulk of this commit.
In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.
The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.
Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches. When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.
* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame. For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-08-28 02:56:19 +00:00
|
|
|
{
|
|
|
|
case BPMEM_SETDRAWDONE:
|
|
|
|
if ((newval & 0xff) == 0x02)
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetFinish(system, cycles_into_future);
|
Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...
The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data. Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic. Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.
My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point). Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much. However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all. (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)
With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done). Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.
Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render. That makes up the bulk of this commit.
In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.
The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.
Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches. When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.
* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame. For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-08-28 02:56:19 +00:00
|
|
|
break;
|
|
|
|
case BPMEM_PE_TOKEN_ID:
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetToken(system, newval & 0xffff, false, cycles_into_future);
|
Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...
The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data. Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic. Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.
My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point). Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much. However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all. (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)
With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done). Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.
Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render. That makes up the bulk of this commit.
In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.
The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.
Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches. When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.
* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame. For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-08-28 02:56:19 +00:00
|
|
|
break;
|
|
|
|
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
|
2022-12-10 16:10:14 +00:00
|
|
|
system.GetPixelEngine().SetToken(system, newval & 0xffff, true, cycles_into_future);
|
Add the 'desynced GPU thread' mode.
It's a relatively big commit (less big with -w), but it's hard to test
any of this separately...
The basic problem is that in netplay or movies, the state of the CPU
must be deterministic, including when the game receives notification
that the GPU has processed FIFO data. Dual core mode notifies the game
whenever the GPU thread actually gets around to doing the work, so it
isn't deterministic. Single core mode is because it notifies the game
'instantly' (after processing the data synchronously), but it's too slow
for many systems and games.
My old dc-netplay branch worked as follows: everything worked as normal
except the state of the CP registers was a lie, and the CPU thread only
delivered results when idle detection triggered (waiting for the GPU if
they weren't ready at that point). Usually, a game is idle iff all the
work for the frame has been done, except for a small amount of work
depending on the GPU result, so neither the CPU or the GPU waiting on
the other affected performance much. However, it's possible that the
game could be waiting for some earlier interrupt, and any of several
games which, for whatever reason, never went into a detectable idle
(even when I tried to improve the detection) would never receive results
at all. (The current method should have better compatibility, but it
also has slightly higher overhead and breaks some other things, so I
want to reimplement this, hopefully with less impact on the code, in the
future.)
With this commit, the basic idea is that the CPU thread acts as if the
work has been done instantly, like single core mode, but actually hands
it off asynchronously to the GPU thread (after backing up some data that
the game might change in memory before it's actually done). Since the
work isn't done, any feedback from the GPU to the CPU, such as real
XFB/EFB copies (virtual are OK), EFB pokes, performance queries, etc. is
broken; but most games work with these options disabled, and there is no
need to try to detect what the CPU thread is doing.
Technically: when the flag g_use_deterministic_gpu_thread (currently
stuck on) is on, the CPU thread calls RunGpu like in single core mode.
This function synchronously copies the data from the FIFO to the
internal video buffer and updates the CP registers, interrupts, etc.
However, instead of the regular ReadDataFromFifo followed by running the
opcode decoder, it runs ReadDataFromFifoOnCPU ->
OpcodeDecoder_Preprocess, which relatively quickly scans through the
FIFO data, detects SetFinish calls etc., which are immediately fired,
and saves certain associated data from memory (e.g. display lists) in
AuxBuffers (a parallel stream to the main FIFO, which is a bit slow at
the moment), before handing the data off to the GPU thread to actually
render. That makes up the bulk of this commit.
In various circumstances, including the aforementioned EFB pokes and
performance queries as well as swap requests (i.e. the end of a frame -
we don't want the CPU potentially pumping out frames too quickly and the
GPU falling behind*), SyncGPU is called to wait for actual completion.
The overhead mainly comes from OpcodeDecoder_Preprocess (which is,
again, synchronous), as well as the actual copying.
Currently, display lists and such are escrowed from main memory even
though they usually won't change over the course of a frame, and
textures are not even though they might, resulting in a small chance of
graphical glitches. When the texture locking (i.e. fault on write) code
lands, I can make this all correct and maybe a little faster.
* This suggests an alternate determinism method of just delaying results
until a short time before the end of each frame. For all I know this
might mostly work - I haven't tried it - but if any significant work
hinges on the competion of render to texture etc., the frame will be
missed.
2014-08-28 02:56:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-07 23:25:11 +00:00
|
|
|
std::pair<std::string, std::string> GetBPRegInfo(u8 cmd, u32 cmddata)
|
2014-05-03 20:36:29 +00:00
|
|
|
{
|
2021-02-07 23:25:11 +00:00
|
|
|
// Macro to set the register name and make sure it was written correctly via compile time assertion
|
|
|
|
#define RegName(reg) ((void)(reg), #reg)
|
|
|
|
#define DescriptionlessReg(reg) std::make_pair(RegName(reg), "");
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-11-03 09:41:38 +00:00
|
|
|
switch (cmd)
|
2014-05-03 20:36:29 +00:00
|
|
|
{
|
|
|
|
case BPMEM_GENMODE: // 0x00
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_GENMODE), fmt::to_string(GenMode{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_DISPLAYCOPYFILTER: // 0x01
|
2021-02-07 23:25:11 +00:00
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 1:
|
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 2:
|
|
|
|
case BPMEM_DISPLAYCOPYFILTER + 3:
|
2014-05-03 20:36:29 +00:00
|
|
|
// TODO: This is actually the sample pattern used for copies from an antialiased EFB
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_DISPLAYCOPYFILTER);
|
2014-05-03 20:36:29 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_IND_MTXA: // 0x06
|
2021-02-07 23:25:11 +00:00
|
|
|
case BPMEM_IND_MTXA + 3:
|
|
|
|
case BPMEM_IND_MTXA + 6:
|
2021-07-05 19:55:32 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_IND_MTXA Matrix {}", (cmd - BPMEM_IND_MTXA) / 3),
|
|
|
|
fmt::format("Matrix {} column A\n{}", (cmd - BPMEM_IND_MTXA) / 3,
|
|
|
|
IND_MTXA{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_IND_MTXB: // 0x07
|
|
|
|
case BPMEM_IND_MTXB + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
case BPMEM_IND_MTXB + 6:
|
2021-07-05 19:55:32 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_IND_MTXB Matrix {}", (cmd - BPMEM_IND_MTXB) / 3),
|
|
|
|
fmt::format("Matrix {} column B\n{}", (cmd - BPMEM_IND_MTXB) / 3,
|
|
|
|
IND_MTXB{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_IND_MTXC: // 0x08
|
|
|
|
case BPMEM_IND_MTXC + 3:
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_IND_MTXC + 6:
|
2021-07-05 19:55:32 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_IND_MTXC Matrix {}", (cmd - BPMEM_IND_MTXC) / 3),
|
|
|
|
fmt::format("Matrix {} column C\n{}", (cmd - BPMEM_IND_MTXC) / 3,
|
|
|
|
IND_MTXC{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_IND_IMASK: // 0x0F
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_IND_IMASK);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_IND_CMD: // 0x10
|
|
|
|
case BPMEM_IND_CMD + 1:
|
|
|
|
case BPMEM_IND_CMD + 2:
|
|
|
|
case BPMEM_IND_CMD + 3:
|
|
|
|
case BPMEM_IND_CMD + 4:
|
|
|
|
case BPMEM_IND_CMD + 5:
|
|
|
|
case BPMEM_IND_CMD + 6:
|
|
|
|
case BPMEM_IND_CMD + 7:
|
|
|
|
case BPMEM_IND_CMD + 8:
|
|
|
|
case BPMEM_IND_CMD + 9:
|
|
|
|
case BPMEM_IND_CMD + 10:
|
|
|
|
case BPMEM_IND_CMD + 11:
|
|
|
|
case BPMEM_IND_CMD + 12:
|
|
|
|
case BPMEM_IND_CMD + 13:
|
|
|
|
case BPMEM_IND_CMD + 14:
|
|
|
|
case BPMEM_IND_CMD + 15:
|
2021-12-27 04:52:07 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_IND_CMD number {}", cmd - BPMEM_IND_CMD),
|
2021-02-07 23:25:11 +00:00
|
|
|
fmt::to_string(TevStageIndirect{.fullhex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SCISSORTL: // 0x20
|
2021-11-28 01:07:02 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_SCISSORTL), fmt::to_string(ScissorPos{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SCISSORBR: // 0x21
|
2021-11-28 01:07:02 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_SCISSORBR), fmt::to_string(ScissorPos{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_LINEPTWIDTH: // 0x22
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_LINEPTWIDTH), fmt::to_string(LPSize{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PERF0_TRI: // 0x23
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_PERF0_TRI);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PERF0_QUAD: // 0x24
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_PERF0_QUAD);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_RAS1_SS0: // 0x25
|
2021-12-27 04:52:07 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_RAS1_SS0),
|
|
|
|
fmt::to_string(std::make_pair(cmd, TEXSCALE{.hex = cmddata})));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_RAS1_SS1: // 0x26
|
2021-12-27 04:52:07 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_RAS1_SS1),
|
|
|
|
fmt::to_string(std::make_pair(cmd, TEXSCALE{.hex = cmddata})));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_IREF: // 0x27
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_IREF), fmt::to_string(RAS1_IREF{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TREF: // 0x28
|
|
|
|
case BPMEM_TREF + 1:
|
|
|
|
case BPMEM_TREF + 2:
|
|
|
|
case BPMEM_TREF + 3:
|
|
|
|
case BPMEM_TREF + 4:
|
|
|
|
case BPMEM_TREF + 5:
|
|
|
|
case BPMEM_TREF + 6:
|
|
|
|
case BPMEM_TREF + 7:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_TREF number {}", cmd - BPMEM_TREF),
|
2021-12-27 04:52:07 +00:00
|
|
|
fmt::to_string(std::make_pair(cmd, TwoTevStageOrders{.hex = cmddata})));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SU_SSIZE: // 0x30
|
|
|
|
case BPMEM_SU_SSIZE + 2:
|
|
|
|
case BPMEM_SU_SSIZE + 4:
|
|
|
|
case BPMEM_SU_SSIZE + 6:
|
|
|
|
case BPMEM_SU_SSIZE + 8:
|
|
|
|
case BPMEM_SU_SSIZE + 10:
|
|
|
|
case BPMEM_SU_SSIZE + 12:
|
|
|
|
case BPMEM_SU_SSIZE + 14:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_SU_SSIZE number {}", (cmd - BPMEM_SU_SSIZE) / 2),
|
2021-12-27 04:52:07 +00:00
|
|
|
fmt::to_string(std::make_pair(true, TCInfo{.hex = cmddata})));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SU_TSIZE: // 0x31
|
|
|
|
case BPMEM_SU_TSIZE + 2:
|
|
|
|
case BPMEM_SU_TSIZE + 4:
|
|
|
|
case BPMEM_SU_TSIZE + 6:
|
|
|
|
case BPMEM_SU_TSIZE + 8:
|
|
|
|
case BPMEM_SU_TSIZE + 10:
|
|
|
|
case BPMEM_SU_TSIZE + 12:
|
|
|
|
case BPMEM_SU_TSIZE + 14:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_SU_TSIZE number {}", (cmd - BPMEM_SU_TSIZE) / 2),
|
2021-12-27 04:52:07 +00:00
|
|
|
fmt::to_string(std::make_pair(false, TCInfo{.hex = cmddata})));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_ZMODE: // 0x40
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_ZMODE), fmt::format("Z mode: {}", ZMode{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_BLENDMODE: // 0x41
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_BLENDMODE), fmt::to_string(BlendMode{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_CONSTANTALPHA: // 0x42
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CONSTANTALPHA),
|
|
|
|
fmt::to_string(ConstantAlpha{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_ZCOMPARE: // 0x43
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_ZCOMPARE), fmt::to_string(PEControl{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FIELDMASK: // 0x44
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FIELDMASK), fmt::to_string(FieldMask{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SETDRAWDONE: // 0x45
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_SETDRAWDONE);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_BUSCLOCK0: // 0x46
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_BUSCLOCK0);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PE_TOKEN_ID: // 0x47
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_PE_TOKEN_ID);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PE_TOKEN_INT_ID: // 0x48
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_PE_TOKEN_INT_ID);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_EFB_TL: // 0x49
|
|
|
|
{
|
2021-02-07 23:25:11 +00:00
|
|
|
const X10Y10 left_top{.hex = cmddata};
|
|
|
|
return std::make_pair(RegName(BPMEM_EFB_TL),
|
|
|
|
fmt::format("EFB Left: {}\nEFB Top: {}", left_top.x, left_top.y));
|
2014-06-02 05:51:52 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2021-02-07 20:32:45 +00:00
|
|
|
case BPMEM_EFB_WH: // 0x4A
|
2014-05-03 20:36:29 +00:00
|
|
|
{
|
2021-02-07 23:25:11 +00:00
|
|
|
const X10Y10 width_height{.hex = cmddata};
|
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_EFB_WH),
|
|
|
|
fmt::format("EFB Width: {}\nEFB Height: {}", width_height.x + 1, width_height.y + 1));
|
2014-05-03 20:36:29 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_EFB_ADDR: // 0x4B
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_EFB_ADDR),
|
|
|
|
fmt::format("EFB Target address (32 byte aligned): 0x{:06X}", cmddata << 5));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2023-10-30 00:54:51 +00:00
|
|
|
case BPMEM_EFB_STRIDE: // 0x4D
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_EFB_STRIDE),
|
|
|
|
fmt::format("EFB destination stride (32 byte aligned): 0x{:06X}", cmddata << 5));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_COPYYSCALE: // 0x4E
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_COPYYSCALE),
|
|
|
|
fmt::format("Y scaling factor (XFB copy only): 0x{:X} ({}, reciprocal {})", cmddata,
|
|
|
|
static_cast<float>(cmddata) / 256.f, 256.f / static_cast<float>(cmddata)));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_CLEAR_AR: // 0x4F
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CLEAR_AR),
|
|
|
|
fmt::format("Clear color alpha: 0x{:02X}\nClear color red: 0x{:02X}",
|
|
|
|
(cmddata & 0xFF00) >> 8, cmddata & 0xFF));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_CLEAR_GB: // 0x50
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CLEAR_GB),
|
|
|
|
fmt::format("Clear color green: 0x{:02X}\nClear color blue: 0x{:02X}",
|
|
|
|
(cmddata & 0xFF00) >> 8, cmddata & 0xFF));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_CLEAR_Z: // 0x51
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CLEAR_Z), fmt::format("Clear Z value: 0x{:06X}", cmddata));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_TRIGGER_EFB_COPY: // 0x52
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_TRIGGER_EFB_COPY),
|
|
|
|
fmt::to_string(UPE_Copy{.Hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_COPYFILTER0: // 0x53
|
2021-02-07 23:25:11 +00:00
|
|
|
{
|
|
|
|
const u32 w0 = (cmddata & 0x00003f);
|
|
|
|
const u32 w1 = (cmddata & 0x000fc0) >> 6;
|
|
|
|
const u32 w2 = (cmddata & 0x03f000) >> 12;
|
|
|
|
const u32 w3 = (cmddata & 0xfc0000) >> 18;
|
|
|
|
return std::make_pair(RegName(BPMEM_COPYFILTER0),
|
|
|
|
fmt::format("w0: {}\nw1: {}\nw2: {}\nw3: {}", w0, w1, w2, w3));
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_COPYFILTER1: // 0x54
|
2021-02-07 23:25:11 +00:00
|
|
|
{
|
|
|
|
const u32 w4 = (cmddata & 0x00003f);
|
|
|
|
const u32 w5 = (cmddata & 0x000fc0) >> 6;
|
|
|
|
const u32 w6 = (cmddata & 0x03f000) >> 12;
|
|
|
|
// There is no w7
|
|
|
|
return std::make_pair(RegName(BPMEM_COPYFILTER1),
|
|
|
|
fmt::format("w4: {}\nw5: {}\nw6: {}", w4, w5, w6));
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_CLEARBBOX1: // 0x55
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CLEARBBOX1),
|
|
|
|
fmt::format("Bounding Box index 0: {}\nBounding Box index 1: {}",
|
|
|
|
cmddata & 0x3ff, (cmddata >> 10) & 0x3ff));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_CLEARBBOX2: // 0x56
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_CLEARBBOX2),
|
|
|
|
fmt::format("Bounding Box index 2: {}\nBounding Box index 3: {}",
|
|
|
|
cmddata & 0x3ff, (cmddata >> 10) & 0x3ff));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_CLEAR_PIXEL_PERF: // 0x57
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_CLEAR_PIXEL_PERF);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_REVBITS: // 0x58
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_REVBITS);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_SCISSOROFFSET: // 0x59
|
2021-04-19 12:20:37 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_SCISSOROFFSET),
|
2021-11-28 01:07:02 +00:00
|
|
|
fmt::to_string(ScissorOffset{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PRELOAD_ADDR: // 0x60
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_PRELOAD_ADDR),
|
|
|
|
fmt::format("Tmem preload address (32 byte aligned, in main memory): 0x{:06x}",
|
|
|
|
cmddata << 5));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PRELOAD_TMEMEVEN: // 0x61
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_PRELOAD_TMEMEVEN),
|
|
|
|
fmt::format("Tmem preload even line: 0x{:04x} (byte 0x{:05x})", cmddata,
|
|
|
|
cmddata * TMEM_LINE_SIZE));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PRELOAD_TMEMODD: // 0x62
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_PRELOAD_TMEMODD),
|
|
|
|
fmt::format("Tmem preload odd line: 0x{:04x} (byte 0x{:05x})", cmddata,
|
|
|
|
cmddata * TMEM_LINE_SIZE));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PRELOAD_MODE: // 0x63
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_PRELOAD_MODE),
|
|
|
|
fmt::to_string(BPU_PreloadTileInfo{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_LOADTLUT0: // 0x64
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(
|
|
|
|
RegName(BPMEM_LOADTLUT0),
|
|
|
|
fmt::format("TLUT load address (32 byte aligned, in main memory): 0x{:06x}", cmddata << 5));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_LOADTLUT1: // 0x65
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_LOADTLUT1),
|
|
|
|
fmt::to_string(BPU_LoadTlutInfo{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TEXINVALIDATE: // 0x66
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_TEXINVALIDATE);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_PERF1: // 0x67
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_PERF1);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FIELDMODE: // 0x68
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FIELDMODE), fmt::to_string(FieldMode{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_BUSCLOCK1: // 0x69
|
2021-02-07 23:25:11 +00:00
|
|
|
return DescriptionlessReg(BPMEM_BUSCLOCK1);
|
2014-06-02 05:51:52 +00:00
|
|
|
// TODO: Description
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETMODE0: // 0x80
|
|
|
|
case BPMEM_TX_SETMODE0 + 1:
|
|
|
|
case BPMEM_TX_SETMODE0 + 2:
|
|
|
|
case BPMEM_TX_SETMODE0 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_TX_SETMODE0 Texture Unit {}", cmd - BPMEM_TX_SETMODE0),
|
|
|
|
fmt::to_string(TexMode0{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETMODE1: // 0x84
|
|
|
|
case BPMEM_TX_SETMODE1 + 1:
|
|
|
|
case BPMEM_TX_SETMODE1 + 2:
|
|
|
|
case BPMEM_TX_SETMODE1 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_TX_SETMODE1 Texture Unit {}", cmd - BPMEM_TX_SETMODE1),
|
|
|
|
fmt::to_string(TexMode1{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETIMAGE0: // 0x88
|
|
|
|
case BPMEM_TX_SETIMAGE0 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE0 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE0 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE0 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE0),
|
|
|
|
fmt::to_string(TexImage0{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETIMAGE1: // 0x8C
|
|
|
|
case BPMEM_TX_SETIMAGE1 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE1 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE1 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE1 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE1),
|
|
|
|
fmt::to_string(TexImage1{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETIMAGE2: // 0x90
|
|
|
|
case BPMEM_TX_SETIMAGE2 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE2 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE2 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE2 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE2),
|
|
|
|
fmt::to_string(TexImage2{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_TX_SETIMAGE3: // 0x94
|
|
|
|
case BPMEM_TX_SETIMAGE3 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE3 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE3 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE3 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE3),
|
|
|
|
fmt::to_string(TexImage3{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TX_SETTLUT: // 0x98
|
|
|
|
case BPMEM_TX_SETTLUT + 1:
|
|
|
|
case BPMEM_TX_SETTLUT + 2:
|
|
|
|
case BPMEM_TX_SETTLUT + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_TX_SETTLUT Texture Unit {}", cmd - BPMEM_TX_SETTLUT),
|
|
|
|
fmt::to_string(TexTLUT{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETMODE0_4: // 0xA0
|
|
|
|
case BPMEM_TX_SETMODE0_4 + 1:
|
|
|
|
case BPMEM_TX_SETMODE0_4 + 2:
|
|
|
|
case BPMEM_TX_SETMODE0_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETMODE0_4 Texture Unit {}", cmd - BPMEM_TX_SETMODE0_4 + 4),
|
|
|
|
fmt::to_string(TexMode0{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETMODE1_4: // 0xA4
|
|
|
|
case BPMEM_TX_SETMODE1_4 + 1:
|
|
|
|
case BPMEM_TX_SETMODE1_4 + 2:
|
|
|
|
case BPMEM_TX_SETMODE1_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETMODE1_4 Texture Unit {}", cmd - BPMEM_TX_SETMODE1_4 + 4),
|
|
|
|
fmt::to_string(TexMode1{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETIMAGE0_4: // 0xA8
|
|
|
|
case BPMEM_TX_SETIMAGE0_4 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE0_4 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE0_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE0_4 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE0_4 + 4),
|
|
|
|
fmt::to_string(TexImage0{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETIMAGE1_4: // 0xAC
|
|
|
|
case BPMEM_TX_SETIMAGE1_4 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE1_4 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE1_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE1_4 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE1_4 + 4),
|
|
|
|
fmt::to_string(TexImage1{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETIMAGE2_4: // 0xB0
|
|
|
|
case BPMEM_TX_SETIMAGE2_4 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE2_4 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE2_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE2_4 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE2_4 + 4),
|
|
|
|
fmt::to_string(TexImage2{.hex = cmddata}));
|
|
|
|
|
|
|
|
case BPMEM_TX_SETIMAGE3_4: // 0xB4
|
|
|
|
case BPMEM_TX_SETIMAGE3_4 + 1:
|
|
|
|
case BPMEM_TX_SETIMAGE3_4 + 2:
|
|
|
|
case BPMEM_TX_SETIMAGE3_4 + 3:
|
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETIMAGE3_4 Texture Unit {}", cmd - BPMEM_TX_SETIMAGE3_4 + 4),
|
|
|
|
fmt::to_string(TexImage3{.hex = cmddata}));
|
|
|
|
|
2014-06-02 06:26:24 +00:00
|
|
|
case BPMEM_TX_SETTLUT_4: // 0xB8
|
|
|
|
case BPMEM_TX_SETTLUT_4 + 1:
|
|
|
|
case BPMEM_TX_SETTLUT_4 + 2:
|
|
|
|
case BPMEM_TX_SETTLUT_4 + 3:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TX_SETTLUT_4 Texture Unit {}", cmd - BPMEM_TX_SETTLUT_4 + 4),
|
|
|
|
fmt::to_string(TexTLUT{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_TEV_COLOR_ENV: // 0xC0
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 2:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 4:
|
2021-02-07 23:25:11 +00:00
|
|
|
case BPMEM_TEV_COLOR_ENV + 6:
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_TEV_COLOR_ENV + 8:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 10:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 12:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 14:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 16:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 18:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 20:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 22:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 24:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 26:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 28:
|
|
|
|
case BPMEM_TEV_COLOR_ENV + 30:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TEV_COLOR_ENV Tev stage {}", (cmd - BPMEM_TEV_COLOR_ENV) / 2),
|
|
|
|
fmt::to_string(TevStageCombiner::ColorCombiner{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-05-03 20:36:29 +00:00
|
|
|
case BPMEM_TEV_ALPHA_ENV: // 0xC1
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 2:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 4:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 6:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 8:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 10:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 12:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 14:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 16:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 18:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 20:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 22:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 24:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 26:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 28:
|
|
|
|
case BPMEM_TEV_ALPHA_ENV + 30:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TEV_ALPHA_ENV Tev stage {}", (cmd - BPMEM_TEV_ALPHA_ENV) / 2),
|
|
|
|
fmt::to_string(TevStageCombiner::AlphaCombiner{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-09-17 16:46:23 +00:00
|
|
|
case BPMEM_TEV_COLOR_RA: // 0xE0
|
|
|
|
case BPMEM_TEV_COLOR_RA + 2: // 0xE2
|
|
|
|
case BPMEM_TEV_COLOR_RA + 4: // 0xE4
|
|
|
|
case BPMEM_TEV_COLOR_RA + 6: // 0xE6
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TEV_COLOR_RA Tev register {}", (cmd - BPMEM_TEV_COLOR_RA) / 2),
|
|
|
|
fmt::to_string(TevReg::RA{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-09-17 16:46:23 +00:00
|
|
|
case BPMEM_TEV_COLOR_BG: // 0xE1
|
|
|
|
case BPMEM_TEV_COLOR_BG + 2: // 0xE3
|
|
|
|
case BPMEM_TEV_COLOR_BG + 4: // 0xE5
|
|
|
|
case BPMEM_TEV_COLOR_BG + 6: // 0xE7
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(
|
|
|
|
fmt::format("BPMEM_TEV_COLOR_BG Tev register {}", (cmd - BPMEM_TEV_COLOR_BG) / 2),
|
|
|
|
fmt::to_string(TevReg::BG{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGRANGE: // 0xE8
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair("BPMEM_FOGRANGE Base",
|
|
|
|
fmt::to_string(FogRangeParams::RangeBase{.hex = cmddata}));
|
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGRANGE + 1:
|
|
|
|
case BPMEM_FOGRANGE + 2:
|
|
|
|
case BPMEM_FOGRANGE + 3:
|
|
|
|
case BPMEM_FOGRANGE + 4:
|
|
|
|
case BPMEM_FOGRANGE + 5:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_FOGRANGE K element {}", cmd - BPMEM_FOGRANGE),
|
|
|
|
fmt::to_string(FogRangeKElement{.HEX = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGPARAM0: // 0xEE
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FOGPARAM0), fmt::to_string(FogParam0{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGBMAGNITUDE: // 0xEF
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FOGBMAGNITUDE), fmt::format("B magnitude: {}", cmddata));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGBEXPONENT: // 0xF0
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FOGBEXPONENT),
|
|
|
|
fmt::format("B shift: 1>>{} (1/{})", cmddata, 1 << cmddata));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGPARAM3: // 0xF1
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FOGPARAM3), fmt::to_string(FogParam3{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_FOGCOLOR: // 0xF2
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_FOGCOLOR),
|
|
|
|
fmt::to_string(FogParams::FogColor{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_ALPHACOMPARE: // 0xF3
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_ALPHACOMPARE), fmt::to_string(AlphaTest{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_BIAS: // 0xF4
|
2023-11-12 00:49:05 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_BIAS), fmt::to_string(ZTex1{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_ZTEX2: // 0xF5
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(RegName(BPMEM_ZTEX2), fmt::to_string(ZTex2{.hex = cmddata}));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2014-06-02 05:51:52 +00:00
|
|
|
case BPMEM_TEV_KSEL: // 0xF6
|
|
|
|
case BPMEM_TEV_KSEL + 1:
|
|
|
|
case BPMEM_TEV_KSEL + 2:
|
|
|
|
case BPMEM_TEV_KSEL + 3:
|
|
|
|
case BPMEM_TEV_KSEL + 4:
|
|
|
|
case BPMEM_TEV_KSEL + 5:
|
|
|
|
case BPMEM_TEV_KSEL + 6:
|
|
|
|
case BPMEM_TEV_KSEL + 7:
|
2021-02-07 23:25:11 +00:00
|
|
|
return std::make_pair(fmt::format("BPMEM_TEV_KSEL number {}", cmd - BPMEM_TEV_KSEL),
|
2021-12-27 04:52:07 +00:00
|
|
|
fmt::to_string(std::make_pair(cmd, TevKSel{.hex = cmddata})));
|
2021-02-07 23:25:11 +00:00
|
|
|
|
|
|
|
case BPMEM_BP_MASK: // 0xFE
|
|
|
|
return std::make_pair(RegName(BPMEM_BP_MASK),
|
|
|
|
fmt::format("The next BP command will only update these bits; others "
|
|
|
|
"will retain their prior values: {:06x}",
|
|
|
|
cmddata));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return std::make_pair(fmt::format("Unknown BP Reg: {:02x}={:06x}", cmd, cmddata), "");
|
2014-05-03 20:36:29 +00:00
|
|
|
|
2021-02-07 23:25:11 +00:00
|
|
|
#undef DescriptionlessReg
|
|
|
|
#undef RegName
|
2014-05-03 20:36:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-01 20:46:02 +00:00
|
|
|
// Called when loading a saved state.
|
|
|
|
void BPReload()
|
|
|
|
{
|
2012-12-23 12:32:23 +00:00
|
|
|
// 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();
|
2021-11-12 19:48:26 +00:00
|
|
|
SetScissorAndViewport();
|
2012-12-23 12:32:23 +00:00
|
|
|
SetDepthMode();
|
|
|
|
SetBlendMode();
|
|
|
|
OnPixelFormatChange();
|
2012-01-01 20:46:02 +00:00
|
|
|
}
|