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

@ -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);

View File

@ -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];

View File

@ -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);
}
}