- [Psy-X] make PGXP_LOOKUP_VALUE macro simpler to use

This commit is contained in:
Ilya Shurumov 2021-05-10 17:46:02 +06:00 committed by InspirationByte
parent 5cde54b0a1
commit b6ac4566ef
5 changed files with 12 additions and 11 deletions

View File

@ -611,8 +611,8 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP
if (!bDoingShadow) // [A] Psy-X is currently incorrectly offsets the offscreen PGXP geometry. We don't need it anyway.
{
PGXPVData vdata1, vdata2;
PGXP_GetCacheData(&vdata1, PGXP_LOOKUP_VALUE(v1[0].sh, v1[1].sh), 0);
PGXP_GetCacheData(&vdata2, PGXP_LOOKUP_VALUE(v2[0].sh, v2[1].sh), 0);
PGXP_GetCacheData(&vdata1, PGXP_LOOKUP_VALUE(v1[0], v1[1]), 0);
PGXP_GetCacheData(&vdata2, PGXP_LOOKUP_VALUE(v2[0], v2[1]), 0);
{
float len;
@ -664,25 +664,25 @@ void DrawBodySprite(PEDESTRIAN* pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP
}
}
PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0.sh, prims->y0.sh),
PGXPVData v0data = { PGXP_LOOKUP_VALUE(prims->x0, prims->y0),
vdata1.px + (FIXEDH(sn) - dx1) * 0.01f,
vdata1.py + (FIXEDH(cs) + dy1) * 0.01f,
vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy };
PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1.sh, prims->y1.sh),
PGXPVData v1data = { PGXP_LOOKUP_VALUE(prims->x1, prims->y1),
vdata1.px - (FIXEDH(sn) - dx1) * 0.01f,
vdata1.py - (FIXEDH(cs) - dy1) * 0.01f,
vdata1.pz, vdata1.scr_h, vdata1.ofx, vdata1.ofy };
PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2.sh, prims->y2.sh),
PGXPVData v2data = { PGXP_LOOKUP_VALUE(prims->x2, prims->y2),
vdata2.px + (FIXEDH(sn) + dx2) * 0.01f,
vdata2.py + (FIXEDH(cs) - dy2) * 0.01f,
vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy };
PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3.sh, prims->y3.sh),
PGXPVData v3data = { PGXP_LOOKUP_VALUE(prims->x3, prims->y3),
vdata2.px - (FIXEDH(sn) + dx2) * 0.01f,
vdata2.py - (FIXEDH(cs) + dy2) * 0.01f,
vdata2.pz, vdata2.scr_h, vdata2.ofx, vdata2.ofy };

View File

@ -5,7 +5,7 @@
#include "PsyX/common/half_float.h"
// Helpful macro
#define PGXP_LOOKUP_VALUE(x, y) (x | (y << 16))
#define PGXP_LOOKUP_VALUE(x, y) (*(u_short*)&(x) | (*(u_short*)&(y) << 16))
//-------------------------------------

View File

@ -589,7 +589,7 @@ extern int doCOP2(int op);
#define gte_stsxy0( r0 ) \
{ *(uint*)((char*)r0) = MFC2(12);}
#endif
#endif // USE_PGXP
// swc2 8
#define gte_stdp( r0 ) \

View File

@ -165,7 +165,8 @@ void MakeLineArray(GrVertex* vertex, VERTTYPE* p0, VERTTYPE* p1, ushort gteidx)
inline void ApplyVertexPGXP(GrVertex* v, VERTTYPE* p, float ofsX, float ofsY, ushort gteidx)
{
#ifdef USE_PGXP
uint lookup = PGXP_LOOKUP_VALUE(p[0].sh, p[1].sh);
uint lookup = PGXP_LOOKUP_VALUE(p[0], p[1]);
PGXPVData vd;
if (g_pgxpTextureCorrection && PGXP_GetCacheData(&vd, lookup, gteidx))
{

View File

@ -385,8 +385,8 @@ int GTE_RotTransPers(int idx, int lm)
g_FP_SXYZ0 = g_FP_SXYZ1;
g_FP_SXYZ1 = g_FP_SXYZ2;
// calculate projected values for cache
PGXPVector3D temp;
temp.px = (double(C2_OFX) + double(float(C2_IR1) * float(h_over_sz3))) / float(1 << 16);
temp.py = (double(C2_OFY) + double(float(C2_IR2) * float(h_over_sz3))) / float(1 << 16);
temp.pz = float(max(C2_SZ3, C2_H / 2)) / float(1 << 16);
@ -401,7 +401,7 @@ int GTE_RotTransPers(int idx, int lm)
// do not perform perspective multiplication so it stays in object space
// perspective is performed exclusively in shader
PGXPVData vdata;
vdata.lookup = PGXP_LOOKUP_VALUE(temp.x.sh, temp.y.sh); // hash short values
vdata.lookup = PGXP_LOOKUP_VALUE(temp.x, temp.y); // hash short values
// FIXME: actually we scaling here entire geometry, is that correct?
vdata.px = fMAC1 * one_by_v * g_pgxpZScale + g_pgxpZOffset;