mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Video backends: mass-replace "xfregs" with "xfmem".
This commit is contained in:
@ -67,8 +67,8 @@ namespace Clipper
|
||||
|
||||
void SetViewOffset()
|
||||
{
|
||||
m_ViewOffset[0] = xfregs.viewport.xOrig - 342;
|
||||
m_ViewOffset[1] = xfregs.viewport.yOrig - 342;
|
||||
m_ViewOffset[0] = xfmem.viewport.xOrig - 342;
|
||||
m_ViewOffset[1] = xfmem.viewport.yOrig - 342;
|
||||
}
|
||||
|
||||
|
||||
@ -430,9 +430,9 @@ namespace Clipper
|
||||
Vec3 &screen = vertex->screenPosition;
|
||||
|
||||
float wInverse = 1.0f/projected.w;
|
||||
screen.x = projected.x * wInverse * xfregs.viewport.wd + m_ViewOffset[0];
|
||||
screen.y = projected.y * wInverse * xfregs.viewport.ht + m_ViewOffset[1];
|
||||
screen.z = projected.z * wInverse * xfregs.viewport.zRange + xfregs.viewport.farZ;
|
||||
screen.x = projected.x * wInverse * xfmem.viewport.wd + m_ViewOffset[0];
|
||||
screen.y = projected.y * wInverse * xfmem.viewport.ht + m_ViewOffset[1];
|
||||
screen.z = projected.z * wInverse * xfmem.viewport.zRange + xfmem.viewport.farZ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ void BuildBlock(s32 blockX, s32 blockY)
|
||||
for (unsigned int i = 0; i < bpmem.genMode.numtexgens; i++)
|
||||
{
|
||||
float projection = invW;
|
||||
if (xfregs.texMtxInfo[i].projection)
|
||||
if (xfmem.texMtxInfo[i].projection)
|
||||
{
|
||||
float q = TexSlopes[i][2].GetValue(dx, dy) * invW;
|
||||
if (q != 0.0f)
|
||||
|
@ -95,15 +95,15 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
||||
|
||||
// Reset vertex
|
||||
// matrix index from xf regs or cp memory?
|
||||
if (xfregs.MatrixIndexA.PosNormalMtxIdx != MatrixIndexA.PosNormalMtxIdx ||
|
||||
xfregs.MatrixIndexA.Tex0MtxIdx != MatrixIndexA.Tex0MtxIdx ||
|
||||
xfregs.MatrixIndexA.Tex1MtxIdx != MatrixIndexA.Tex1MtxIdx ||
|
||||
xfregs.MatrixIndexA.Tex2MtxIdx != MatrixIndexA.Tex2MtxIdx ||
|
||||
xfregs.MatrixIndexA.Tex3MtxIdx != MatrixIndexA.Tex3MtxIdx ||
|
||||
xfregs.MatrixIndexB.Tex4MtxIdx != MatrixIndexB.Tex4MtxIdx ||
|
||||
xfregs.MatrixIndexB.Tex5MtxIdx != MatrixIndexB.Tex5MtxIdx ||
|
||||
xfregs.MatrixIndexB.Tex6MtxIdx != MatrixIndexB.Tex6MtxIdx ||
|
||||
xfregs.MatrixIndexB.Tex7MtxIdx != MatrixIndexB.Tex7MtxIdx)
|
||||
if (xfmem.MatrixIndexA.PosNormalMtxIdx != MatrixIndexA.PosNormalMtxIdx ||
|
||||
xfmem.MatrixIndexA.Tex0MtxIdx != MatrixIndexA.Tex0MtxIdx ||
|
||||
xfmem.MatrixIndexA.Tex1MtxIdx != MatrixIndexA.Tex1MtxIdx ||
|
||||
xfmem.MatrixIndexA.Tex2MtxIdx != MatrixIndexA.Tex2MtxIdx ||
|
||||
xfmem.MatrixIndexA.Tex3MtxIdx != MatrixIndexA.Tex3MtxIdx ||
|
||||
xfmem.MatrixIndexB.Tex4MtxIdx != MatrixIndexB.Tex4MtxIdx ||
|
||||
xfmem.MatrixIndexB.Tex5MtxIdx != MatrixIndexB.Tex5MtxIdx ||
|
||||
xfmem.MatrixIndexB.Tex6MtxIdx != MatrixIndexB.Tex6MtxIdx ||
|
||||
xfmem.MatrixIndexB.Tex7MtxIdx != MatrixIndexB.Tex7MtxIdx)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Matrix indices don't match");
|
||||
|
||||
@ -114,15 +114,15 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
||||
}
|
||||
|
||||
#if(1)
|
||||
m_Vertex.posMtx = xfregs.MatrixIndexA.PosNormalMtxIdx;
|
||||
m_Vertex.texMtx[0] = xfregs.MatrixIndexA.Tex0MtxIdx;
|
||||
m_Vertex.texMtx[1] = xfregs.MatrixIndexA.Tex1MtxIdx;
|
||||
m_Vertex.texMtx[2] = xfregs.MatrixIndexA.Tex2MtxIdx;
|
||||
m_Vertex.texMtx[3] = xfregs.MatrixIndexA.Tex3MtxIdx;
|
||||
m_Vertex.texMtx[4] = xfregs.MatrixIndexB.Tex4MtxIdx;
|
||||
m_Vertex.texMtx[5] = xfregs.MatrixIndexB.Tex5MtxIdx;
|
||||
m_Vertex.texMtx[6] = xfregs.MatrixIndexB.Tex6MtxIdx;
|
||||
m_Vertex.texMtx[7] = xfregs.MatrixIndexB.Tex7MtxIdx;
|
||||
m_Vertex.posMtx = xfmem.MatrixIndexA.PosNormalMtxIdx;
|
||||
m_Vertex.texMtx[0] = xfmem.MatrixIndexA.Tex0MtxIdx;
|
||||
m_Vertex.texMtx[1] = xfmem.MatrixIndexA.Tex1MtxIdx;
|
||||
m_Vertex.texMtx[2] = xfmem.MatrixIndexA.Tex2MtxIdx;
|
||||
m_Vertex.texMtx[3] = xfmem.MatrixIndexA.Tex3MtxIdx;
|
||||
m_Vertex.texMtx[4] = xfmem.MatrixIndexB.Tex4MtxIdx;
|
||||
m_Vertex.texMtx[5] = xfmem.MatrixIndexB.Tex5MtxIdx;
|
||||
m_Vertex.texMtx[6] = xfmem.MatrixIndexB.Tex6MtxIdx;
|
||||
m_Vertex.texMtx[7] = xfmem.MatrixIndexB.Tex7MtxIdx;
|
||||
#else
|
||||
m_Vertex.posMtx = MatrixIndexA.PosNormalMtxIdx;
|
||||
m_Vertex.texMtx[0] = MatrixIndexA.Tex0MtxIdx;
|
||||
@ -242,7 +242,7 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
||||
m_TexGenSpecialCase =
|
||||
((g_VtxDesc.Hex & 0x60600L) == g_VtxDesc.Hex) && // only pos and tex coord 0
|
||||
(g_VtxDesc.Tex0Coord != NOT_PRESENT) &&
|
||||
(xfregs.texMtxInfo[0].projection == XF_TEXPROJ_ST);
|
||||
(xfmem.texMtxInfo[0].projection == XF_TEXPROJ_ST);
|
||||
|
||||
m_SetupUnit->Init(primitiveType);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void VideoSoftware::DoState(PointerWrap& p)
|
||||
EfbInterface::DoState(p);
|
||||
OpcodeDecoder::DoState(p);
|
||||
Clipper::DoState(p);
|
||||
p.Do(xfregs);
|
||||
p.Do(xfmem);
|
||||
p.Do(bpmem);
|
||||
p.DoPOD(swstats);
|
||||
|
||||
|
@ -689,7 +689,7 @@ void Tev::Draw()
|
||||
// - scaling of the "k" coefficient isn't clear either.
|
||||
|
||||
// First, calculate the offset from the viewport center (normalized to 0..1)
|
||||
float offset = (Position[0] - (bpmem.fogRange.Base.Center - 342)) / (float)xfregs.viewport.wd;
|
||||
float offset = (Position[0] - (bpmem.fogRange.Base.Center - 342)) / (float)xfmem.viewport.wd;
|
||||
|
||||
// Based on that, choose the index such that points which are far away from the z-axis use the 10th "k" value and such that central points use the first value.
|
||||
float floatindex = 9.f - std::abs(offset) * 9.f;
|
||||
|
@ -70,22 +70,22 @@ void MultipleVec3Ortho(const Vec3 &vec, const float *proj, Vec4 &result)
|
||||
|
||||
void TransformPosition(const InputVertexData *src, OutputVertexData *dst)
|
||||
{
|
||||
const float* mat = (const float*)&xfregs.posMatrices[src->posMtx * 4];
|
||||
const float* mat = (const float*)&xfmem.posMatrices[src->posMtx * 4];
|
||||
MultiplyVec3Mat34(src->position, mat, dst->mvPosition);
|
||||
|
||||
if (xfregs.projection.type == GX_PERSPECTIVE)
|
||||
if (xfmem.projection.type == GX_PERSPECTIVE)
|
||||
{
|
||||
MultipleVec3Perspective(dst->mvPosition, xfregs.projection.rawProjection, dst->projectedPosition);
|
||||
MultipleVec3Perspective(dst->mvPosition, xfmem.projection.rawProjection, dst->projectedPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
MultipleVec3Ortho(dst->mvPosition, xfregs.projection.rawProjection, dst->projectedPosition);
|
||||
MultipleVec3Ortho(dst->mvPosition, xfmem.projection.rawProjection, dst->projectedPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformNormal(const InputVertexData *src, bool nbt, OutputVertexData *dst)
|
||||
{
|
||||
const float* mat = (const float*)&xfregs.normalMatrices[(src->posMtx & 31) * 3];
|
||||
const float* mat = (const float*)&xfmem.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*)&xfregs.posMatrices[srcVertex->texMtx[coordNum] * 4];
|
||||
const float *mat = (const float*)&xfmem.posMatrices[srcVertex->texMtx[coordNum] * 4];
|
||||
Vec3 *dst = &dstVertex->texCoords[coordNum];
|
||||
|
||||
if (texinfo.projection == XF_TEXPROJ_ST)
|
||||
@ -144,13 +144,13 @@ void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bool spec
|
||||
MultiplyVec3Mat34(*src, mat, *dst);
|
||||
}
|
||||
|
||||
if (xfregs.dualTexTrans.enabled)
|
||||
if (xfmem.dualTexTrans.enabled)
|
||||
{
|
||||
Vec3 tempCoord;
|
||||
|
||||
// normalize
|
||||
const PostMtxInfo &postInfo = xfregs.postMtxInfo[coordNum];
|
||||
const float *postMat = (const float*)&xfregs.postMatrices[postInfo.index * 4];
|
||||
const PostMtxInfo &postInfo = xfmem.postMtxInfo[coordNum];
|
||||
const float *postMat = (const float*)&xfmem.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*)&xfregs.lights[0x10*lightNum];
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.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*)&xfregs.lights[0x10*lightNum];
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.lights[0x10*lightNum];
|
||||
|
||||
if (!(chan.attnfunc & 1))
|
||||
{
|
||||
@ -376,18 +376,18 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann
|
||||
|
||||
void TransformColor(const InputVertexData *src, OutputVertexData *dst)
|
||||
{
|
||||
for (u32 chan = 0; chan < xfregs.numChan.numColorChans; chan++)
|
||||
for (u32 chan = 0; chan < xfmem.numChan.numColorChans; chan++)
|
||||
{
|
||||
// abgr
|
||||
u8 matcolor[4];
|
||||
u8 chancolor[4];
|
||||
|
||||
// color
|
||||
LitChannel &colorchan = xfregs.color[chan];
|
||||
LitChannel &colorchan = xfmem.color[chan];
|
||||
if (colorchan.matsource)
|
||||
*(u32*)matcolor = *(u32*)src->color[chan]; // vertex
|
||||
else
|
||||
*(u32*)matcolor = xfregs.matColor[chan];
|
||||
*(u32*)matcolor = xfmem.matColor[chan];
|
||||
|
||||
if (colorchan.enablelighting)
|
||||
{
|
||||
@ -401,7 +401,7 @@ void TransformColor(const InputVertexData *src, OutputVertexData *dst)
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 *ambColor = (u8*)&xfregs.ambColor[chan];
|
||||
u8 *ambColor = (u8*)&xfmem.ambColor[chan];
|
||||
lightCol.x = ambColor[1];
|
||||
lightCol.y = ambColor[2];
|
||||
lightCol.z = ambColor[3];
|
||||
@ -425,19 +425,19 @@ void TransformColor(const InputVertexData *src, OutputVertexData *dst)
|
||||
}
|
||||
|
||||
// alpha
|
||||
LitChannel &alphachan = xfregs.alpha[chan];
|
||||
LitChannel &alphachan = xfmem.alpha[chan];
|
||||
if (alphachan.matsource)
|
||||
matcolor[0] = src->color[chan][0]; // vertex
|
||||
else
|
||||
matcolor[0] = xfregs.matColor[chan] & 0xff;
|
||||
matcolor[0] = xfmem.matColor[chan] & 0xff;
|
||||
|
||||
if (xfregs.alpha[chan].enablelighting)
|
||||
if (xfmem.alpha[chan].enablelighting)
|
||||
{
|
||||
float lightCol;
|
||||
if (alphachan.ambsource)
|
||||
lightCol = src->color[chan][0]; // vertex
|
||||
else
|
||||
lightCol = (float)(xfregs.ambColor[chan] & 0xff);
|
||||
lightCol = (float)(xfmem.ambColor[chan] & 0xff);
|
||||
|
||||
u8 mask = alphachan.GetFullLightMask();
|
||||
for (int i = 0; i < 8; ++i)
|
||||
@ -460,9 +460,9 @@ void TransformColor(const InputVertexData *src, OutputVertexData *dst)
|
||||
|
||||
void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool specialCase)
|
||||
{
|
||||
for (u32 coordNum = 0; coordNum < xfregs.numTexGen.numTexGens; coordNum++)
|
||||
for (u32 coordNum = 0; coordNum < xfmem.numTexGen.numTexGens; coordNum++)
|
||||
{
|
||||
const TexMtxInfo &texinfo = xfregs.texMtxInfo[coordNum];
|
||||
const TexMtxInfo &texinfo = xfmem.texMtxInfo[coordNum];
|
||||
|
||||
switch (texinfo.texgentype)
|
||||
{
|
||||
@ -471,7 +471,7 @@ void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool s
|
||||
break;
|
||||
case XF_TEXGEN_EMBOSS_MAP:
|
||||
{
|
||||
const LightPointer *light = (const LightPointer*)&xfregs.lights[0x10*texinfo.embosslightshift];
|
||||
const LightPointer *light = (const LightPointer*)&xfmem.lights[0x10*texinfo.embosslightshift];
|
||||
|
||||
Vec3 ldir = (light->pos - dst->mvPosition).normalized();
|
||||
float d1 = ldir * dst->normal[1];
|
||||
@ -501,7 +501,7 @@ void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool s
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 coordNum = 0; coordNum < xfregs.numTexGen.numTexGens; coordNum++)
|
||||
for (u32 coordNum = 0; coordNum < xfmem.numTexGen.numTexGens; coordNum++)
|
||||
{
|
||||
dst->texCoords[coordNum][0] *= (bpmem.texcoords[coordNum].s.scale_minus_1 + 1);
|
||||
dst->texCoords[coordNum][1] *= (bpmem.texcoords[coordNum].t.scale_minus_1 + 1);
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
void InitXFMemory()
|
||||
{
|
||||
memset(&xfregs, 0, sizeof(xfregs));
|
||||
memset(&xfmem, 0, sizeof(xfmem));
|
||||
}
|
||||
|
||||
void XFWritten(u32 transferSize, u32 baseAddress)
|
||||
@ -23,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 = xfregs.lights;
|
||||
u32* x = xfmem.lights;
|
||||
|
||||
// go through all lights
|
||||
for (int light = 0; light < 8; light++)
|
||||
@ -61,7 +61,7 @@ void SWLoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
||||
// write to XF regs
|
||||
if (transferSize > 0)
|
||||
{
|
||||
memcpy_gc((u32*)(&xfregs) + baseAddress, pData, transferSize * 4);
|
||||
memcpy_gc((u32*)(&xfmem) + baseAddress, pData, transferSize * 4);
|
||||
XFWritten(transferSize, baseAddress);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user