GregMiscellaneous: zzogl-pg: Give VB its own header. Some changes to the Kick functions.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3961 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-10-23 08:15:39 +00:00
parent c544ec7ca6
commit 465dd47bde
18 changed files with 333 additions and 296 deletions

View File

@ -179,6 +179,8 @@ extern int g_PrevBitwiseTexX, g_PrevBitwiseTexY;
void tex0Write(int i, u32 *data) void tex0Write(int i, u32 *data)
{ {
if (!NoHighlights(i)) return;
u32 psm = (data[0] >> 20) & 0x3f; u32 psm = (data[0] >> 20) & 0x3f;
if( psm == 9 ) psm = 1; // hmm..., ffx intro menu if( psm == 9 ) psm = 1; // hmm..., ffx intro menu
@ -340,6 +342,8 @@ __forceinline void testWrite(int i, u32 *data)
__forceinline void clampWrite(int i, u32 *data) __forceinline void clampWrite(int i, u32 *data)
{ {
if (!NoHighlights(i)) return;
clampInfo& clamp = ZeroGS::vb[i].clamp; clampInfo& clamp = ZeroGS::vb[i].clamp;
if( s_uClampData[i] != data[0] || ((clamp.minv>>8)|(clamp.maxv<<2)) != (data[1]&0x0fff) ) { if( s_uClampData[i] != data[0] || ((clamp.minv>>8)|(clamp.maxv<<2)) != (data[1]&0x0fff) ) {
@ -500,6 +504,8 @@ void __fastcall GIFRegHandlerNOP(u32* data)
void tex1Write(int i, u32* data) void tex1Write(int i, u32* data)
{ {
if (!NoHighlights(i)) return;
tex1Info& tex1 = ZeroGS::vb[i].tex1; tex1Info& tex1 = ZeroGS::vb[i].tex1;
if( conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7)) ) { if( conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7)) ) {

View File

@ -105,6 +105,7 @@ set(zzoglHeaders
ZZoglMath.h ZZoglMath.h
ZZoglShaders.h ZZoglShaders.h
ZZoglShoots.h ZZoglShoots.h
ZZoglVB.h
) )
# zzogl S sources # zzogl S sources

View File

@ -40,6 +40,19 @@ struct Vector_16F
// PS2 vertex // PS2 vertex
// Almost same as VertexGPU, controlled by prim.fst flags
struct Vertex
{
u16 x, y, f, resv0; // note: xy is 12d3
u32 rgba;
u32 z;
float s, t, q;
// Texel coordinate of vertex. Used if prim.fst == 1
// Bits 0-14 and 16-30 of UV
u16 u, v;
};
struct VertexGPU struct VertexGPU
{ {
// gained from XYZ2, XYZ3, XYZF2, XYZF3, // gained from XYZ2, XYZ3, XYZF2, XYZF3,
@ -53,19 +66,26 @@ struct VertexGPU
// Texture coordinates. S & T going from ST register (bits 0-31, and 32-63). // Texture coordinates. S & T going from ST register (bits 0-31, and 32-63).
// Q goes from RGBAQ register, bits 32-63 // Q goes from RGBAQ register, bits 32-63
float s, t, q; float s, t, q;
};
void move_x(Vertex v, int offset)
{
x = ((((int)v.x - offset) >> 1) & 0xffff);
}
void move_y(Vertex v, int offset)
{
y = ((((int)v.y - offset) >> 1) & 0xffff);
}
void move_z(Vertex v, int mask)
{
z = (mask == 0xffff) ? min((u32)0xffff, v.z) : v.z;
}
// Almost same as previous, controlled by prim.fst flags void move_fog(Vertex v)
{
struct Vertex f = ((s16)(v).f << 7) | 0x7f;
{ }
u16 x, y, f, resv0; // note: xy is 12d3
u32 rgba;
u32 z;
float s, t, q;
// Texel coordinate of vertex. Used if prim.fst == 1
// Bits 0-14 and 16-30 of UV
u16 u, v;
}; };
extern GSconf conf; extern GSconf conf;

View File

@ -25,6 +25,7 @@
#include "Mem.h" #include "Mem.h"
#include "x86.h" #include "x86.h"
#include "targets.h" #include "targets.h"
#include "ZZoglVB.h"
// flush current vertices, call before setting new registers (the main render method) // flush current vertices, call before setting new registers (the main render method)
extern void Flush(int context); extern void Flush(int context);

View File

@ -98,8 +98,6 @@
<Mode after="always" /> <Mode after="always" />
</ExtraCommands> </ExtraCommands>
<Unit filename="../../CRC.h" /> <Unit filename="../../CRC.h" />
<Unit filename="../../ZZClut.cpp" />
<Unit filename="../../ZZClut.h" />
<Unit filename="../../GLWin.h" /> <Unit filename="../../GLWin.h" />
<Unit filename="../../GLWin32.cpp" /> <Unit filename="../../GLWin32.cpp" />
<Unit filename="../../GLWinX11.cpp" /> <Unit filename="../../GLWinX11.cpp" />
@ -145,6 +143,8 @@
<Option compile="0" /> <Option compile="0" />
<Option link="0" /> <Option link="0" />
</Unit> </Unit>
<Unit filename="../../ZZClut.cpp" />
<Unit filename="../../ZZClut.h" />
<Unit filename="../../ZZGl.h" /> <Unit filename="../../ZZGl.h" />
<Unit filename="../../ZZKeyboard.cpp" /> <Unit filename="../../ZZKeyboard.cpp" />
<Unit filename="../../ZZKick.cpp" /> <Unit filename="../../ZZKick.cpp" />
@ -164,6 +164,7 @@
<Unit filename="../../ZZoglShoots.cpp" /> <Unit filename="../../ZZoglShoots.cpp" />
<Unit filename="../../ZZoglShoots.h" /> <Unit filename="../../ZZoglShoots.h" />
<Unit filename="../../ZZoglVB.cpp" /> <Unit filename="../../ZZoglVB.cpp" />
<Unit filename="../../ZZoglVB.h" />
<Unit filename="../../common.h" /> <Unit filename="../../common.h" />
<Unit filename="../../glprocs.c"> <Unit filename="../../glprocs.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />

View File

@ -23,6 +23,7 @@
#include "PS2Etypes.h" #include "PS2Etypes.h"
#include "targets.h" #include "targets.h"
#include "ZZoglVB.h"
#include "ZZKick.h" #include "ZZKick.h"
#ifdef USE_OLD_REGS #ifdef USE_OLD_REGS
@ -95,11 +96,11 @@ void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
if (data[3] & 0x8000) if (data[3] & 0x8000)
{ {
KICK_VERTEX3(); ZZKick->KickVERTEX3();
} }
else else
{ {
KICK_VERTEX2(); ZZKick->KickVERTEX2();
} }
} }
@ -114,11 +115,11 @@ void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
if (data[3] & 0x8000) if (data[3] & 0x8000)
{ {
KICK_VERTEX3(); ZZKick->KickVERTEX3();
} }
else else
{ {
KICK_VERTEX2(); ZZKick->KickVERTEX2();
} }
} }
@ -146,6 +147,9 @@ void __gifCall GIFPackedRegHandlerNOP(const u32* data)
void tex0Write(int i, const u32 *data) void tex0Write(int i, const u32 *data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(i)) return;
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]); u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
if (m_Blocks[psm].bpp == 0) if (m_Blocks[psm].bpp == 0)
@ -274,6 +278,9 @@ __forceinline
void clampWrite(int i, const u32 *data) void clampWrite(int i, const u32 *data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(i)) return;
clampInfo& clamp = vb[i].clamp; clampInfo& clamp = vb[i].clamp;
if ((s_uClampData[i] != data[0]) || (((clamp.minv >> 8) | (clamp.maxv << 2)) != (data[1]&0x0fff))) if ((s_uClampData[i] != data[0]) || (((clamp.minv >> 8) | (clamp.maxv << 2)) != (data[1]&0x0fff)))
@ -361,7 +368,7 @@ void __gifCall GIFRegHandlerXYZF2(const u32* data)
gs.gsvertex[gs.primIndex] = gs.vertexregs; gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = gs.primNext(); gs.primIndex = gs.primNext();
KICK_VERTEX2(); ZZKick->KickVERTEX2();
} }
void __gifCall GIFRegHandlerXYZ2(const u32* data) void __gifCall GIFRegHandlerXYZ2(const u32* data)
@ -373,24 +380,20 @@ void __gifCall GIFRegHandlerXYZ2(const u32* data)
gs.gsvertex[gs.primIndex] = gs.vertexregs; gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = gs.primNext(); gs.primIndex = gs.primNext();
KICK_VERTEX2(); ZZKick->KickVERTEX2();
} }
void __gifCall GIFRegHandlerTEX0_1(const u32* data) void __gifCall GIFRegHandlerTEX0_1(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(0)) return;
tex0Write(0, data); tex0Write(0, data);
} }
void __gifCall GIFRegHandlerTEX0_2(const u32* data) void __gifCall GIFRegHandlerTEX0_2(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(1)) return;
tex0Write(1, data); tex0Write(1, data);
} }
@ -398,8 +401,6 @@ void __gifCall GIFRegHandlerCLAMP_1(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(0)) return;
clampWrite(0, data); clampWrite(0, data);
} }
@ -407,8 +408,6 @@ void __gifCall GIFRegHandlerCLAMP_2(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(1)) return;
clampWrite(1, data); clampWrite(1, data);
} }
@ -429,7 +428,7 @@ void __gifCall GIFRegHandlerXYZF3(const u32* data)
gs.gsvertex[gs.primIndex] = gs.vertexregs; gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = gs.primNext(); gs.primIndex = gs.primNext();
KICK_VERTEX3(); ZZKick->KickVERTEX3();
} }
void __gifCall GIFRegHandlerXYZ3(const u32* data) void __gifCall GIFRegHandlerXYZ3(const u32* data)
@ -441,7 +440,7 @@ void __gifCall GIFRegHandlerXYZ3(const u32* data)
gs.gsvertex[gs.primIndex] = gs.vertexregs; gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = gs.primNext(); gs.primIndex = gs.primNext();
KICK_VERTEX3(); ZZKick->KickVERTEX3();
} }
void __gifCall GIFRegHandlerNOP(const u32* data) void __gifCall GIFRegHandlerNOP(const u32* data)
@ -452,6 +451,9 @@ void __gifCall GIFRegHandlerNOP(const u32* data)
void tex1Write(int i, const u32* data) void tex1Write(int i, const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(i)) return;
tex1Info& tex1 = vb[i].tex1; tex1Info& tex1 = vb[i].tex1;
if (conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7))) if (conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7)))
@ -461,7 +463,6 @@ void tex1Write(int i, const u32* data)
} }
tex1.lcm = (data[0]) & 0x1; tex1.lcm = (data[0]) & 0x1;
tex1.mxl = (data[0] >> 2) & 0x7; tex1.mxl = (data[0] >> 2) & 0x7;
tex1.mmag = (data[0] >> 5) & 0x1; tex1.mmag = (data[0] >> 5) & 0x1;
tex1.mmin = (data[0] >> 6) & 0x7; tex1.mmin = (data[0] >> 6) & 0x7;
@ -473,9 +474,7 @@ void tex1Write(int i, const u32* data)
void __gifCall GIFRegHandlerTEX1_1(const u32* data) void __gifCall GIFRegHandlerTEX1_1(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(0)) return;
tex1Write(0, data); tex1Write(0, data);
} }
@ -483,20 +482,20 @@ void __gifCall GIFRegHandlerTEX1_2(const u32* data)
{ {
FUNCLOG FUNCLOG
if (!NoHighlights(1)) return;
tex1Write(1, data); tex1Write(1, data);
} }
void __gifCall GIFRegHandlerTEX2_1(const u32* data) void __gifCall GIFRegHandlerTEX2_1(const u32* data)
{ {
FUNCLOG FUNCLOG
tex2Write(0, data); tex2Write(0, data);
} }
void __gifCall GIFRegHandlerTEX2_2(const u32* data) void __gifCall GIFRegHandlerTEX2_2(const u32* data)
{ {
FUNCLOG FUNCLOG
tex2Write(1, data); tex2Write(1, data);
} }

