Remove DataReader from LoadXFReg
This commit is contained in:
parent
b5fd35f951
commit
d84d695fdf
|
@ -86,8 +86,8 @@ void FifoRecorder::FifoRecordAnalyzer::OnPrimitiveCommand(OpcodeDecoder::Primiti
|
||||||
}
|
}
|
||||||
const u32 pos_size = VertexLoader_Position::GetSize(vtx_desc.low.Position, vtx_attr.g0.PosFormat,
|
const u32 pos_size = VertexLoader_Position::GetSize(vtx_desc.low.Position, vtx_attr.g0.PosFormat,
|
||||||
vtx_attr.g0.PosElements);
|
vtx_attr.g0.PosElements);
|
||||||
ProcessVertexComponent(CPArray::Position, vtx_desc.low.Position, offset, vertex_size, num_vertices,
|
ProcessVertexComponent(CPArray::Position, vtx_desc.low.Position, offset, vertex_size,
|
||||||
vertex_data);
|
num_vertices, vertex_data);
|
||||||
offset += pos_size;
|
offset += pos_size;
|
||||||
|
|
||||||
const u32 norm_size =
|
const u32 norm_size =
|
||||||
|
|
|
@ -50,9 +50,7 @@ public:
|
||||||
|
|
||||||
if constexpr (!is_preprocess)
|
if constexpr (!is_preprocess)
|
||||||
{
|
{
|
||||||
// HACK
|
LoadXFReg(address, count, data);
|
||||||
LoadXFReg(count, address,
|
|
||||||
DataReader{const_cast<u8*>(data), const_cast<u8*>(data) + count * sizeof(u32)});
|
|
||||||
|
|
||||||
INCSTAT(g_stats.this_frame.num_xf_loads);
|
INCSTAT(g_stats.this_frame.num_xf_loads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include "Common/EnumFormatter.h"
|
#include "Common/EnumFormatter.h"
|
||||||
#include "VideoCommon/CPMemory.h"
|
#include "VideoCommon/CPMemory.h"
|
||||||
|
|
||||||
class DataReader;
|
|
||||||
|
|
||||||
constexpr size_t NUM_XF_COLOR_CHANNELS = 2;
|
constexpr size_t NUM_XF_COLOR_CHANNELS = 2;
|
||||||
|
|
||||||
// Lighting
|
// Lighting
|
||||||
|
@ -458,6 +456,6 @@ static_assert(sizeof(XFMemory) == sizeof(u32) * XFMEM_REGISTERS_END);
|
||||||
|
|
||||||
extern XFMemory xfmem;
|
extern XFMemory xfmem;
|
||||||
|
|
||||||
void LoadXFReg(u32 transferSize, u32 address, DataReader src);
|
void LoadXFReg(u16 base_address, u8 transfer_size, const u8* data);
|
||||||
void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|
void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|
||||||
void PreprocessIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|
void PreprocessIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
|
|
||||||
#include "VideoCommon/CPMemory.h"
|
#include "VideoCommon/CPMemory.h"
|
||||||
#include "VideoCommon/DataReader.h"
|
|
||||||
#include "VideoCommon/Fifo.h"
|
#include "VideoCommon/Fifo.h"
|
||||||
#include "VideoCommon/GeometryShaderManager.h"
|
#include "VideoCommon/GeometryShaderManager.h"
|
||||||
#include "VideoCommon/PixelShaderManager.h"
|
#include "VideoCommon/PixelShaderManager.h"
|
||||||
|
@ -26,16 +25,10 @@ static void XFMemWritten(u32 transferSize, u32 baseAddress)
|
||||||
VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize);
|
VertexShaderManager::InvalidateXFRange(baseAddress, baseAddress + transferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
static void XFRegWritten(u32 address, u32 value)
|
||||||
{
|
{
|
||||||
u32 address = baseAddress;
|
if (address >= XFMEM_REGISTERS_START && address < XFMEM_REGISTERS_END)
|
||||||
u32 dataIndex = 0;
|
|
||||||
|
|
||||||
while (transferSize > 0 && address < XFMEM_REGISTERS_END)
|
|
||||||
{
|
{
|
||||||
u32 newValue = src.Peek<u32>(dataIndex * sizeof(u32));
|
|
||||||
u32 nextAddress = address + 1;
|
|
||||||
|
|
||||||
switch (address)
|
switch (address)
|
||||||
{
|
{
|
||||||
case XFMEM_ERROR:
|
case XFMEM_ERROR:
|
||||||
|
@ -44,12 +37,12 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_STATE1: // internal state 1
|
case XFMEM_STATE1: // internal state 1
|
||||||
case XFMEM_CLOCK:
|
case XFMEM_CLOCK:
|
||||||
case XFMEM_SETGPMETRIC:
|
case XFMEM_SETGPMETRIC:
|
||||||
nextAddress = 0x1007;
|
// Not implemented
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_CLIPDISABLE:
|
case XFMEM_CLIPDISABLE:
|
||||||
{
|
{
|
||||||
ClipDisable setting{.hex = newValue};
|
ClipDisable setting{.hex = value};
|
||||||
if (setting.disable_clipping_detection)
|
if (setting.disable_clipping_detection)
|
||||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::SETS_XF_CLIPDISABLE_BIT_0);
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::SETS_XF_CLIPDISABLE_BIT_0);
|
||||||
if (setting.disable_trivial_rejection)
|
if (setting.disable_trivial_rejection)
|
||||||
|
@ -63,7 +56,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETNUMCHAN:
|
case XFMEM_SETNUMCHAN:
|
||||||
if (xfmem.numChan.numColorChans != (newValue & 3))
|
if (xfmem.numChan.numColorChans != (value & 3))
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetLightingConfigChanged();
|
VertexShaderManager::SetLightingConfigChanged();
|
||||||
break;
|
break;
|
||||||
|
@ -72,7 +65,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_SETCHAN1_AMBCOLOR:
|
case XFMEM_SETCHAN1_AMBCOLOR:
|
||||||
{
|
{
|
||||||
u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR;
|
u8 chan = address - XFMEM_SETCHAN0_AMBCOLOR;
|
||||||
if (xfmem.ambColor[chan] != newValue)
|
if (xfmem.ambColor[chan] != value)
|
||||||
{
|
{
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetMaterialColorChanged(chan);
|
VertexShaderManager::SetMaterialColorChanged(chan);
|
||||||
|
@ -84,7 +77,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_SETCHAN1_MATCOLOR:
|
case XFMEM_SETCHAN1_MATCOLOR:
|
||||||
{
|
{
|
||||||
u8 chan = address - XFMEM_SETCHAN0_MATCOLOR;
|
u8 chan = address - XFMEM_SETCHAN0_MATCOLOR;
|
||||||
if (xfmem.matColor[chan] != newValue)
|
if (xfmem.matColor[chan] != value)
|
||||||
{
|
{
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetMaterialColorChanged(chan + 2);
|
VertexShaderManager::SetMaterialColorChanged(chan + 2);
|
||||||
|
@ -96,22 +89,22 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_SETCHAN1_COLOR:
|
case XFMEM_SETCHAN1_COLOR:
|
||||||
case XFMEM_SETCHAN0_ALPHA: // Channel Alpha
|
case XFMEM_SETCHAN0_ALPHA: // Channel Alpha
|
||||||
case XFMEM_SETCHAN1_ALPHA:
|
case XFMEM_SETCHAN1_ALPHA:
|
||||||
if (((u32*)&xfmem)[address] != (newValue & 0x7fff))
|
if (((u32*)&xfmem)[address] != (value & 0x7fff))
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetLightingConfigChanged();
|
VertexShaderManager::SetLightingConfigChanged();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_DUALTEX:
|
case XFMEM_DUALTEX:
|
||||||
if (xfmem.dualTexTrans.enabled != bool(newValue & 1))
|
if (xfmem.dualTexTrans.enabled != bool(value & 1))
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetTexMatrixInfoChanged(-1);
|
VertexShaderManager::SetTexMatrixInfoChanged(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETMATRIXINDA:
|
case XFMEM_SETMATRIXINDA:
|
||||||
VertexShaderManager::SetTexMatrixChangedA(newValue);
|
VertexShaderManager::SetTexMatrixChangedA(value);
|
||||||
break;
|
break;
|
||||||
case XFMEM_SETMATRIXINDB:
|
case XFMEM_SETMATRIXINDB:
|
||||||
VertexShaderManager::SetTexMatrixChangedB(newValue);
|
VertexShaderManager::SetTexMatrixChangedB(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETVIEWPORT:
|
case XFMEM_SETVIEWPORT:
|
||||||
|
@ -124,8 +117,6 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
VertexShaderManager::SetViewportChanged();
|
VertexShaderManager::SetViewportChanged();
|
||||||
PixelShaderManager::SetViewportChanged();
|
PixelShaderManager::SetViewportChanged();
|
||||||
GeometryShaderManager::SetViewportChanged();
|
GeometryShaderManager::SetViewportChanged();
|
||||||
|
|
||||||
nextAddress = XFMEM_SETVIEWPORT + 6;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETPROJECTION:
|
case XFMEM_SETPROJECTION:
|
||||||
|
@ -138,12 +129,10 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetProjectionChanged();
|
VertexShaderManager::SetProjectionChanged();
|
||||||
GeometryShaderManager::SetProjectionChanged();
|
GeometryShaderManager::SetProjectionChanged();
|
||||||
|
|
||||||
nextAddress = XFMEM_SETPROJECTION + 7;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
|
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
|
||||||
if (xfmem.numTexGen.numTexGens != (newValue & 15))
|
if (xfmem.numTexGen.numTexGens != (value & 15))
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -157,8 +146,6 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_SETTEXMTXINFO + 7:
|
case XFMEM_SETTEXMTXINFO + 7:
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetTexMatrixInfoChanged(address - XFMEM_SETTEXMTXINFO);
|
VertexShaderManager::SetTexMatrixInfoChanged(address - XFMEM_SETTEXMTXINFO);
|
||||||
|
|
||||||
nextAddress = XFMEM_SETTEXMTXINFO + 8;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XFMEM_SETPOSTMTXINFO:
|
case XFMEM_SETPOSTMTXINFO:
|
||||||
|
@ -171,8 +158,6 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case XFMEM_SETPOSTMTXINFO + 7:
|
case XFMEM_SETPOSTMTXINFO + 7:
|
||||||
g_vertex_manager->Flush();
|
g_vertex_manager->Flush();
|
||||||
VertexShaderManager::SetTexMatrixInfoChanged(address - XFMEM_SETPOSTMTXINFO);
|
VertexShaderManager::SetTexMatrixInfoChanged(address - XFMEM_SETPOSTMTXINFO);
|
||||||
|
|
||||||
nextAddress = XFMEM_SETPOSTMTXINFO + 8;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// --------------
|
// --------------
|
||||||
|
@ -189,7 +174,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
case 0x104e:
|
case 0x104e:
|
||||||
case 0x104f:
|
case 0x104f:
|
||||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
|
||||||
DEBUG_LOG_FMT(VIDEO, "Possible Normal Mtx XF reg?: {:x}={:x}", address, newValue);
|
DEBUG_LOG_FMT(VIDEO, "Possible Normal Mtx XF reg?: {:x}={:x}", address, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1013:
|
case 0x1013:
|
||||||
|
@ -200,66 +185,62 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
|
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
|
||||||
WARN_LOG_FMT(VIDEO, "Unknown XF Reg: {:x}={:x}", address, newValue);
|
WARN_LOG_FMT(VIDEO, "Unknown XF Reg: {:x}={:x}", address, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int transferred = nextAddress - address;
|
|
||||||
address = nextAddress;
|
|
||||||
|
|
||||||
transferSize -= transferred;
|
|
||||||
dataIndex += transferred;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadXFReg(u32 transferSize, u32 baseAddress, DataReader src)
|
void LoadXFReg(u16 base_address, u8 transfer_size, const u8* data)
|
||||||
{
|
{
|
||||||
// do not allow writes past registers
|
if (base_address > XFMEM_REGISTERS_END)
|
||||||
if (baseAddress + transferSize > XFMEM_REGISTERS_END)
|
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(VIDEO, "XF load exceeds address space: {:x} {} bytes", baseAddress, transferSize);
|
WARN_LOG_FMT(VIDEO, "XF load base address past end of address space: {:x} {} bytes",
|
||||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
|
base_address, transfer_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (baseAddress >= XFMEM_REGISTERS_END)
|
u32 end_address = base_address + transfer_size; // exclusive
|
||||||
transferSize = 0;
|
|
||||||
else
|
// do not allow writes past registers
|
||||||
transferSize = XFMEM_REGISTERS_END - baseAddress;
|
if (end_address > XFMEM_REGISTERS_END)
|
||||||
|
{
|
||||||
|
WARN_LOG_FMT(VIDEO, "XF load ends past end of address space: {:x} {} bytes", base_address,
|
||||||
|
transfer_size);
|
||||||
|
end_address = XFMEM_REGISTERS_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to XF mem
|
// write to XF mem
|
||||||
if (baseAddress < XFMEM_REGISTERS_START && transferSize > 0)
|
if (base_address < XFMEM_REGISTERS_START)
|
||||||
{
|
{
|
||||||
u32 end = baseAddress + transferSize;
|
const u32 xf_mem_base = base_address;
|
||||||
|
u32 xf_mem_transfer_size = transfer_size;
|
||||||
|
|
||||||
u32 xfMemBase = baseAddress;
|
if (end_address > XFMEM_REGISTERS_START)
|
||||||
u32 xfMemTransferSize = transferSize;
|
|
||||||
|
|
||||||
if (end >= XFMEM_REGISTERS_START)
|
|
||||||
{
|
{
|
||||||
xfMemTransferSize = XFMEM_REGISTERS_START - baseAddress;
|
xf_mem_transfer_size = XFMEM_REGISTERS_START - base_address;
|
||||||
|
base_address = XFMEM_REGISTERS_START;
|
||||||
baseAddress = XFMEM_REGISTERS_START;
|
|
||||||
transferSize = end - XFMEM_REGISTERS_START;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
transferSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XFMemWritten(xfMemTransferSize, xfMemBase);
|
XFMemWritten(xf_mem_transfer_size, xf_mem_base);
|
||||||
for (u32 i = 0; i < xfMemTransferSize; i++)
|
for (u32 i = 0; i < xf_mem_transfer_size; i++)
|
||||||
{
|
{
|
||||||
((u32*)&xfmem)[xfMemBase + i] = src.Read<u32>();
|
((u32*)&xfmem)[xf_mem_base + i] = Common::swap32(data);
|
||||||
|
data += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to XF regs
|
// write to XF regs
|
||||||
if (transferSize > 0)
|
if (base_address >= XFMEM_REGISTERS_START)
|
||||||
{
|
{
|
||||||
XFRegWritten(transferSize, baseAddress, src);
|
for (u32 address = base_address; address < end_address; address++)
|
||||||
for (u32 i = 0; i < transferSize; i++)
|
|
||||||
{
|
{
|
||||||
((u32*)&xfmem)[baseAddress + i] = src.Read<u32>();
|
const u32 value = Common::swap32(data);
|
||||||
|
|
||||||
|
XFRegWritten(address, value);
|
||||||
|
((u32*)&xfmem)[address] = value;
|
||||||
|
|
||||||
|
data += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue