Video backend: merge global var xfmem into xfregs.

There isn't really any reason to keep them separate.
This commit is contained in:
magumagu
2014-04-16 18:10:33 -07:00
parent 818c89313e
commit 8f5342c442
11 changed files with 34 additions and 70 deletions

View File

@ -108,7 +108,7 @@ void PixelShaderManager::SetConstants()
// lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats
int istart = nLightsChanged[0] / 0x10;
int iend = (nLightsChanged[1] + 15) / 0x10;
const float* xfmemptr = (const float*)&xfmem.lights[0x10 * istart];
const float* xfmemptr = (const float*)&xfregs.lights[0x10 * istart];
for (int i = istart; i < iend; ++i)
{

View File

@ -504,8 +504,8 @@ void Renderer::RecordVideoMemory()
{
u32 *bpMem = (u32*)&bpmem;
u32 cpMem[256];
u32 *xfMem = (u32*)&xfmem;
u32 *xfRegs = (u32*)&xfregs;
u32 *xfMem = (u32*)&xfregs;
u32 *xfRegs = (u32*)&xfregs + 0x1000;
memset(cpMem, 0, 256 * 4);
FillCPMemoryArray(cpMem);

View File

@ -217,7 +217,7 @@ void LOADERDECL UpdateBoundingBox()
// We need to get the raw projection values for the bounding box calculation
// to work properly. That means, no projection hacks!
const float * const orig_point = s_bbox_vertex_buffer;
const float * const world_matrix = (float*)xfmem.posMatrices + s_curposmtx * 4;
const float * const world_matrix = (float*)xfregs.posMatrices + s_curposmtx * 4;
const float * const proj_matrix = xfregs.projection.rawProjection;
// Transform by world matrix

View File

@ -168,7 +168,6 @@ void VertexShaderManager::Init()
Dirty();
memset(&xfregs, 0, sizeof(xfregs));
memset(&xfmem, 0, sizeof(xfmem));
memset(&constants, 0 , sizeof(constants));
ResetView();
@ -216,7 +215,7 @@ void VertexShaderManager::SetConstants()
{
int startn = nTransformMatricesChanged[0] / 4;
int endn = (nTransformMatricesChanged[1] + 3) / 4;
memcpy(constants.transformmatrices[startn], &xfmem.posMatrices[startn * 4], (endn - startn) * 16);
memcpy(constants.transformmatrices[startn], &xfregs.posMatrices[startn * 4], (endn - startn) * 16);
dirty = true;
nTransformMatricesChanged[0] = nTransformMatricesChanged[1] = -1;
}
@ -227,7 +226,7 @@ void VertexShaderManager::SetConstants()
int endn = (nNormalMatricesChanged[1] + 2) / 3;
for (int i=startn; i<endn; i++)
{
memcpy(constants.normalmatrices[i], &xfmem.normalMatrices[3*i], 12);
memcpy(constants.normalmatrices[i], &xfregs.normalMatrices[3*i], 12);
}
dirty = true;
nNormalMatricesChanged[0] = nNormalMatricesChanged[1] = -1;
@ -237,7 +236,7 @@ void VertexShaderManager::SetConstants()
{
int startn = nPostTransformMatricesChanged[0] / 4;
int endn = (nPostTransformMatricesChanged[1] + 3 ) / 4;
memcpy(constants.posttransformmatrices[startn], &xfmem.postMatrices[startn * 4], (endn - startn) * 16);
memcpy(constants.posttransformmatrices[startn], &xfregs.postMatrices[startn * 4], (endn - startn) * 16);
dirty = true;
nPostTransformMatricesChanged[0] = nPostTransformMatricesChanged[1] = -1;
}
@ -248,7 +247,7 @@ void VertexShaderManager::SetConstants()
// lights don't have a 1 to 1 mapping, the color component needs to be converted to 4 floats
int istart = nLightsChanged[0] / 0x10;
int iend = (nLightsChanged[1] + 15) / 0x10;
const float* xfmemptr = (const float*)&xfmem.lights[0x10 * istart];
const float* xfmemptr = (const float*)&xfregs.lights[0x10 * istart];
for (int i = istart; i < iend; ++i)
{
@ -286,7 +285,7 @@ void VertexShaderManager::SetConstants()
{
if (nMaterialsChanged & (1 << i))
{
u32 data = *(xfregs.ambColor + i);
u32 data = xfregs.ambColor[i];
constants.materials[i][0] = (data >> 24) & 0xFF;
constants.materials[i][1] = (data >> 16) & 0xFF;
constants.materials[i][2] = (data >> 8) & 0xFF;
@ -298,7 +297,7 @@ void VertexShaderManager::SetConstants()
{
if (nMaterialsChanged & (1 << (i + 2)))
{
u32 data = *(xfregs.matColor + i);
u32 data = xfregs.matColor[i];
constants.materials[i+2][0] = (data >> 24) & 0xFF;
constants.materials[i+2][1] = (data >> 16) & 0xFF;
constants.materials[i+2][2] = (data >> 8) & 0xFF;
@ -314,8 +313,8 @@ void VertexShaderManager::SetConstants()
{
bPosNormalMatrixChanged = false;
const float *pos = (const float *)xfmem.posMatrices + MatrixIndexA.PosNormalMtxIdx * 4;
const float *norm = (const float *)xfmem.normalMatrices + 3 * (MatrixIndexA.PosNormalMtxIdx & 31);
const float *pos = (const float *)xfregs.posMatrices + MatrixIndexA.PosNormalMtxIdx * 4;
const float *norm = (const float *)xfregs.normalMatrices + 3 * (MatrixIndexA.PosNormalMtxIdx & 31);
memcpy(constants.posnormalmatrix, pos, 3*16);
memcpy(constants.posnormalmatrix[3], norm, 12);
@ -329,10 +328,10 @@ void VertexShaderManager::SetConstants()
bTexMatricesChanged[0] = false;
const float *fptrs[] =
{
(const float *)&xfmem.posMatrices[MatrixIndexA.Tex0MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexA.Tex1MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexA.Tex2MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexA.Tex3MtxIdx * 4]
(const float *)&xfregs.posMatrices[MatrixIndexA.Tex0MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexA.Tex1MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexA.Tex2MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexA.Tex3MtxIdx * 4]
};
for (int i = 0; i < 4; ++i)
@ -346,10 +345,10 @@ void VertexShaderManager::SetConstants()
{
bTexMatricesChanged[1] = false;
const float *fptrs[] = {
(const float *)&xfmem.posMatrices[MatrixIndexB.Tex4MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexB.Tex5MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexB.Tex6MtxIdx * 4],
(const float *)&xfmem.posMatrices[MatrixIndexB.Tex7MtxIdx * 4]
(const float *)&xfregs.posMatrices[MatrixIndexB.Tex4MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexB.Tex5MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexB.Tex6MtxIdx * 4],
(const float *)&xfregs.posMatrices[MatrixIndexB.Tex7MtxIdx * 4]
};
for (int i = 0; i < 4; ++i)

View File

@ -31,7 +31,6 @@ static void DoState(PointerWrap &p)
// XF Memory
p.Do(xfregs);
p.Do(xfmem);
p.DoMarker("XF Memory");
// Texture decoder

View File

@ -6,4 +6,3 @@
// STATE_TO_SAVE
XFRegisters xfregs;
XFMemory xfmem;

View File

@ -234,7 +234,7 @@ struct Projection
u32 type; // only GX_PERSPECTIVE or GX_ORTHOGRAPHIC are allowed
};
struct XFMemory
struct XFRegisters
{
u32 posMatrices[256]; // 0x0000 - 0x00ff
u32 unk0[768]; // 0x0100 - 0x03ff
@ -243,10 +243,6 @@ struct XFMemory
u32 postMatrices[256]; // 0x0500 - 0x05ff
u32 lights[128]; // 0x0600 - 0x067f
u32 unk2[2432]; // 0x0680 - 0x0fff
};
struct XFRegisters
{
u32 error; // 0x1000
u32 diag; // 0x1001
u32 state0; // 0x1002
@ -279,7 +275,6 @@ struct XFRegisters
};
extern XFMemory xfmem;
extern XFRegisters xfregs;
void LoadXFReg(u32 transferSize, u32 address, u32 *pData);

View File

@ -83,7 +83,7 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETCHAN1_COLOR:
case XFMEM_SETCHAN0_ALPHA: // Channel Alpha
case XFMEM_SETCHAN1_ALPHA:
if (((u32*)&xfregs)[address - 0x1000] != (newValue & 0x7fff))
if (((u32*)&xfregs)[address] != (newValue & 0x7fff))
VertexManager::Flush();
break;
@ -228,7 +228,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
}
XFMemWritten(xfMemTransferSize, xfMemBase);
memcpy_gc((u32*)(&xfmem) + xfMemBase, pData, xfMemTransferSize * 4);
memcpy_gc((u32*)(&xfregs) + xfMemBase, pData, xfMemTransferSize * 4);
pData += xfMemTransferSize;
}
@ -237,7 +237,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
if (transferSize > 0)
{
XFRegWritten(transferSize, baseAddress, pData);
memcpy_gc((u32*)(&xfregs) + (baseAddress - 0x1000), pData, transferSize * 4);
memcpy_gc((u32*)(&xfregs) + baseAddress, pData, transferSize * 4);
}
}
@ -249,7 +249,7 @@ void LoadIndexedXF(u32 val, int refarray)
int size = ((val >> 12) & 0xF) + 1;
//load stuff from array to address in xf mem
u32* currData = (u32*)(&xfmem) + address;
u32* currData = (u32*)(&xfregs) + address;
u32* newData = (u32*)Memory::GetPointer(arraybases[refarray] + arraystrides[refarray] * index);
bool changed = false;
for (int i = 0; i < size; ++i)