View File

@ -18,7 +18,9 @@
*/ */
#include "ZZKick.h" #include "ZZKick.h"
#include "targets.h" #include "ZZoglVB.h"
Kick* ZZKick;
const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff }; const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff };
const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 }; const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
@ -27,35 +29,6 @@ const GLenum primtype[8] = { GL_POINTS, GL_LINES, GL_LINES, GL_TRIANGLES, GL_TRI
extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
KickDummy, KickDummy, KickDummy, KickDummy
};
void init_drawfn()
{
drawfn[0] = KickPoint;
drawfn[1] = KickLine;
drawfn[2] = KickLine;
drawfn[3] = KickTriangle;
drawfn[4] = KickTriangle;
drawfn[5] = KickTriangleFan;
drawfn[6] = KickSprite;
drawfn[7] = KickDummy;
}
void clear_drawfn()
{
drawfn[0] = KickDummy;
drawfn[1] = KickDummy;
drawfn[2] = KickDummy;
drawfn[3] = KickDummy;
drawfn[4] = KickDummy;
drawfn[5] = KickDummy;
drawfn[6] = KickDummy;
drawfn[7] = KickDummy;
}
// Still thinking about the best place to put this. // Still thinking about the best place to put this.
// called on a primitive switch // called on a primitive switch
void Prim() void Prim()
@ -70,16 +43,6 @@ void Prim()
curvb.curprim.prim = prim->prim; curvb.curprim.prim = prim->prim;
} }
__forceinline void MOVZ(VertexGPU *p, u32 gsz, const VB& curvb)
{
p->z = (curvb.zprimmask == 0xffff) ? min((u32)0xffff, gsz) : gsz;
}
__forceinline void MOVFOG(VertexGPU *p, Vertex gsf)
{
p->f = ((s16)(gsf).f << 7) | 0x7f;
}
// return true if triangle SHOULD be painted. // return true if triangle SHOULD be painted.
// Hackish and should be replaced. // Hackish and should be replaced.
bool __forceinline NoHighlights(int i) bool __forceinline NoHighlights(int i)
@ -100,19 +63,19 @@ bool __forceinline NoHighlights(int i)
return (!(conf.settings().xenosaga_spec) || !vb[i].zbuf.zmsk || prim->iip) ; return (!(conf.settings().xenosaga_spec) || !vb[i].zbuf.zmsk || prim->iip) ;
} }
void __forceinline KICK_VERTEX2() void __forceinline Kick::KickVERTEX2()
{ {
FUNCLOG FUNCLOG
if (++gs.primC >= (int)g_primmult[prim->prim]) if (++gs.primC >= (int)g_primmult[prim->prim])
{ {
if (NoHighlights(prim->ctxt)) (*drawfn[prim->prim])(); if (NoHighlights(prim->ctxt)) ZZKick->fn(prim->prim);
gs.primC -= g_primsub[prim->prim]; gs.primC -= g_primsub[prim->prim];
} }
} }
void __forceinline KICK_VERTEX3() void __forceinline Kick::KickVERTEX3()
{ {
FUNCLOG FUNCLOG
@ -123,50 +86,40 @@ void __forceinline KICK_VERTEX3()
if (prim->prim == 5) if (prim->prim == 5)
{ {
/* tri fans need special processing */ /* tri fans need special processing */
if (gs.nTriFanVert == gs.primIndex) if (gs.nTriFanVert == gs.primIndex) gs.primIndex = gs.primNext();
gs.primIndex = gs.primNext();
} }
} }
} }
void __forceinline KickVertex(bool adc) void __forceinline Kick::KickVertex(bool adc)
{ {
FUNCLOG FUNCLOG
if (++gs.primC >= (int)g_primmult[prim->prim]) if (++gs.primC >= (int)g_primmult[prim->prim])
{ {
if (!adc && NoHighlights(prim->ctxt)) (*drawfn[prim->prim])(); if (!adc && NoHighlights(prim->ctxt)) fn(prim->prim);
gs.primC -= g_primsub[prim->prim]; gs.primC -= g_primsub[prim->prim];
if (adc && prim->prim == 5) if (adc && prim->prim == 5)
{ {
/* tri fans need special processing */ /* tri fans need special processing */
if (gs.nTriFanVert == gs.primIndex) if (gs.nTriFanVert == gs.primIndex) gs.primIndex = gs.primNext();
gs.primIndex = gs.primNext();
} }
} }
} }
inline void Kick::SET_VERTEX(VertexGPU *p, int i)
inline void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
{ {
int index = Index; p->move_x(gs.gsvertex[i], vb[prim->ctxt].offset.x);
p->x = ((((int)gs.gsvertex[index].x - curvb.offset.x) >> 1) & 0xffff); p->move_y(gs.gsvertex[i], vb[prim->ctxt].offset.y);
p->y = ((((int)gs.gsvertex[index].y - curvb.offset.y) >> 1) & 0xffff); p->move_z(gs.gsvertex[i], vb[prim->ctxt].zprimmask);
p->f = ((s16)gs.gsvertex[index].f << 7) | 0x7f; p->move_fog(gs.gsvertex[i]);
MOVZ(p, gs.gsvertex[index].z, curvb); p->rgba = prim->iip ? gs.gsvertex[i].rgba : gs.rgba;
p->rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba;
// This code is somehow incorrect
// if ((gs.texa.aem) && ((p->rgba & 0xffffff ) == 0))
// p->rgba = 0;
if (conf.settings().texa) if (conf.settings().texa)
{ {
u32 B = ((p->rgba & 0xfe000000) >> 1) + u32 B = ((p->rgba & 0xfe000000) >> 1) + (0x01000000 * vb[prim->ctxt].fba.fba);
(0x01000000 * curvb.fba.fba) ;
p->rgba = (p->rgba & 0xffffff) + B; p->rgba = (p->rgba & 0xffffff) + B;
} }
@ -174,20 +127,20 @@ inline void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
{ {
if (prim->fst) if (prim->fst)
{ {
p->s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt]; p->s = (float)gs.gsvertex[i].u * fiTexWidth[prim->ctxt];
p->t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt]; p->t = (float)gs.gsvertex[i].v * fiTexHeight[prim->ctxt];
p->q = 1; p->q = 1;
} }
else else
{ {
p->s = gs.gsvertex[index].s; p->s = gs.gsvertex[i].s;
p->t = gs.gsvertex[index].t; p->t = gs.gsvertex[i].t;
p->q = gs.gsvertex[index].q; p->q = gs.gsvertex[i].q;
} }
} }
} }
static __forceinline void OUTPUT_VERT(VertexGPU vert, u32 id) __forceinline void Kick::OUTPUT_VERT(VertexGPU vert, u32 id)
{ {
#ifdef WRITE_PRIM_LOGS #ifdef WRITE_PRIM_LOGS
ZZLog::Prim_Log("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n", ZZLog::Prim_Log("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n",
@ -196,7 +149,22 @@ static __forceinline void OUTPUT_VERT(VertexGPU vert, u32 id)
#endif #endif
} }
void KickPoint() void Kick::fn(u32 i)
{
switch (i)
{
case 0: Point(); break;
case 1: Line(); break;
case 2: Line(); break;
case 3: Triangle(); break;
case 4: Triangle(); break;
case 5: TriangleFan(); break;
case 6: Sprite(); break;
default: Dummy(); break;
}
}
void Kick::Point()
{ {
FUNCLOG FUNCLOG
assert(gs.primC >= 1); assert(gs.primC >= 1);
@ -216,13 +184,13 @@ void KickPoint()
int last = gs.primNext(2); int last = gs.primNext(2);
VertexGPU* p = curvb.pBufferData + curvb.nCount; VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], last, curvb); SET_VERTEX(&p[0], last);
curvb.nCount++; curvb.nCount++;
OUTPUT_VERT(p[0], 0); OUTPUT_VERT(p[0], 0);
} }
void KickLine() void Kick::Line()
{ {
FUNCLOG FUNCLOG
assert(gs.primC >= 2); assert(gs.primC >= 2);
@ -242,8 +210,8 @@ void KickLine()
int last = gs.primNext(2); int last = gs.primNext(2);
VertexGPU* p = curvb.pBufferData + curvb.nCount; VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], next, curvb); SET_VERTEX(&p[0], next);
SET_VERTEX(&p[1], last, curvb); SET_VERTEX(&p[1], last);
curvb.nCount += 2; curvb.nCount += 2;
@ -251,7 +219,7 @@ void KickLine()
OUTPUT_VERT(p[1], 1); OUTPUT_VERT(p[1], 1);
} }
void KickTriangle() void Kick::Triangle()
{ {
FUNCLOG FUNCLOG
assert(gs.primC >= 3); assert(gs.primC >= 3);
@ -268,9 +236,9 @@ void KickTriangle()
curvb.NotifyWrite(3); curvb.NotifyWrite(3);
VertexGPU* p = curvb.pBufferData + curvb.nCount; VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], 0, curvb); SET_VERTEX(&p[0], 0);
SET_VERTEX(&p[1], 1, curvb); SET_VERTEX(&p[1], 1);
SET_VERTEX(&p[2], 2, curvb); SET_VERTEX(&p[2], 2);
curvb.nCount += 3; curvb.nCount += 3;
@ -279,7 +247,7 @@ void KickTriangle()
OUTPUT_VERT(p[2], 2); OUTPUT_VERT(p[2], 2);
} }
void KickTriangleFan() void Kick::TriangleFan()
{ {
FUNCLOG FUNCLOG
assert(gs.primC >= 3); assert(gs.primC >= 3);
@ -296,9 +264,9 @@ void KickTriangleFan()
curvb.NotifyWrite(3); curvb.NotifyWrite(3);
VertexGPU* p = curvb.pBufferData + curvb.nCount; VertexGPU* p = curvb.pBufferData + curvb.nCount;
SET_VERTEX(&p[0], 0, curvb); SET_VERTEX(&p[0], 0);
SET_VERTEX(&p[1], 1, curvb); SET_VERTEX(&p[1], 1);
SET_VERTEX(&p[2], 2, curvb); SET_VERTEX(&p[2], 2);
curvb.nCount += 3; curvb.nCount += 3;
@ -311,14 +279,14 @@ void KickTriangleFan()
OUTPUT_VERT(p[2], 2); OUTPUT_VERT(p[2], 2);
} }
void SetKickVertex(VertexGPU *p, Vertex v, int next, const VB& curvb) void Kick::SetKickVertex(VertexGPU *p, Vertex v, int next)
{ {
SET_VERTEX(p, next, curvb); SET_VERTEX(p, next);
MOVZ(p, v.z, curvb); p->move_z(v, vb[prim->ctxt].zprimmask);
MOVFOG(p, v); p->move_fog(v);
} }
void KickSprite() void Kick::Sprite()
{ {
FUNCLOG FUNCLOG
assert(gs.primC >= 2); assert(gs.primC >= 2);
@ -346,16 +314,16 @@ void KickSprite()
VertexGPU* p = curvb.pBufferData + curvb.nCount; VertexGPU* p = curvb.pBufferData + curvb.nCount;
SetKickVertex(&p[0], gs.gsvertex[last], next, curvb); SetKickVertex(&p[0], gs.gsvertex[last], next);
SetKickVertex(&p[3], gs.gsvertex[last], next, curvb); SetKickVertex(&p[3], gs.gsvertex[last], next);
SetKickVertex(&p[1], gs.gsvertex[last], last, curvb); SetKickVertex(&p[1], gs.gsvertex[last], last);
SetKickVertex(&p[4], gs.gsvertex[last], last, curvb); SetKickVertex(&p[4], gs.gsvertex[last], last);
SetKickVertex(&p[2], gs.gsvertex[last], next, curvb); SetKickVertex(&p[2], gs.gsvertex[last], next);
p[2].s = p[1].s; p[2].s = p[1].s;
p[2].x = p[1].x; p[2].x = p[1].x;
SetKickVertex(&p[5], gs.gsvertex[last], last, curvb); SetKickVertex(&p[5], gs.gsvertex[last], last);
p[5].s = p[0].s; p[5].s = p[0].s;
p[5].x = p[0].x; p[5].x = p[0].x;
@ -366,7 +334,7 @@ void KickSprite()
OUTPUT_VERT(p[1], 1); OUTPUT_VERT(p[1], 1);
} }
void KickDummy() void Kick::Dummy()
{ {
FUNCLOG FUNCLOG
//ZZLog::Greg_Log("Kicking bad primitive: %.8x\n", *(u32*)prim); //ZZLog::Greg_Log("Kicking bad primitive: %.8x\n", *(u32*)prim);

View File

@ -20,30 +20,33 @@
#ifndef ZZKICK_H_INCLUDED #ifndef ZZKICK_H_INCLUDED
#define ZZKICK_H_INCLUDED #define ZZKICK_H_INCLUDED
#include "Util.h"
#include "GS.h" #include "GS.h"
// visible members
typedef void (*DrawFn)();
extern DrawFn drawfn[8];
// Older Kick Vertex functions.
void __forceinline KICK_VERTEX2();
void __forceinline KICK_VERTEX3();
// Newer version.
extern void __forceinline KickVertex(bool adc);
extern bool __forceinline NoHighlights(int i); extern bool __forceinline NoHighlights(int i);
extern void init_drawfn(); class Kick
extern void clear_drawfn(); {
private:
extern void KickPoint(); void SET_VERTEX(VertexGPU *p, int i);
extern void KickLine(); void SetKickVertex(VertexGPU *p, Vertex v, int next);
extern void KickTriangle(); void OUTPUT_VERT(VertexGPU vert, u32 id);
extern void KickTriangleFan(); public:
extern void KickSprite(); Kick() { }
extern void KickDummy(); ~Kick() { }
void KickVertex(bool adc);
void KickVERTEX2();
void KickVERTEX3();
void fn(u32 i);
void Point();
void Line();
void Triangle();
void TriangleFan();
void Sprite();
void Dummy();
};
extern Kick* ZZKick;
#endif // ZZKICK_H_INCLUDED #endif // ZZKICK_H_INCLUDED

View File

@ -28,6 +28,7 @@
#include "ZZKick.h" #include "ZZKick.h"
#include "rasterfont.h" // simple font #include "rasterfont.h" // simple font
#include <math.h> #include <math.h>
#include "ZZoglVB.h"
//------------------ Defines //------------------ Defines
#if !defined(ZEROGS_DEVBUILD) #if !defined(ZEROGS_DEVBUILD)
@ -704,7 +705,8 @@ void ZZReset()
ZZGSStateReset(); ZZGSStateReset();
ZZDestroy(); ZZDestroy();
clear_drawfn(); //clear_drawfn();
if (ZZKick != NULL) delete ZZKick;
} }
// If needed reset // If needed reset

