Update GSSetupPrimCodeGenerator for x86_64.

offsetof requires the expression to be constant to get the offset.
Use a combination of offsetof + sizeof to get the correct offset.
This commit is contained in:
Ryan Houdek 2014-07-15 18:22:54 -05:00
parent 74dd2553a6
commit 8ff0f9e869
1 changed files with 27 additions and 12 deletions

View File

@ -36,7 +36,7 @@ void GSSetupPrimCodeGenerator::Generate()
mov(r8, (size_t)&m_local);
if((m_en.z || m_en.f) && !m_sel.sprite || m_en.t || m_en.c && m_sel.iip)
if((m_en.z || m_en.f) && m_sel.prim != GS_SPRITE_CLASS || m_en.t || m_en.c && m_sel.iip)
{
for(int i = 0; i < 5; i++)
{
@ -65,7 +65,7 @@ void GSSetupPrimCodeGenerator::Depth()
return;
}
if(!m_sel.sprite)
if(m_sel.prim != GS_SPRITE_CLASS)
{
// GSVector4 p = dscan.p;
@ -96,7 +96,9 @@ void GSSetupPrimCodeGenerator::Depth()
cvttps2dq(xmm2, xmm2);
pshuflw(xmm2, xmm2, _MM_SHUFFLE(2, 2, 0, 0));
pshufhw(xmm2, xmm2, _MM_SHUFFLE(2, 2, 0, 0));
movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].f)], xmm2);
const size_t variableOffset = offsetof(GSScanlineLocalData, d[0].f) + (i * sizeof(GSScanlineLocalData::d[0]));
movdqa(ptr[r8 + variableOffset], xmm2);
}
}
@ -118,7 +120,9 @@ void GSSetupPrimCodeGenerator::Depth()
movaps(xmm1, xmm0);
mulps(xmm1, Xmm(4 + i));
movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].z)], xmm1);
const size_t variableOffset = offsetof(GSScanlineLocalData, d[0].z) + (i * sizeof(GSScanlineLocalData::d[0]));
movdqa(ptr[r8 + variableOffset], xmm1);
}
}
}
@ -226,21 +230,28 @@ void GSSetupPrimCodeGenerator::Texture()
cvttps2dq(xmm2, xmm2);
const size_t variableOffsetS = offsetof(GSScanlineLocalData, d[0].s) + (i * sizeof(GSScanlineLocalData::d[0]));
const size_t variableOffsetT = offsetof(GSScanlineLocalData, d[0].t) + (i * sizeof(GSScanlineLocalData::d[0]));
switch(j)
{
case 0: movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].si)], xmm2); break;
case 1: movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].ti)], xmm2); break;
case 0: movdqa(ptr[r8 + variableOffsetS], xmm2); break;
case 1: movdqa(ptr[r8 + variableOffsetT], xmm2); break;
}
}
else
{
// m_local.d[i].s/t/q = v;
const size_t variableOffsetS = offsetof(GSScanlineLocalData, d[0].s) + (i * sizeof(GSScanlineLocalData::d[0]));
const size_t variableOffsetT = offsetof(GSScanlineLocalData, d[0].t) + (i * sizeof(GSScanlineLocalData::d[0]));
const size_t variableOffsetQ = offsetof(GSScanlineLocalData, d[0].q) + (i * sizeof(GSScanlineLocalData::d[0]));
switch(j)
{
case 0: movaps(ptr[r8 + offsetof(GSScanlineLocalData, d[i].s)], xmm2); break;
case 1: movaps(ptr[r8 + offsetof(GSScanlineLocalData, d[i].t)], xmm2); break;
case 2: movaps(ptr[r8 + offsetof(GSScanlineLocalData, d[i].q)], xmm2); break;
case 0: movaps(ptr[r8 + variableOffsetS], xmm2); break;
case 1: movaps(ptr[r8 + variableOffsetT], xmm2); break;
case 2: movaps(ptr[r8 + variableOffsetQ], xmm2); break;
}
}
}
@ -297,7 +308,9 @@ void GSSetupPrimCodeGenerator::Color()
// m_local.d[i].rb = r.upl16(b);
punpcklwd(xmm2, xmm3);
movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].rb)], xmm2);
const size_t variableOffset = offsetof(GSScanlineLocalData, d[0].rb) + (i * sizeof(GSScanlineLocalData::d[0]));
movdqa(ptr[r8 + variableOffset], xmm2);
}
// GSVector4 c = dscan.c;
@ -330,7 +343,9 @@ void GSSetupPrimCodeGenerator::Color()
// m_local.d[i].ga = g.upl16(a);
punpcklwd(xmm2, xmm3);
movdqa(ptr[r8 + offsetof(GSScanlineLocalData, d[i].ga)], xmm2);
const size_t variableOffset = offsetof(GSScanlineLocalData, d[0].ga) + (i * sizeof(GSScanlineLocalData::d[0]));
movdqa(ptr[r8 + variableOffset], xmm2);
}
}
else
@ -362,4 +377,4 @@ void GSSetupPrimCodeGenerator::Color()
}
}
#endif
#endif