From 818c89313e54bcf3de98b976c0da57c88a8588d2 Mon Sep 17 00:00:00 2001 From: magumagu Date: Wed, 16 Apr 2014 14:51:18 -0700 Subject: [PATCH] Video backends: unify xfregs/xfmem structures. Removes the duplicate swxfregs global variable/struct from the software backend in favor of the ones from VideoCommon. --- .../Core/VideoBackends/Software/Clipper.cpp | 10 +-- .../VideoBackends/Software/Rasterizer.cpp | 2 +- .../VideoBackends/Software/SWVertexLoader.cpp | 38 +++++----- Source/Core/VideoBackends/Software/SWmain.cpp | 3 +- Source/Core/VideoBackends/Software/Tev.cpp | 2 +- .../VideoBackends/Software/TransformUnit.cpp | 46 ++++++------ .../VideoBackends/Software/XFMemLoader.cpp | 46 +++++++++--- .../Core/VideoBackends/Software/XFMemLoader.h | 75 ------------------- .../Core/VideoCommon/PixelShaderManager.cpp | 2 +- Source/Core/VideoCommon/RenderBase.cpp | 2 +- Source/Core/VideoCommon/VertexLoader.cpp | 2 +- .../Core/VideoCommon/VertexShaderManager.cpp | 26 ++++--- Source/Core/VideoCommon/VideoState.cpp | 2 +- Source/Core/VideoCommon/XFMemory.cpp | 2 +- Source/Core/VideoCommon/XFMemory.h | 19 ++++- Source/Core/VideoCommon/XFStructs.cpp | 4 +- 16 files changed, 123 insertions(+), 158 deletions(-) diff --git a/Source/Core/VideoBackends/Software/Clipper.cpp b/Source/Core/VideoBackends/Software/Clipper.cpp index e1081da142..f74a494622 100644 --- a/Source/Core/VideoBackends/Software/Clipper.cpp +++ b/Source/Core/VideoBackends/Software/Clipper.cpp @@ -67,8 +67,8 @@ namespace Clipper void SetViewOffset() { - m_ViewOffset[0] = swxfregs.viewport.xOrig - 342; - m_ViewOffset[1] = swxfregs.viewport.yOrig - 342; + m_ViewOffset[0] = xfregs.viewport.xOrig - 342; + m_ViewOffset[1] = xfregs.viewport.yOrig - 342; } @@ -430,9 +430,9 @@ namespace Clipper Vec3 &screen = vertex->screenPosition; float wInverse = 1.0f/projected.w; - screen.x = projected.x * wInverse * swxfregs.viewport.wd + m_ViewOffset[0]; - screen.y = projected.y * wInverse * swxfregs.viewport.ht + m_ViewOffset[1]; - screen.z = projected.z * wInverse * swxfregs.viewport.zRange + swxfregs.viewport.farZ; + 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; } } diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index bf90d5a862..6334a300f5 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -270,7 +270,7 @@ void BuildBlock(s32 blockX, s32 blockY) for (unsigned int i = 0; i < bpmem.genMode.numtexgens; i++) { float projection = invW; - if (swxfregs.texMtxInfo[i].projection) + if (xfregs.texMtxInfo[i].projection) { float q = TexSlopes[i][2].GetValue(dx, dy) * invW; if (q != 0.0f) diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index 63d96dcd2c..490e5b54d3 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -95,15 +95,15 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) // Reset vertex // matrix index from xf regs or cp memory? - if (swxfregs.MatrixIndexA.PosNormalMtxIdx != MatrixIndexA.PosNormalMtxIdx || - swxfregs.MatrixIndexA.Tex0MtxIdx != MatrixIndexA.Tex0MtxIdx || - swxfregs.MatrixIndexA.Tex1MtxIdx != MatrixIndexA.Tex1MtxIdx || - swxfregs.MatrixIndexA.Tex2MtxIdx != MatrixIndexA.Tex2MtxIdx || - swxfregs.MatrixIndexA.Tex3MtxIdx != MatrixIndexA.Tex3MtxIdx || - swxfregs.MatrixIndexB.Tex4MtxIdx != MatrixIndexB.Tex4MtxIdx || - swxfregs.MatrixIndexB.Tex5MtxIdx != MatrixIndexB.Tex5MtxIdx || - swxfregs.MatrixIndexB.Tex6MtxIdx != MatrixIndexB.Tex6MtxIdx || - swxfregs.MatrixIndexB.Tex7MtxIdx != MatrixIndexB.Tex7MtxIdx) + 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) { WARN_LOG(VIDEO, "Matrix indices don't match"); @@ -114,15 +114,15 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) } #if(1) - m_Vertex.posMtx = swxfregs.MatrixIndexA.PosNormalMtxIdx; - m_Vertex.texMtx[0] = swxfregs.MatrixIndexA.Tex0MtxIdx; - m_Vertex.texMtx[1] = swxfregs.MatrixIndexA.Tex1MtxIdx; - m_Vertex.texMtx[2] = swxfregs.MatrixIndexA.Tex2MtxIdx; - m_Vertex.texMtx[3] = swxfregs.MatrixIndexA.Tex3MtxIdx; - m_Vertex.texMtx[4] = swxfregs.MatrixIndexB.Tex4MtxIdx; - m_Vertex.texMtx[5] = swxfregs.MatrixIndexB.Tex5MtxIdx; - m_Vertex.texMtx[6] = swxfregs.MatrixIndexB.Tex6MtxIdx; - m_Vertex.texMtx[7] = swxfregs.MatrixIndexB.Tex7MtxIdx; + 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; #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) && - (swxfregs.texMtxInfo[0].projection == XF_TEXPROJ_ST); + (xfregs.texMtxInfo[0].projection == XF_TEXPROJ_ST); m_SetupUnit->Init(primitiveType); } diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index f41aba3a28..16ce1d059c 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -115,7 +115,8 @@ void VideoSoftware::DoState(PointerWrap& p) EfbInterface::DoState(p); OpcodeDecoder::DoState(p); Clipper::DoState(p); - p.Do(swxfregs); + p.Do(xfmem); + p.Do(xfregs); p.Do(bpmem); p.DoPOD(swstats); diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 9e6191c315..f20ed7b11e 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -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)swxfregs.viewport.wd; + float offset = (Position[0] - (bpmem.fogRange.Base.Center - 342)) / (float)xfregs.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; diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index f0722ce797..a25ef9e460 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -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*)&swxfregs.posMatrices[src->posMtx * 4]; + const float* mat = (const float*)&xfmem.posMatrices[src->posMtx * 4]; MultiplyVec3Mat34(src->position, mat, dst->mvPosition); - if (swxfregs.projection.type == GX_PERSPECTIVE) + if (xfregs.projection.type == GX_PERSPECTIVE) { - MultipleVec3Perspective(dst->mvPosition, swxfregs.projection.rawProjection, dst->projectedPosition); + MultipleVec3Perspective(dst->mvPosition, xfregs.projection.rawProjection, dst->projectedPosition); } else { - MultipleVec3Ortho(dst->mvPosition, swxfregs.projection.rawProjection, dst->projectedPosition); + MultipleVec3Ortho(dst->mvPosition, xfregs.projection.rawProjection, dst->projectedPosition); } } void TransformNormal(const InputVertexData *src, bool nbt, OutputVertexData *dst) { - const float* mat = (const float*)&swxfregs.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*)&swxfregs.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 (swxfregs.dualTexTrans) + if (xfregs.dualTexTrans.enabled) { Vec3 tempCoord; // normalize - const PostMtxInfo &postInfo = swxfregs.postMtxInfo[coordNum]; - const float *postMat = (const float*)&swxfregs.postMatrices[postInfo.index * 4]; + const PostMtxInfo &postInfo = xfregs.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*)&swxfregs.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*)&swxfregs.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 < swxfregs.nNumChans; chan++) + for (u32 chan = 0; chan < xfregs.numChan.numColorChans; chan++) { // abgr u8 matcolor[4]; u8 chancolor[4]; // color - LitChannel &colorchan = swxfregs.color[chan]; + LitChannel &colorchan = xfregs.color[chan]; if (colorchan.matsource) *(u32*)matcolor = *(u32*)src->color[chan]; // vertex else - *(u32*)matcolor = swxfregs.matColor[chan]; + *(u32*)matcolor = xfregs.matColor[chan]; if (colorchan.enablelighting) { @@ -401,7 +401,7 @@ void TransformColor(const InputVertexData *src, OutputVertexData *dst) } else { - u8 *ambColor = (u8*)&swxfregs.ambColor[chan]; + u8 *ambColor = (u8*)&xfregs.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 = swxfregs.alpha[chan]; + LitChannel &alphachan = xfregs.alpha[chan]; if (alphachan.matsource) matcolor[0] = src->color[chan][0]; // vertex else - matcolor[0] = swxfregs.matColor[chan] & 0xff; + matcolor[0] = xfregs.matColor[chan] & 0xff; - if (swxfregs.alpha[chan].enablelighting) + if (xfregs.alpha[chan].enablelighting) { float lightCol; if (alphachan.ambsource) lightCol = src->color[chan][0]; // vertex else - lightCol = (float)(swxfregs.ambColor[chan] & 0xff); + lightCol = (float)(xfregs.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 < swxfregs.numTexGens; coordNum++) + for (u32 coordNum = 0; coordNum < xfregs.numTexGen.numTexGens; coordNum++) { - const TexMtxInfo &texinfo = swxfregs.texMtxInfo[coordNum]; + const TexMtxInfo &texinfo = xfregs.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*)&swxfregs.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 < swxfregs.numTexGens; coordNum++) + for (u32 coordNum = 0; coordNum < xfregs.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); diff --git a/Source/Core/VideoBackends/Software/XFMemLoader.cpp b/Source/Core/VideoBackends/Software/XFMemLoader.cpp index 0c1c51d400..4304500056 100644 --- a/Source/Core/VideoBackends/Software/XFMemLoader.cpp +++ b/Source/Core/VideoBackends/Software/XFMemLoader.cpp @@ -8,11 +8,10 @@ #include "VideoBackends/Software/XFMemLoader.h" #include "VideoCommon/VideoCommon.h" -SWXFRegisters swxfregs; - void InitXFMemory() { - memset(&swxfregs, 0, sizeof(swxfregs)); + memset(&xfregs, 0, sizeof(xfregs)); + memset(&xfmem, 0, sizeof(xfmem)); } void XFWritten(u32 transferSize, u32 baseAddress) @@ -25,7 +24,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 = swxfregs.lights; + u32* x = xfmem.lights; // go through all lights for (int light = 0; light < 8; light++) @@ -49,22 +48,47 @@ void XFWritten(u32 transferSize, u32 baseAddress) void SWLoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData) { - u32 size = transferSize; - // do not allow writes past registers if (baseAddress + transferSize > 0x1058) { - INFO_LOG(VIDEO, "xf load exceeds address space: %x %d bytes\n", baseAddress, transferSize); + INFO_LOG(VIDEO, "XF load exceeds address space: %x %d bytes", baseAddress, transferSize); if (baseAddress >= 0x1058) - size = 0; + transferSize = 0; else - size = 0x1058 - baseAddress; + transferSize = 0x1058 - baseAddress; } - if (size > 0) + // write to XF mem + if (baseAddress < 0x1000 && transferSize > 0) { - memcpy_gc( &((u32*)&swxfregs)[baseAddress], pData, size * 4); + 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); XFWritten(transferSize, baseAddress); } } diff --git a/Source/Core/VideoBackends/Software/XFMemLoader.h b/Source/Core/VideoBackends/Software/XFMemLoader.h index 2bda565aeb..bc639f6c76 100644 --- a/Source/Core/VideoBackends/Software/XFMemLoader.h +++ b/Source/Core/VideoBackends/Software/XFMemLoader.h @@ -8,81 +8,6 @@ #include "VideoCommon/XFMemory.h" -union TXFMatrixIndexA -{ - struct - { - u32 PosNormalMtxIdx : 6; - u32 Tex0MtxIdx : 6; - u32 Tex1MtxIdx : 6; - u32 Tex2MtxIdx : 6; - u32 Tex3MtxIdx : 6; - }; - struct - { - u32 Hex : 30; - u32 unused : 2; - }; -}; - -union TXFMatrixIndexB -{ - struct - { - u32 Tex4MtxIdx : 6; - u32 Tex5MtxIdx : 6; - u32 Tex6MtxIdx : 6; - u32 Tex7MtxIdx : 6; - }; - struct - { - u32 Hex : 24; - u32 unused : 8; - }; -}; - -struct SWXFRegisters -{ - u32 posMatrices[256]; // 0x0000 - 0x00ff - u32 unk0[768]; // 0x0100 - 0x03ff - u32 normalMatrices[96]; // 0x0400 - 0x045f - u32 unk1[160]; // 0x0460 - 0x04ff - u32 postMatrices[256]; // 0x0500 - 0x05ff - u32 lights[128]; // 0x0600 - 0x067f - u32 unk2[2432]; // 0x0680 - 0x0fff - u32 error; // 0x1000 - u32 diag; // 0x1001 - u32 state0; // 0x1002 - u32 state1; // 0x1003 - u32 xfClock; // 0x1004 - u32 clipDisable; // 0x1005 - u32 perf0; // 0x1006 - u32 perf1; // 0x1007 - INVTXSPEC hostinfo; // 0x1008 number of textures,colors,normals from vertex input - u32 nNumChans; // 0x1009 - u32 ambColor[2]; // 0x100a, 0x100b - u32 matColor[2]; // 0x100c, 0x100d - LitChannel color[2]; // 0x100e, 0x100f - LitChannel alpha[2]; // 0x1010, 0x1011 - u32 dualTexTrans; // 0x1012 - u32 unk3; // 0x1013 - u32 unk4; // 0x1014 - u32 unk5; // 0x1015 - u32 unk6; // 0x1016 - u32 unk7; // 0x1017 - TXFMatrixIndexA MatrixIndexA; // 0x1018 - TXFMatrixIndexB MatrixIndexB; // 0x1019 - Viewport viewport; // 0x101a - 0x101f - Projection projection; // 0x1020 - 0x1026 - u32 unk8[24]; // 0x1027 - 0x103e - u32 numTexGens; // 0x103f - TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047 - u32 unk9[8]; // 0x1048 - 0x104f - PostMtxInfo postMtxInfo[8]; // 0x1050 - 0x1057 -}; - -extern SWXFRegisters swxfregs; - void InitXFMemory(); void XFWritten(u32 transferSize, u32 baseAddress); diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index aa5140d4df..f03b6332ac 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -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[0x10 * istart + XFMEM_LIGHTS]; + const float* xfmemptr = (const float*)&xfmem.lights[0x10 * istart]; for (int i = istart; i < iend; ++i) { diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 8b42d1c23b..8702648b9a 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -504,7 +504,7 @@ void Renderer::RecordVideoMemory() { u32 *bpMem = (u32*)&bpmem; u32 cpMem[256]; - u32 *xfMem = (u32*)xfmem; + u32 *xfMem = (u32*)&xfmem; u32 *xfRegs = (u32*)&xfregs; memset(cpMem, 0, 256 * 4); diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 80fbf08cb5..5b99174822 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -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 + s_curposmtx * 4; + const float * const world_matrix = (float*)xfmem.posMatrices + s_curposmtx * 4; const float * const proj_matrix = xfregs.projection.rawProjection; // Transform by world matrix diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index b26ee5ccf9..627d432fb0 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -168,7 +168,7 @@ void VertexShaderManager::Init() Dirty(); memset(&xfregs, 0, sizeof(xfregs)); - memset(xfmem, 0, sizeof(xfmem)); + memset(&xfmem, 0, sizeof(xfmem)); memset(&constants, 0 , sizeof(constants)); ResetView(); @@ -216,7 +216,7 @@ void VertexShaderManager::SetConstants() { int startn = nTransformMatricesChanged[0] / 4; int endn = (nTransformMatricesChanged[1] + 3) / 4; - memcpy(constants.transformmatrices[startn], &xfmem[startn * 4], (endn - startn) * 16); + memcpy(constants.transformmatrices[startn], &xfmem.posMatrices[startn * 4], (endn - startn) * 16); dirty = true; nTransformMatricesChanged[0] = nTransformMatricesChanged[1] = -1; } @@ -227,7 +227,7 @@ void VertexShaderManager::SetConstants() int endn = (nNormalMatricesChanged[1] + 2) / 3; for (int i=startn; i> 12) & 0xF) + 1; //load stuff from array to address in xf mem - u32* currData = (u32*)(xfmem + address); + u32* currData = (u32*)(&xfmem) + address; u32* newData = (u32*)Memory::GetPointer(arraybases[refarray] + arraystrides[refarray] * index); bool changed = false; for (int i = 0; i < size; ++i)