Video backend: merge global var xfmem into xfregs.
There isn't really any reason to keep them separate.
This commit is contained in:
parent
818c89313e
commit
8f5342c442
|
@ -115,7 +115,6 @@ void VideoSoftware::DoState(PointerWrap& p)
|
|||
EfbInterface::DoState(p);
|
||||
OpcodeDecoder::DoState(p);
|
||||
Clipper::DoState(p);
|
||||
p.Do(xfmem);
|
||||
p.Do(xfregs);
|
||||
p.Do(bpmem);
|
||||
p.DoPOD(swstats);
|
||||
|
|
|
@ -70,7 +70,7 @@ void MultipleVec3Ortho(const Vec3 &vec, const float *proj, Vec4 &result)
|
|||
|
||||
void TransformPosition(const InputVertexData *src, OutputVertexData *dst)
|
||||
{
|
||||
const float* mat = (const float*)&xfmem.posMatrices[src->posMtx * 4];
|
||||
const float* mat = (const float*)&xfregs.posMatrices[src->posMtx * 4];
|
||||
MultiplyVec3Mat34(src->position, mat, dst->mvPosition);
|
||||
|
||||
if (xfregs.projection.type == GX_PERSPECTIVE)
|
||||
|
@ -85,7 +85,7 @@ void TransformPosition(const InputVertexData *src, OutputVertexData *dst)
|
|||
|
||||
void TransformNormal(const InputVertexData *src, bool nbt, OutputVertexData *dst)
|
||||
{
|
||||
const float* mat = (const float*)&xfmem.normalMatrices[(src->posMtx & 31) * 3];
|
||||
const float* mat = (const float*)&xfregs.normalMatrices[(src->posMtx & 31) * 3];
|
||||
|
||||
if (nbt)
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bool spec
|
|||
break;
|
||||
}
|
||||
|
||||
const float *mat = (const float*)&xfmem.posMatrices[srcVertex->texMtx[coordNum] * 4];
|
||||
const float *mat = (const float*)&xfregs.posMatrices[srcVertex->texMtx[coordNum] * 4];
|
||||
Vec3 *dst = &dstVertex->texCoords[coordNum];
|
||||
|
||||
if (texinfo.projection == XF_TEXPROJ_ST)
|
||||
|
@ -150,7 +150,7 @@ void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bool spec
|
|||
|
||||
// normalize
|
||||
const PostMtxInfo &postInfo = xfregs.postMtxInfo[coordNum];
|
||||
const float *postMat = (const float*)&xfmem.postMatrices[postInfo.index * 4];
|
||||
const float *postMat = (const float*)&xfregs.postMatrices[postInfo.index * 4];
|
||||
|
||||
if (specialCase)
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ inline float SafeDivide(float n, float d)
|
|||
|
||||
void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChannel &chan, Vec3 &lightCol)
|
||||
{
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.lights[0x10*lightNum];
|
||||
const LightPointer *light = (const LightPointer*)&xfregs.lights[0x10*lightNum];
|
||||
|
||||
if (!(chan.attnfunc & 1))
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
|||
|
||||
void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChannel &chan, float &lightCol)
|
||||
{
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.lights[0x10*lightNum];
|
||||
const LightPointer *light = (const LightPointer*)&xfregs.lights[0x10*lightNum];
|
||||
|
||||
if (!(chan.attnfunc & 1))
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool s
|
|||
break;
|
||||
case XF_TEXGEN_EMBOSS_MAP:
|
||||
{
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.lights[0x10*texinfo.embosslightshift];
|
||||
const LightPointer *light = (const LightPointer*)&xfregs.lights[0x10*texinfo.embosslightshift];
|
||||
|
||||
Vec3 ldir = (light->pos - dst->mvPosition).normalized();
|
||||
float d1 = ldir * dst->normal[1];
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
void InitXFMemory()
|
||||
{
|
||||
memset(&xfregs, 0, sizeof(xfregs));
|
||||
memset(&xfmem, 0, sizeof(xfmem));
|
||||
}
|
||||
|
||||
void XFWritten(u32 transferSize, u32 baseAddress)
|
||||
|
@ -24,7 +23,7 @@ void XFWritten(u32 transferSize, u32 baseAddress)
|
|||
// fix lights so invalid values don't trash the lighting computations
|
||||
if (baseAddress <= 0x067f && topAddress >= 0x0604)
|
||||
{
|
||||
u32* x = xfmem.lights;
|
||||
u32* x = xfregs.lights;
|
||||
|
||||
// go through all lights
|
||||
for (int light = 0; light < 8; light++)
|
||||
|
@ -59,36 +58,10 @@ void SWLoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
|||
transferSize = 0x1058 - baseAddress;
|
||||
}
|
||||
|
||||
// write to XF mem
|
||||
if (baseAddress < 0x1000 && transferSize > 0)
|
||||
{
|
||||
u32 end = baseAddress + transferSize;
|
||||
|
||||
u32 xfMemBase = baseAddress;
|
||||
u32 xfMemTransferSize = transferSize;
|
||||
|
||||
if (end >= 0x1000)
|
||||
{
|
||||
xfMemTransferSize = 0x1000 - baseAddress;
|
||||
|
||||
baseAddress = 0x1000;
|
||||
transferSize = end - 0x1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
transferSize = 0;
|
||||
}
|
||||
|
||||
memcpy_gc((u32*)(&xfmem) + xfMemBase, pData, xfMemTransferSize * 4);
|
||||
XFWritten(xfMemTransferSize, xfMemBase);
|
||||
|
||||
pData += xfMemTransferSize;
|
||||
}
|
||||
|
||||
// write to XF regs
|
||||
if (transferSize > 0)
|
||||
{
|
||||
memcpy_gc((u32*)(&xfregs) + (baseAddress - 0x1000), pData, transferSize * 4);
|
||||
memcpy_gc((u32*)(&xfregs) + baseAddress, pData, transferSize * 4);
|
||||
XFWritten(transferSize, baseAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -31,7 +31,6 @@ static void DoState(PointerWrap &p)
|
|||
|
||||
// XF Memory
|
||||
p.Do(xfregs);
|
||||
p.Do(xfmem);
|
||||
p.DoMarker("XF Memory");
|
||||
|
||||
// Texture decoder
|
||||
|
|
|
@ -6,4 +6,3 @@
|
|||
|
||||
// STATE_TO_SAVE
|
||||
XFRegisters xfregs;
|
||||
XFMemory xfmem;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue