zzogl-pg: More changes to the new register code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3444 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-10 06:04:32 +00:00
parent dd100a775e
commit f07f522238
9 changed files with 164 additions and 179 deletions

View File

@ -635,6 +635,7 @@ typedef struct
int imageWnew, imageHnew, imageX, imageY, imageEndX, imageEndY;
pathInfo path[3];
GIFRegDIMX dimx;
void setRGBA(u32 r, u32 g, u32 b, u32 a)
{
rgba = (r & 0xff) |
@ -643,6 +644,24 @@ typedef struct
((a & 0xff) << 24);
}
void add_vertex(u16 x, u16 y, u32 z, float f)
{
vertexregs.x = x;
vertexregs.y = y;
vertexregs.z = z;
vertexregs.f = f;
gsvertex[primIndex] = vertexregs;
primIndex = (primIndex + 1) % ARRAY_SIZE(gsvertex);
}
void add_vertex(u16 x, u16 y, u32 z)
{
vertexregs.x = x;
vertexregs.y = y;
vertexregs.z = z;
gsvertex[primIndex] = vertexregs;
primIndex = (primIndex + 1) % ARRAY_SIZE(gsvertex);
}
} GSinternal;
extern GSinternal gs;

View File

@ -140,13 +140,7 @@ void __fastcall GIFPackedRegHandlerXYZF2(u32* data)
{
FUNCLOG
GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.vertexregs.f = r->F;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ArraySize(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z, r->F);
// Fix Vertexes up later.
if (data[3] & 0x8000)
@ -163,11 +157,7 @@ void __fastcall GIFPackedRegHandlerXYZ2(u32* data)
{
FUNCLOG
GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ArraySize(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z);
// Fix Vertexes up later.
if (data[3] & 0x8000)
@ -203,6 +193,7 @@ void __fastcall GIFPackedRegHandlerNOP(u32* data)
void tex0Write(int i, u32 *data)
{
FUNCLOG
GIFRegTEX0* r = (GIFRegTEX0*)(data);
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
if (m_Blocks[psm].bpp == 0)
@ -211,6 +202,9 @@ void tex0Write(int i, u32 *data)
return;
}
//ZeroGS::vb[i].uCurTex0.i64 = r->i64;
// ZeroGS::vb[i].uNextTex0Data[0] = r->ai32[0];
// ZeroGS::vb[i].uNextTex0Data[1] = r->ai32[1];
ZeroGS::vb[i].uNextTex0Data[0] = data[0];
ZeroGS::vb[i].uNextTex0Data[1] = data[1];
ZeroGS::vb[i].bNeedTexCheck = 1;
@ -224,10 +218,10 @@ void tex0Write(int i, u32 *data)
// loading clut, so flush whole texture
ZeroGS::vb[i].FlushTexData();
}
// check if csa is the same!! (ffx bisaid island, grass)
// else if (r->CSA != (ZeroGS::vb[i].uCurTex0.CSA))
else if ((data[1] & 0x1f780000) != (ZeroGS::vb[i].uCurTex0Data[1] & 0x1f780000))
{
// check if csa is the same!! (ffx bisaid island, grass)
ZeroGS::Flush(i); // flush any previous entries
}
}
@ -238,7 +232,7 @@ void tex2Write(int i, u32 *data)
FUNCLOG
tex0Info& tex0 = ZeroGS::vb[i].tex0;
if (ZeroGS::vb[i].bNeedTexCheck) ZeroGS::vb[i].FlushTexData();
ZeroGS::vb[i].FlushTexData();
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
@ -310,22 +304,12 @@ __forceinline void testWrite(int i, u32 *data)
pixTest* test = &ZeroGS::vb[i].test;
GIFRegTEST* r = (GIFRegTEST*)(data);
if ((*(u32*)test & 0x0007ffff) == (data[0] & 0x0007ffff)) return;
if (test->_val != r->ai32[0])
{
ZeroGS::Flush(i);
}
//test = (pixTest*)data;
test->_val = r->ai32[0];
// test->ate = r->ATE;
// test->atst = r->ATST;
// test->aref = r->AREF;
// test->afail = r->AFAIL;
// test->date = r->DATE;
// test->datm = r->DATM;
// test->zte = r->ZTE;
}
void clampWrite(int i, u32 *data)
@ -337,6 +321,10 @@ void clampWrite(int i, u32 *data)
if ((s_uClampData[i] != data[0]) || (((clamp.minv >> 8) | (clamp.maxv << 2)) != (data[1]&0x0fff)))
{
ZeroGS::Flush(i);
ZeroGS::vb[i].bTexConstsSync = false;
}
s_uClampData[i] = data[0];
clamp.wms = r->WMS;
@ -345,9 +333,6 @@ void clampWrite(int i, u32 *data)
clamp.maxu = r->MAXU;
clamp.minv = r->MINV;
clamp.maxv = r->MAXV;
ZeroGS::vb[i].bTexConstsSync = false;
}
}
void __fastcall GIFRegHandlerNull(u32* data)
@ -406,6 +391,7 @@ void __fastcall GIFRegHandlerST(u32* data)
void __fastcall GIFRegHandlerUV(u32* data)
{
// Baroque breaks if u&v are 16 bits instead of 14.
FUNCLOG
GIFRegUV* r = (GIFRegUV*)(data);
gs.vertexregs.u = r->U;
@ -416,12 +402,7 @@ void __fastcall GIFRegHandlerXYZF2(u32* data)
{
FUNCLOG
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.vertexregs.f = r->F;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ARRAY_SIZE(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z, r->F);
KICK_VERTEX2();
}
@ -430,11 +411,7 @@ void __fastcall GIFRegHandlerXYZ2(u32* data)
{
FUNCLOG
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ARRAY_SIZE(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z);
KICK_VERTEX2();
}
@ -490,12 +467,7 @@ void __fastcall GIFRegHandlerXYZF3(u32* data)
{
FUNCLOG
GIFRegXYZF* r = (GIFRegXYZF*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.vertexregs.f = r->F;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ARRAY_SIZE(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z, r->F);
KICK_VERTEX3();
}
@ -504,11 +476,7 @@ void __fastcall GIFRegHandlerXYZ3(u32* data)
{
FUNCLOG
GIFRegXYZ* r = (GIFRegXYZ*)(data);
gs.vertexregs.x = r->X;
gs.vertexregs.y = r->Y;
gs.vertexregs.z = r->Z;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex + 1) % ARRAY_SIZE(gs.gsvertex);
gs.add_vertex(r->X, r->Y,r->Z);
KICK_VERTEX3();
}
@ -613,8 +581,8 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data)
FUNCLOG
GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data);
if (ZeroGS::vb[0].bNeedTexCheck) ZeroGS::vb[0].FlushTexData();
if (ZeroGS::vb[1].bNeedTexCheck) ZeroGS::vb[1].FlushTexData();
ZeroGS::vb[0].FlushTexData();
ZeroGS::vb[1].FlushTexData();
// Fixme.
gs.clut.cbw = r->CBW << 6;
@ -760,10 +728,11 @@ void __fastcall GIFRegHandlerSCISSOR_1(u32* data)
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
{
ZeroGS::Flush(0);
scissor = newscissor;
ZeroGS::vb[0].bNeedFrameCheck = 1;
}
scissor = newscissor;
//Hmm...
/*
if(PRIM->CTXT == i && r->SCISSOR != m_env.CTXT[i].SCISSOR)
@ -794,86 +763,96 @@ void __fastcall GIFRegHandlerSCISSOR_2(u32* data)
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
{
ZeroGS::Flush(1);
scissor = newscissor;
// flush everything
ZeroGS::vb[1].bNeedFrameCheck = 1;
}
scissor = newscissor;
}
void __fastcall GIFRegHandlerALPHA_1(u32* data)
{
FUNCLOG
// Another tangled one. Mess with this later.
alphaInfo newalpha;
newalpha.abcd = *(u8*)data;
newalpha.fix = *(u8*)(data + 1);
if (*(u16*)&newalpha != *(u16*)&ZeroGS::vb[0].alpha)
{
ZeroGS::Flush(0);
GIFRegALPHA* r = (GIFRegALPHA*)(data);
alphaInfo newalpha;
newalpha.a = r->A;
newalpha.b = r->B;
newalpha.c = r->C;
newalpha.d = r->D;
newalpha.fix = r->FIX;
if (newalpha.a == 3) newalpha.a = 0;
if (newalpha.b == 3) newalpha.b = 0;
if (newalpha.c == 3) newalpha.c = 0;
if (newalpha.d == 3) newalpha.d = 0;
*(u16*)&ZeroGS::vb[0].alpha = *(u16*) & newalpha;
if ((newalpha.abcd != ZeroGS::vb[0].alpha.abcd) || (newalpha.fix != ZeroGS::vb[0].alpha.fix))
{
ZeroGS::Flush(0);
}
ZeroGS::vb[0].alpha = newalpha;
}
void __fastcall GIFRegHandlerALPHA_2(u32* data)
{
FUNCLOG
// ...
GIFRegALPHA* r = (GIFRegALPHA*)(data);
alphaInfo newalpha;
newalpha.abcd = *(u8*)data;
newalpha.fix = *(u8*)(data + 1);
if (*(u16*)&newalpha != *(u16*)&ZeroGS::vb[1].alpha)
{
ZeroGS::Flush(1);
newalpha.a = r->A;
newalpha.b = r->B;
newalpha.c = r->C;
newalpha.d = r->D;
newalpha.fix = r->FIX;
if (newalpha.a == 3) newalpha.a = 0;
if (newalpha.b == 3) newalpha.b = 0;
if (newalpha.c == 3) newalpha.c = 0;
if (newalpha.d == 3) newalpha.d = 0;
*(u16*)&ZeroGS::vb[1].alpha = *(u16*) & newalpha;
if ((newalpha.abcd != ZeroGS::vb[1].alpha.abcd) || (newalpha.fix != ZeroGS::vb[1].alpha.fix))
{
ZeroGS::Flush(1);
}
ZeroGS::vb[1].alpha = newalpha;
}
void __fastcall GIFRegHandlerDIMX(u32* data)
{
FUNCLOG
GIFRegDIMX* r = (GIFRegDIMX*)(data);
// Not even handled? Fixme.
/*
bool update = false;
if(r->DIMX != m_env.DIMX)
if (r->i64 != gs.dimx.i64)
{
Flush();
ZeroGS::FlushBoth();
update = true;
}
m_env.DIMX = (GSVector4i)r->DIMX;
gs.dimx.i64 = r->i64;
if(update)
if (update)
{
m_env.UpdateDIMX();
}*/
//gs.UpdateDIMX();
}
}
void __fastcall GIFRegHandlerDTHE(u32* data)
{
FUNCLOG
GIFRegDTHE* r = (GIFRegDTHE*)(data);
// Flush me.
if (r->DTHE != gs.dthe)
{
ZeroGS::FlushBoth();
}
gs.dthe = r->DTHE;
}
@ -886,6 +865,7 @@ void __fastcall GIFRegHandlerCOLCLAMP(u32* data)
{
ZeroGS::FlushBoth();
}
gs.colclamp = r->CLAMP;
}
@ -905,11 +885,12 @@ void __fastcall GIFRegHandlerPABE(u32* data)
{
FUNCLOG
GIFRegPABE* r = (GIFRegPABE*)(data);
//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
if (gs.pabe != r->PABE)
{
ZeroGS::FlushBoth();
// ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
// ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
}
gs.pabe = r->PABE;
@ -924,6 +905,7 @@ void __fastcall GIFRegHandlerFBA_1(u32* data)
{
ZeroGS::FlushBoth();
}
ZeroGS::vb[0].fba.fba = r->FBA;
}
@ -1052,9 +1034,6 @@ void __fastcall GIFRegHandlerTRXPOS(u32* data)
gs.trxposnew.sy = r->SSAY;
gs.trxposnew.dx = r->DSAX;
gs.trxposnew.dy = r->DSAY;
//Fixme. DIRY & DIRX together?
//gs.trxposnew.dir = (data[1] >> 27) & 0x3;
gs.trxposnew.dirx = r->DIRX;
gs.trxposnew.diry = r->DIRY;
}
@ -1153,14 +1132,9 @@ void __fastcall GIFRegHandlerSIGNAL(u32* data)
{
SIGLBLID->SIGID = (SIGLBLID->SIGID & ~data[1]) | (data[0] & data[1]);
// if (gs.CSRw & 0x1) CSR->SIGNAL = 1;
// if (!IMR->SIGMSK && GSirq)
// GSirq();
if (gs.CSRw & 0x1)
{
CSR->SIGNAL = 1;
//gs.CSRw &= ~1;
}
if (!IMR->SIGMSK && GSirq) GSirq();
@ -1176,17 +1150,6 @@ void __fastcall GIFRegHandlerFINISH(u32* data)
if (gs.CSRw & 0x2) CSR->FINISH = 1;
if (!IMR->FINISHMSK && GSirq) GSirq();
// if( gs.CSRw & 2 ) {
// //gs.CSRw &= ~2;
// //CSR->FINISH = 0;
//
//
// }
// CSR->FINISH = 1;
//
// if( !IMR->FINISHMSK && GSirq )
// GSirq();
}
}