View File

@ -28,6 +28,7 @@
#include "targets.h" #include "targets.h"
#include "rasterfont.h" // simple font #include "rasterfont.h" // simple font
#include "ZZKick.h" #include "ZZKick.h"
#include "ZZoglVB.h"
// This include for windows resource file with Shaders // This include for windows resource file with Shaders
#ifdef _WIN32 #ifdef _WIN32
@ -507,7 +508,9 @@ bool ZZCreate(int _width, int _height)
if (err != GL_NO_ERROR) bSuccess = false; if (err != GL_NO_ERROR) bSuccess = false;
// init draw fns // init draw fns
init_drawfn(); //init_drawfn();
if (ZZKick != NULL) delete ZZKick;
ZZKick = new Kick;
SetAA(conf.aa); SetAA(conf.aa);

View File

@ -464,18 +464,18 @@ inline CRenderTarget* FlushReGetTarget(int& tbw, int& tbp0, int& tpsm, VB& curvb
if ((ptextarg == NULL) && (tpsm == PSMT8) && (conf.settings().reget)) if ((ptextarg == NULL) && (tpsm == PSMT8) && (conf.settings().reget))
{ {
// check for targets with half the width. Break Valkyrie Chronicles // check for targets with half the width. Break Valkyrie Chronicles
ptextarg = s_RTs.GetTarg(tbp0, tbw / 2, curvb); ptextarg = s_RTs.GetTarg(tbp0, tbw / 2);
if (ptextarg == NULL) if (ptextarg == NULL)
{ {
tbp0 &= ~0x7ff; tbp0 &= ~0x7ff;
ptextarg = s_RTs.GetTarg(tbp0, tbw / 2, curvb); // mgs3 hack ptextarg = s_RTs.GetTarg(tbp0, tbw / 2); // mgs3 hack
if (ptextarg == NULL) if (ptextarg == NULL)
{ {
// check the next level (mgs3) // check the next level (mgs3)
tbp0 &= ~0xfff; tbp0 &= ~0xfff;
ptextarg = s_RTs.GetTarg(tbp0, tbw / 2, curvb); // mgs3 hack ptextarg = s_RTs.GetTarg(tbp0, tbw / 2); // mgs3 hack
} }
if (ptextarg != NULL && ptextarg->start > tbp0*256) if (ptextarg != NULL && ptextarg->start > tbp0*256)
@ -490,7 +490,7 @@ inline CRenderTarget* FlushReGetTarget(int& tbw, int& tbp0, int& tpsm, VB& curvb
if (PSMT_ISZTEX(tpsm) && (ptextarg == NULL)) if (PSMT_ISZTEX(tpsm) && (ptextarg == NULL))
{ {
// try depth // try depth
ptextarg = s_DepthRTs.GetTarg(tbp0, tbw, curvb); ptextarg = s_DepthRTs.GetTarg(tbp0, tbw);
} }
if ((ptextarg == NULL) && (conf.settings().texture_targs)) if ((ptextarg == NULL) && (conf.settings().texture_targs))
@ -556,7 +556,7 @@ inline CRenderTarget* FlushGetTarget(VB& curvb)
tpsm = curvb.tex0.psm; tpsm = curvb.tex0.psm;
} }
ptextarg = s_RTs.GetTarg(tbp0, tbw, curvb); ptextarg = s_RTs.GetTarg(tbp0, tbw);
if (ptextarg == NULL) if (ptextarg == NULL)
ptextarg = FlushReGetTarget(tbw, tbp0, tpsm, curvb); ptextarg = FlushReGetTarget(tbw, tbp0, tpsm, curvb);

View File

@ -28,6 +28,7 @@
#include "GS.h" #include "GS.h"
#include "targets.h" #include "targets.h"
#include "ZZoglVB.h"
extern int g_SkipFlushFrame; extern int g_SkipFlushFrame;

View File

@ -20,7 +20,7 @@
// Save and Load. // Save and Load.
//------------------ Includes //------------------ Includes
#include "targets.h" #include "ZZoglVB.h"
extern void ZZGSStateReset(); extern void ZZGSStateReset();
//----------------------- Defines //----------------------- Defines

View File

@ -22,6 +22,7 @@
//------------------- Includes //------------------- Includes
#include "targets.h" #include "targets.h"
#include "ZZoglVB.h"
#include "GS.h" #include "GS.h"
#include "Mem.h" #include "Mem.h"
extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height

View File

@ -0,0 +1,157 @@
/* ZZ Open GL graphics plugin
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// Zerogs:VB implementation.
// VB stands for Visual Buffer, as I think
#ifndef ZZOGLVB_H_INCLUDED
#define ZZOGLVB_H_INCLUDED
#include "targets.h"
extern const GLenum primtype[8];
struct VB
{
VB();
~VB();
void Destroy();
inline bool CheckPrim()
{
static const int PRIMMASK = 0x0e; // for now ignore 0x10 (AA)
if ((PRIMMASK & prim->_val) != (PRIMMASK & curprim._val) || primtype[prim->prim] != primtype[curprim.prim])
return nCount > 0;
return false;
}
void CheckFrame(int tbp);
// context specific state
Point offset;
Rect2 scissor;
tex0Info tex0;
tex1Info tex1;
miptbpInfo miptbp0;
miptbpInfo miptbp1;
alphaInfo alpha;
fbaInfo fba;
clampInfo clamp;
pixTest test;
u32 ptexClamp[2]; // textures for x and y dir region clamping
public:
void FlushTexData();
inline int CheckFrameAddConstraints(int tbp);
inline void CheckScissors(int maxpos);
inline void CheckFrame32bitRes(int maxpos);
inline int FindMinimalMemoryConstrain(int tbp, int maxpos);
inline int FindZbufferMemoryConstrain(int tbp, int maxpos);
inline int FindMinimalHeightConstrain(int maxpos);
inline int CheckFrameResolveRender(int tbp);
inline void CheckFrame16vs32Conversion();
inline int CheckFrameResolveDepth(int tbp);
inline void FlushTexUnchangedClutDontUpdate() ;
inline void FlushTexClutDontUpdate() ;
inline void FlushTexClutting() ;
inline void FlushTexSetNewVars(u32 psm) ;
// notify VB that nVerts need to be written to pbuf
inline void NotifyWrite(int nVerts)
{
assert(pBufferData != NULL && nCount <= nNumVertices && nVerts > 0);
if (nCount + nVerts > nNumVertices)
{
// recreate except with a bigger count
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nNumVertices * 2, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
nNumVertices *= 2;
assert(nCount + nVerts <= nNumVertices);
_aligned_free(pBufferData);
pBufferData = ptemp;
}
}
void Init(int nVerts)
{
if (pBufferData == NULL && nVerts > 0)
{
pBufferData = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nVerts, 256);
nNumVertices = nVerts;
}
nCount = 0;
}
u8 bNeedFrameCheck;
u8 bNeedZCheck;
u8 bNeedTexCheck;
u8 dummy0;
union
{
struct
{
u8 bTexConstsSync; // only pixel shader constants that context owns
u8 bVarsTexSync; // texture info
u8 bVarsSetTarg;
u8 dummy1;
};
u32 bSyncVars;
};
int ictx;
VertexGPU* pBufferData; // current allocated data
int nNumVertices; // size of pBufferData in terms of VertexGPU objects
int nCount;
primInfo curprim; // the previous prim the current buffers are set to
zbufInfo zbuf;
frameInfo gsfb; // the real info set by FRAME cmd
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
int nNextFrameHeight;
CMemoryTarget* pmemtarg; // the current mem target set
CRenderTarget* prndr;
CDepthTarget* pdepth;
};
// VB variables
extern VB vb[2];
#endif // ZZOGLVB_H_INCLUDED

View File

@ -27,6 +27,7 @@
#include "ZZoglShaders.h" #include "ZZoglShaders.h"
#include "ZZClut.h" #include "ZZClut.h"
#include <math.h> #include <math.h>
#include "ZZoglVB.h"
#ifdef ZEROGS_SSE2 #ifdef ZEROGS_SSE2
#include <emmintrin.h> #include <emmintrin.h>

View File

@ -26,6 +26,7 @@
#include <map> #include <map>
#include "GS.h" #include "GS.h"
#include "ZZGl.h" #include "ZZGl.h"
//#include "ZZoglVB.h"
#ifndef GL_TEXTURE_RECTANGLE #ifndef GL_TEXTURE_RECTANGLE
#define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV #define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV
@ -226,133 +227,7 @@ class CMemoryTarget
int clutsize; // size of the clut array. 0 otherwise int clutsize; // size of the clut array. 0 otherwise
}; };
extern const GLenum primtype[8]; inline u32 GetFrameKey(int fbp, int fbw);
struct VB
{
VB();
~VB();
void Destroy();
inline bool CheckPrim()
{
static const int PRIMMASK = 0x0e; // for now ignore 0x10 (AA)
if ((PRIMMASK & prim->_val) != (PRIMMASK & curprim._val) || primtype[prim->prim] != primtype[curprim.prim])
return nCount > 0;
return false;
}
void CheckFrame(int tbp);
// context specific state
Point offset;
Rect2 scissor;
tex0Info tex0;
tex1Info tex1;
miptbpInfo miptbp0;
miptbpInfo miptbp1;
alphaInfo alpha;
fbaInfo fba;
clampInfo clamp;
pixTest test;
u32 ptexClamp[2]; // textures for x and y dir region clamping
public:
void FlushTexData();
inline int CheckFrameAddConstraints(int tbp);
inline void CheckScissors(int maxpos);
inline void CheckFrame32bitRes(int maxpos);
inline int FindMinimalMemoryConstrain(int tbp, int maxpos);
inline int FindZbufferMemoryConstrain(int tbp, int maxpos);
inline int FindMinimalHeightConstrain(int maxpos);
inline int CheckFrameResolveRender(int tbp);
inline void CheckFrame16vs32Conversion();
inline int CheckFrameResolveDepth(int tbp);
inline void FlushTexUnchangedClutDontUpdate() ;
inline void FlushTexClutDontUpdate() ;
inline void FlushTexClutting() ;
inline void FlushTexSetNewVars(u32 psm) ;
// notify VB that nVerts need to be written to pbuf
inline void NotifyWrite(int nVerts)
{
assert(pBufferData != NULL && nCount <= nNumVertices && nVerts > 0);
if (nCount + nVerts > nNumVertices)
{
// recreate except with a bigger count
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nNumVertices * 2, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
nNumVertices *= 2;
assert(nCount + nVerts <= nNumVertices);
_aligned_free(pBufferData);
pBufferData = ptemp;
}
}
void Init(int nVerts)
{
if (pBufferData == NULL && nVerts > 0)
{
pBufferData = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU) * nVerts, 256);
nNumVertices = nVerts;
}
nCount = 0;
}
u8 bNeedFrameCheck;
u8 bNeedZCheck;
u8 bNeedTexCheck;
u8 dummy0;
union
{
struct
{
u8 bTexConstsSync; // only pixel shader constants that context owns
u8 bVarsTexSync; // texture info
u8 bVarsSetTarg;
u8 dummy1;
};
u32 bSyncVars;
};
int ictx;
VertexGPU* pBufferData; // current allocated data
int nNumVertices; // size of pBufferData in terms of VertexGPU objects
int nCount;
primInfo curprim; // the previous prim the current buffers are set to
zbufInfo zbuf;
frameInfo gsfb; // the real info set by FRAME cmd
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
int nNextFrameHeight;
CMemoryTarget* pmemtarg; // the current mem target set
CRenderTarget* prndr;
CDepthTarget* pdepth;
};
inline u32 GetFrameKey(int fbp, int fbw, VB& curvb);
// manages render targets // manages render targets
class CRenderTargetMngr class CRenderTargetMngr
@ -375,13 +250,13 @@ class CRenderTargetMngr
bool isFound(const frameInfo& frame, MAPTARGETS::iterator& it, u32 opts, u32 key, int maxposheight); bool isFound(const frameInfo& frame, MAPTARGETS::iterator& it, u32 opts, u32 key, int maxposheight);
CRenderTarget* GetTarg(const frameInfo& frame, u32 Options, int maxposheight); CRenderTarget* GetTarg(const frameInfo& frame, u32 Options, int maxposheight);
inline CRenderTarget* GetTarg(int fbp, int fbw, VB& curvb) inline CRenderTarget* GetTarg(int fbp, int fbw)
{ {
MAPTARGETS::iterator it = mapTargets.find(GetFrameKey(fbp, fbw, curvb)); MAPTARGETS::iterator it = mapTargets.find(GetFrameKey(fbp, fbw));
/* if (fbp == 0x3600 && fbw == 0x100 && it == mapTargets.end()) /* if (fbp == 0x3600 && fbw == 0x100 && it == mapTargets.end())
{ {
ZZLog::Debug_Log("%x", GetFrameKey(fbp, fbw, curvb)) ; ZZLog::Debug_Log("%x", GetFrameKey(fbp, fbw)) ;
ZZLog::Debug_Log("%x %x", fbp, fbw); ZZLog::Debug_Log("%x %x", fbp, fbw);
for(MAPTARGETS::iterator it1 = mapTargets.begin(); it1 != mapTargets.end(); ++it1) for(MAPTARGETS::iterator it1 = mapTargets.begin(); it1 != mapTargets.end(); ++it1)
ZZLog::Debug_Log("\t %x %x %x %x", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp); ZZLog::Debug_Log("\t %x %x %x %x", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
@ -572,7 +447,7 @@ inline u32 GetFrameKey(CRenderTarget* frame)
return (((frame->fbw) << 16) | (frame->fbp)); return (((frame->fbw) << 16) | (frame->fbp));
} }
inline u32 GetFrameKey(int fbp, int fbw, VB& curvb) inline u32 GetFrameKey(int fbp, int fbw)
{ {
return (((fbw) << 16) | (fbp)); return (((fbw) << 16) | (fbp));
} }
@ -713,9 +588,6 @@ static __forceinline void setRectWrap2(GLint type)
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, type); glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, type);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, type); glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, type);
} }
// VB variables
extern VB vb[2];
//------------------------ Inlines ------------------------- //------------------------ Inlines -------------------------

View File

@ -19,6 +19,7 @@
//-------------------------- Includes //-------------------------- Includes
#include "zerogs.h" #include "zerogs.h"
#include "ZZoglVB.h"
///////////////////// /////////////////////
// graphics resources // graphics resources