View File

@ -575,21 +575,19 @@ REG64_(GIFReg, TRXREG)
u32 _PAD2:20;
REG_END
// GSState::GIFPackedRegHandlerUV and GSState::GIFRegHandlerUV will make sure that the _PAD1/2 bits are set to zero
REG64_(GIFReg, UV)
u32 U:16;
// u32 _PAD1:2;
u32 V:16;
// u32 _PAD2:2;
u32 U:14;
u32 _PAD1:2;
u32 V:14;
u32 _PAD2:2;
u32 _PAD3:32;
REG_END
// GSState::GIFRegHandlerXYOFFSET will make sure that the _PAD1/2 bits are set to zero
REG64_(GIFReg, XYOFFSET)
u32 OFX; // :16; u32 _PAD1:16;
u32 OFY; // :16; u32 _PAD2:16;
u32 OFX:16;
u32 _PAD1:16;
u32 OFY:16;
u32 _PAD2:16;
REG_END
REG64_(GIFReg, XYZ)

View File

@ -256,7 +256,7 @@ void tex2Write(int i, u32 *data)
FUNCLOG
tex0Info& tex0 = ZeroGS::vb[i].tex0;
if (ZeroGS::vb[i].bNeedTexCheck) ZeroGS::vb[i].FlushTexData();
ZeroGS::vb[i].FlushTexData();
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
@ -621,8 +621,8 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data)
{
FUNCLOG
if (ZeroGS::vb[0].bNeedTexCheck) ZeroGS::vb[0].FlushTexData();
if (ZeroGS::vb[1].bNeedTexCheck) ZeroGS::vb[1].FlushTexData();
ZeroGS::vb[0].FlushTexData();
ZeroGS::vb[1].FlushTexData();
gs.clut.cbw = ((data[0]) & 0x3f) * 64;
gs.clut.cou = ((data[0] >> 6) & 0x3f) * 16;

View File

@ -163,9 +163,8 @@ static Vector vAlphaBlendColor; // used for GPU_COLOR
static bool bNeedBlendFactorInAlpha; // set if the output source alpha is different from the real source alpha (only when blend factor > 0x80)
static u32 s_dwColorWrite = 0xf; // the color write mask of the current target
union
typedef union
{
struct
{
u8 _bNeedAlphaColor; // set if vAlphaBlendColor needs to be set
@ -176,7 +175,9 @@ union
};
u32 _bAlphaState;
} g_vars;
} g_flag_vars;
g_flag_vars g_vars;
//#define bNeedAlphaColor g_vars._bNeedAlphaColor
#define b2XAlphaTest g_vars._b2XAlphaTest
@ -399,7 +400,7 @@ inline void FlushTransferRangesHelper(VB& curvb)
}
}
// If set bit for texture cheking, do it. Maybe it's all.
// If set bit for texture checking, do it. Maybe it's all.
inline bool FushTexDataHelper(VB& curvb)
{
if (curvb.bNeedFrameCheck || curvb.bNeedZCheck)

View File

@ -124,6 +124,8 @@ void SetupFragmentProgramParameters(FRAGMENTSHADER* pf, int context, int type)
pf->set_shader_const(Vector(1 / 1024.0f, 0.2f / 1024.0f, 1 / 128.0f, 1 / 512.0f), "g_fMult");
}
static bool outdated_shaders = false;
void SetupVertexProgramParameters(CGprogram prog, int context)
{
CGparameter p;
@ -160,9 +162,13 @@ void SetupVertexProgramParameters(CGprogram prog, int context)
}
else
{
if (!outdated_shaders)
{
outdated_shaders = true;
ZZLog::Error_Log("Shader file version is outdated! Only log-Z is possible.");
}
}
}
Vector vnorm = Vector(g_filog32, 0, 0, 0);

View File

@ -457,7 +457,9 @@ void ZeroGS::VB::FlushTexData()
{
GL_REPORT_ERRORD();
assert(bNeedTexCheck);
//assert(bNeedTexCheck);
//if (bNeedTexCheck)
{
bNeedTexCheck = 0;
u32 psm = ZZOglGet_psm_TexBitsFix(uNextTex0Data[0]);
@ -497,4 +499,5 @@ void ZeroGS::VB::FlushTexData()
if (PSMT_ISCLUT(psm)) ZeroGS::CluttingForFlushedTex(&tex0, uNextTex0Data[1], ictx) ;
GL_REPORT_ERRORD();
}
}

View File

@ -619,15 +619,6 @@ void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
int index = Index;
p->x = ((((int)gs.gsvertex[index].x - curvb.offset.x) >> 1) & 0xffff);
p->y = ((((int)gs.gsvertex[index].y - curvb.offset.y) >> 1) & 0xffff);
#ifdef LSD_MODE
int diffX = (int)gs.gsvertex[index].x - curvb.offset.x;
int diffY = (int)gs.gsvertex[index].y - curvb.offset.y;
if (diffX < 0) { p->x = - p->x; }
if (diffY < 0) { p->y = - p->y; }
#endif
p->f = ((s16)gs.gsvertex[index].f << 7) | 0x7f;
MOVZ(p, gs.gsvertex[index].z, curvb);
@ -678,7 +669,7 @@ void ZeroGS::KickPoint()
VB& curvb = vb[prim->ctxt];
if (curvb.bNeedTexCheck) curvb.FlushTexData();
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
@ -703,7 +694,7 @@ void ZeroGS::KickLine()
assert(gs.primC >= 2);
VB& curvb = vb[prim->ctxt];
if (curvb.bNeedTexCheck) curvb.FlushTexData();
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
@ -732,7 +723,7 @@ void ZeroGS::KickTriangle()
assert(gs.primC >= 3);
VB& curvb = vb[prim->ctxt];
if (curvb.bNeedTexCheck) curvb.FlushTexData();
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
@ -760,7 +751,7 @@ void ZeroGS::KickTriangleFan()
assert(gs.primC >= 3);
VB& curvb = vb[prim->ctxt];
if (curvb.bNeedTexCheck) curvb.FlushTexData();
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{
@ -799,7 +790,7 @@ void ZeroGS::KickSprite()
assert(gs.primC >= 2);
VB& curvb = vb[prim->ctxt];
if (curvb.bNeedTexCheck) curvb.FlushTexData();
curvb.FlushTexData();
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
{

View File

@ -409,7 +409,11 @@ public:
frameInfo frame;
int zprimmask; // zmask for incoming points
union
{
u32 uCurTex0Data[2]; // current tex0 data
GIFRegTEX0 uCurTex0;
};
u32 uNextTex0Data[2]; // tex0 data that has to be applied if bNeedTexCheck is 1
//int nFrameHeights[8]; // frame heights for the past frame changes