zzogl-pg: Renamed Vector to float4 & renamed zerogsmath.h to ZZoglMath.h. (Continuing to work on bringing zzogl-pg in sync with recent revisions of zzogl.)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3786 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-09-17 07:31:55 +00:00
parent 6656819a33
commit cc5414f49e
16 changed files with 138 additions and 136 deletions

View File

@ -92,9 +92,9 @@ set(zzoglHeaders
Util.h
x86.h
zerogs.h
zerogsmath.h
zpipe.h
ZZoglCRTC.h
ZZoglMath.h
ZZoglShaders.h
ZZGl.h
ZZLog.h)

View File

@ -264,7 +264,7 @@ void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize) {FUNCLOG}
} \
} \
\
psrcv = (Vector*)&vBilinearData[0] + b.ox + b.oy * BLOCK_TEXWIDTH; \
psrcv = (float4*)&vBilinearData[0] + b.ox + b.oy * BLOCK_TEXWIDTH; \
\
for(i = 0; i < b.height; ++i) \
{ \
@ -273,7 +273,7 @@ void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize) {FUNCLOG}
for(j = 0; j < b.width; ++j) \
{ \
u32 temp = ((j + 1) % b.width); \
Vector* pv = &psrcv[i_width + j]; \
float4* pv = &psrcv[i_width + j]; \
pv->x = psrcf[i_width + j]; \
pv->y = psrcf[i_width + temp]; \
pv->z = psrcf[i_width2 + j]; \
@ -390,13 +390,13 @@ void FillBlocksF(vector<char>& vBlockData, vector<char>& vBilinearData)
{
FUNCLOG
vBlockData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * 4);
vBilinearData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * sizeof(Vector));
vBilinearData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * sizeof(float4));
int i, j;
BLOCK b;
float* psrcf = NULL;
u16* psrcw = NULL;
Vector* psrcv = NULL;
float4* psrcv = NULL;
memset(m_Blocks, 0, sizeof(m_Blocks));

View File

@ -97,8 +97,8 @@ struct BLOCK
BLOCK() { memset(this, 0, sizeof(BLOCK)); }
// shader constants for this block
Vector vTexBlock;
Vector vTexDims;
float4 vTexBlock;
float4 vTexDims;
int width, height; // dims of one page in pixels
int ox, oy, mult;
int bpp;
@ -124,8 +124,8 @@ struct BLOCK
ox = ox2;
oy = oy2;
mult = mult2;
vTexDims = Vector(BLOCK_TEXWIDTH/(float)(bw), BLOCK_TEXHEIGHT/(float)bh, 0, 0);
vTexBlock = Vector((float)bw/BLOCK_TEXWIDTH, (float)bh/BLOCK_TEXHEIGHT, ((float)ox+0.2f)/BLOCK_TEXWIDTH, ((float)oy+0.05f)/BLOCK_TEXHEIGHT);
vTexDims = float4(BLOCK_TEXWIDTH/(float)(bw), BLOCK_TEXHEIGHT/(float)bh, 0, 0);
vTexBlock = float4((float)bw/BLOCK_TEXWIDTH, (float)bh/BLOCK_TEXHEIGHT, ((float)ox+0.2f)/BLOCK_TEXWIDTH, ((float)oy+0.05f)/BLOCK_TEXHEIGHT);
width = bw;
height = bh;
colwidth = bh / 4;

View File

@ -638,7 +638,7 @@ void __gifCall GIFRegHandlerSCISSOR(const u32* data)
Flush();
}
m_env.CTXT[i].SCISSOR = (GSVector4i)r->SCISSOR;
m_env.CTXT[i].SCISSOR = (Vector4i)r->SCISSOR;
m_env.CTXT[i].UpdateScissor();*/
ZZLog::Greg_Log("SCISSOR%d", i);

View File

@ -52,7 +52,7 @@ extern "C" u32 CALLBACK PS2EgetLibType(void);
extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
extern "C" char* CALLBACK PS2EgetLibName(void);
#include "zerogsmath.h"
#include "ZZoglMath.h"
#include <vector>
#include <string>

View File

@ -481,10 +481,6 @@
RelativePath="..\zerogs.h"
>
</File>
<File
RelativePath="..\zerogsmath.h"
>
</File>
<File
RelativePath="..\ZZGl.h"
>
@ -497,6 +493,10 @@
RelativePath="..\ZZoglFlushHack.h"
>
</File>
<File
RelativePath="..\ZZoglMath.h"
>
</File>
<File
RelativePath="..\ZZoglShaders.h"
>

View File

@ -50,7 +50,7 @@ extern bool g_bMakeSnapshot;
extern string strSnapshot;
// Adjusts vertex shader BitBltPos vector v to preserve aspect ratio. It used to emulate 4:3 or 16:9.
void ZeroGS::AdjustTransToAspect(Vector& v)
void ZeroGS::AdjustTransToAspect(float4& v)
{
double temp;
float f;
@ -242,11 +242,11 @@ inline void RenderStartHelper(u32 bInterlace)
// on image y coords. So if we write valpha.z * F + valpha.w + 0.5, it would be switching odd
// and even strings at each frame.
// valpha.x and y are used for image blending.
inline Vector RenderGetForClip(u32 bInterlace, int interlace, int psm, FRAGMENTSHADER* prog)
inline float4 RenderGetForClip(u32 bInterlace, int interlace, int psm, FRAGMENTSHADER* prog)
{
SetShaderCaller("RenderGetForClip");
Vector valpha;
float4 valpha;
// first render the current render targets, then from ptexMem
if (psm == 1)
@ -396,10 +396,10 @@ inline int RenderGetOffsets(int* dby, int* movy, tex0Info& texframe, CRenderTarg
}
// BltBit shader calculate vertex (4 coord's pixel) position at the viewport.
inline Vector RenderSetTargetBitPos(int dh, int th, int movy, bool isInterlace)
inline float4 RenderSetTargetBitPos(int dh, int th, int movy, bool isInterlace)
{
SetShaderCaller("RenderSetTargetBitPos");
Vector v;
float4 v;
// dest rect
v.x = 1;
v.y = dh / (float)th;
@ -425,12 +425,12 @@ inline Vector RenderSetTargetBitPos(int dh, int th, int movy, bool isInterlace)
// For example, use tw / X and tw / X magnify the viewport.
// Interlaced output is little out of VB, it could be seen as an evil blinking line on top
// and bottom, so we try to remove it.
inline Vector RenderSetTargetBitTex(float th, float tw, float dh, float dw, bool isInterlace)
inline float4 RenderSetTargetBitTex(float th, float tw, float dh, float dw, bool isInterlace)
{
SetShaderCaller("RenderSetTargetBitTex");
Vector v;
v = Vector(th, tw, dh, dw);
float4 v;
v = float4(th, tw, dh, dw);
// Incorrect Aspect ratio on interlaced frames
@ -447,21 +447,21 @@ inline Vector RenderSetTargetBitTex(float th, float tw, float dh, float dw, bool
// Translator for POSITION coordinates (-1.0:+1.0f at x axis, +1.0f:-1.0y at y) into target frame ones.
// We don't need x coordinate, because interlacing is y-axis only.
inline Vector RenderSetTargetBitTrans(int th)
inline float4 RenderSetTargetBitTrans(int th)
{
SetShaderCaller("RenderSetTargetBitTrans");
Vector v = Vector(float(th), -float(th), float(th), float(th));
float4 v = float4(float(th), -float(th), float(th), float(th));
ZZshSetParameter4fv(pvsBitBlt.fBitBltTrans, v, "g_fBitBltTrans");
return v;
}
// use g_fInvTexDims to store inverse texture dims
// Seems, that Targ shader does not use it
inline Vector RenderSetTargetInvTex(int bInterlace, int tw, int th, FRAGMENTSHADER* prog)
inline float4 RenderSetTargetInvTex(int bInterlace, int tw, int th, FRAGMENTSHADER* prog)
{
SetShaderCaller("RenderSetTargetInvTex");
Vector v = Vector(0, 0, 0, 0);
float4 v = float4(0, 0, 0, 0);
if (prog->sInvTexDims)
{
@ -544,14 +544,14 @@ inline void RenderCheckForTargets(tex0Info& texframe, list<CRenderTarget*>& list
SetShaderCaller("RenderCheckForTargets");
// Texture
Vector v = RenderSetTargetBitTex((float)RW(texframe.tw), (float)RH(dh), (float)RW(pfb->DBX), (float)RH(dby), INTERLACE_COUNT);
float4 v = RenderSetTargetBitTex((float)RW(texframe.tw), (float)RH(dh), (float)RW(pfb->DBX), (float)RH(dby), INTERLACE_COUNT);
// dest rect
v = RenderSetTargetBitPos(dh, texframe.th, movy, INTERLACE_COUNT);
v = RenderSetTargetBitTrans(ptarg->fbh);
v = RenderSetTargetInvTex(bInterlace, texframe.tbw, ptarg->fbh, &ppsCRTCTarg[bInterlace]) ; // FIXME. This is no use
Vector valpha = RenderGetForClip(bInterlace, interlace, texframe.psm, &ppsCRTCTarg[bInterlace]);
float4 valpha = RenderGetForClip(bInterlace, interlace, texframe.psm, &ppsCRTCTarg[bInterlace]);
// inside vb[0]'s target area, so render that region only
ZZshGLSetTextureParameter(ppsCRTCTarg[bInterlace].sFinal, ptarg->ptex, "CRTC target");
@ -582,7 +582,7 @@ inline void RenderCheckForTargets(tex0Info& texframe, list<CRenderTarget*>& list
// this is the function that does it.
inline void RenderCheckForMemory(tex0Info& texframe, list<CRenderTarget*>& listTargs, int i, bool* bUsingStencil, int interlace, int bInterlace)
{
Vector v;
float4 v;
for (list<CRenderTarget*>::iterator it = listTargs.begin(); it != listTargs.end(); ++it)
{
@ -624,7 +624,7 @@ inline void RenderCheckForMemory(tex0Info& texframe, list<CRenderTarget*>& listT
v = RenderSetTargetBitPos(1, 1, 0, INTERLACE_COUNT);
v = RenderSetTargetBitTrans(texframe.th);
v = RenderSetTargetInvTex(bInterlace, texframe.tw, texframe.th, &ppsCRTC[bInterlace]);
Vector valpha = RenderGetForClip(bInterlace, interlace, texframe.psm, &ppsCRTC[bInterlace]);
float4 valpha = RenderGetForClip(bInterlace, interlace, texframe.psm, &ppsCRTC[bInterlace]);
ZZshGLSetTextureParameter(ppsCRTC[bInterlace].sMemory, vb[0].pmemtarg->ptex->tex, "CRTC memory");
RenderCreateInterlaceTex(bInterlace, texframe.th, &ppsCRTC[bInterlace]);

View File

@ -63,7 +63,7 @@ extern int s_nNewWidth, s_nNewHeight;
extern CRangeManager s_RangeMngr; // manages overwritten memory
extern void FlushTransferRanges(const tex0Info* ptex);
extern void ProcessMessages();
void AdjustTransToAspect(Vector& v);
void AdjustTransToAspect(float4& v);
// Interlace texture is lazy 1*(height) array of 1 and 0.
// If its height (named s_nInterlaceTexWidth here) is hanging we must redo

View File

@ -156,7 +156,7 @@ int s_nWriteDestAlphaTest = 0; // ZZ
////////////////////
// State parameters
static Vector vAlphaBlendColor; // used for GPU_COLOR
static float4 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
@ -832,11 +832,11 @@ inline int FlushGetShaderType(VB& curvb, CRenderTarget* ptextarg, GLuint& ptexcl
//Set page offsets depends on shader type.
inline Vector FlushSetPageOffset(FRAGMENTSHADER* pfragment, int shadertype, CRenderTarget* ptextarg)
inline float4 FlushSetPageOffset(FRAGMENTSHADER* pfragment, int shadertype, CRenderTarget* ptextarg)
{
SetShaderCaller("FlushSetPageOffset");
Vector vpageoffset;
float4 vpageoffset;
vpageoffset.w = 0;
switch (shadertype)
@ -865,14 +865,14 @@ inline Vector FlushSetPageOffset(FRAGMENTSHADER* pfragment, int shadertype, CRen
}
//Set texture offsets depends omn shader type.
inline Vector FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& curvb, CRenderTarget* ptextarg)
inline float4 FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& curvb, CRenderTarget* ptextarg)
{
SetShaderCaller("FlushSetTexOffset");
Vector v;
float4 v;
if (shadertype == 3)
{
Vector v;
float4 v;
v.x = 16.0f / (float)curvb.tex0.tw;
v.y = 16.0f / (float)curvb.tex0.th;
v.z = 0.5f * v.x;
@ -881,7 +881,7 @@ inline Vector FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& c
}
else if (shadertype == 4)
{
Vector v;
float4 v;
v.x = 16.0f / (float)ptextarg->fbw;
v.y = 16.0f / (float)ptextarg->fbh;
v.z = -1;
@ -893,10 +893,10 @@ inline Vector FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& c
}
// Set dimension (Real!) of texture. z and w
inline Vector FlushTextureDims(FRAGMENTSHADER* pfragment, int shadertype, VB& curvb, CRenderTarget* ptextarg)
inline float4 FlushTextureDims(FRAGMENTSHADER* pfragment, int shadertype, VB& curvb, CRenderTarget* ptextarg)
{
SetShaderCaller("FlushTextureDims");
Vector vTexDims;
float4 vTexDims;
vTexDims.x = (float)RW(curvb.tex0.tw) ;
vTexDims.y = (float)RH(curvb.tex0.th) ;
@ -963,11 +963,11 @@ inline FRAGMENTSHADER* FlushUseExistRenderTarget(VB& curvb, CRenderTarget* ptext
FRAGMENTSHADER* pfragment = LoadShadeEffect(shadertype, 0, curvb.curprim.fge,
IsAlphaTestExpansion(curvb.tex0), exactcolor, curvb.clamp, context, NULL);
Vector vpageoffset = FlushSetPageOffset(pfragment, shadertype, ptextarg);
float4 vpageoffset = FlushSetPageOffset(pfragment, shadertype, ptextarg);
Vector v = FlushSetTexOffset(pfragment, shadertype, curvb, ptextarg);
float4 v = FlushSetTexOffset(pfragment, shadertype, curvb, ptextarg);
Vector vTexDims = FlushTextureDims(pfragment, shadertype, curvb, ptextarg);
float4 vTexDims = FlushTextureDims(pfragment, shadertype, curvb, ptextarg);
if (pfragment->sCLUT != NULL && ptexclut != 0)
ZZshGLSetTextureParameter(pfragment->sCLUT, ptexclut, "CLUT");
@ -1162,7 +1162,7 @@ inline u32 AlphaRenderAlpha(VB& curvb, const pixTest curtest, FRAGMENTSHADER* pf
}
// harvest fishing
Vector v = vAlphaBlendColor;
float4 v = vAlphaBlendColor;
if (exactcolor)
{
@ -1175,7 +1175,7 @@ inline u32 AlphaRenderAlpha(VB& curvb, const pixTest curtest, FRAGMENTSHADER* pf
else
{
// not using blending so set to defaults
Vector v = exactcolor ? Vector(1, 510 * 255.0f / 256.0f, 0, 0) : Vector(1, 2 * 255.0f / 256.0f, 0, 0);
float4 v = exactcolor ? float4(1, 510 * 255.0f / 256.0f, 0, 0) : float4(1, 2 * 255.0f / 256.0f, 0, 0);
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
}
@ -1259,7 +1259,7 @@ inline void AlphaPabe(VB& curvb, FRAGMENTSHADER* pfragment, int exactcolor)
glDisable(GL_BLEND);
GL_STENCILFUNC_SET();
Vector v;
float4 v;
v.x = 1;
v.y = 2;
v.z = 0;
@ -1332,7 +1332,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
if (gs.pabe && bCanRenderStencil)
{
// only render the pixels with alpha values >= 0x80
Vector v = vAlphaBlendColor;
float4 v = vAlphaBlendColor;
if (exactcolor) { v.y *= 255; v.w *= 255; }
@ -1352,7 +1352,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
glDisable(GL_BLEND);
GL_STENCILFUNC_SET();
Vector v;
float4 v;
v.x = 1;
v.y = 2;
v.z = 0;
@ -1411,7 +1411,7 @@ inline void AlphaSpecialTesting(VB& curvb, FRAGMENTSHADER* pfragment, u32 dwUsin
glStencilFunc(GL_EQUAL, STENCIL_SPECIAL | STENCIL_PIXELWRITE, STENCIL_SPECIAL | STENCIL_PIXELWRITE);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
Vector v = Vector(0, exactcolor ? 510.0f : 2.0f, 0, 0);
float4 v = float4(0, exactcolor ? 510.0f : 2.0f, 0, 0);
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
Draw(curvb);
@ -1623,7 +1623,7 @@ inline void ZeroGS::RenderFBA(const VB& curvb, ZZshParameter sOneColor)
glAlphaFunc(GL_GEQUAL, 1);
Vector v(1,2,0,0);
float4 v(1,2,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor");
@ -1662,7 +1662,7 @@ __forceinline void ZeroGS::RenderAlphaTest(const VB& curvb, ZZshParameter sOneCo
SetShaderCaller("RenderAlphaTest");
Vector v(1,2,0,0);
float4 v(1,2,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor");
@ -1687,7 +1687,7 @@ __forceinline void ZeroGS::RenderAlphaTest(const VB& curvb, ZZshParameter sOneCo
if (curvb.test.ate && curvb.test.atst > 1 && curvb.test.aref > 0x80)
{
v = Vector(1,1,0,0);
v = float4(1,1,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor");
glAlphaFunc(g_dwAlphaCmp[curvb.test.atst], AlphaReferedValue(curvb.test.aref));
}
@ -1993,7 +1993,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment)
FUNCLOG
SetShaderCaller("SetTexClamping");
clampInfo* pclamp = &ZeroGS::vb[context].clamp;
Vector v, v2;
float4 v, v2;
v.x = v.y = 0;
u32* ptex = ZeroGS::vb[context].ptexClamp;
ptex[0] = ptex[1] = 0;
@ -2078,8 +2078,8 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment)
}
// Fixme should be in Vector lib
inline bool equal_vectors(Vector a, Vector b)
// Fixme should be in float4 lib
inline bool equal_vectors(float4 a, float4 b)
{
if (abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z) + abs(a.w - b.w) < 0.01)
return true;
@ -2096,7 +2096,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
assert(!vb[context].bNeedTexCheck);
Vector v, v2;
float4 v, v2;
tex0Info& tex0 = vb[context].tex0;
@ -2108,14 +2108,14 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
SetShaderCaller("SetTexVariables");
// alpha and texture highlighting
Vector valpha, valpha2 ;
float4 valpha, valpha2 ;
// if clut, use the frame format
int psm = PIXEL_STORAGE_FORMAT(tex0);
// ZZLog::Error_Log( "A %d psm, is-clut %d. cpsm %d | %d %d", psm, PSMT_ISCLUT(psm), tex0.cpsm, tex0.tfx, tex0.tcc );
Vector vblack;
float4 vblack;
vblack.x = vblack.y = vblack.z = vblack.w = 10;
/* tcc -- Tecture Color Component 0=RGB, 1=RGBA + use Alpha from TEXA reg when not in PSM
@ -2159,7 +2159,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
/*
// Test, old code.
Vector valpha3, valpha4;
float4 valpha3, valpha4;
switch(tex0.tfx) {
case 0:
valpha3.z = 0; valpha3.w = 0;
@ -2269,7 +2269,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
void ZeroGS::SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0, bool CheckVB, FRAGMENTSHADER* pfragment, int force)
{
FUNCLOG
Vector v;
float4 v;
CMemoryTarget* pmemtarg = g_MemTargs.GetMemoryTarget(tex0, 1);
assert( pmemtarg != NULL && pfragment != NULL && pmemtarg->ptex != NULL);
@ -2311,7 +2311,7 @@ void ZeroGS::SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0,
float fbw = (float)tex0.tbw;
Vector vTexDims;
float4 vTexDims;
vTexDims.x = b.vTexDims.x * (fw);
vTexDims.y = b.vTexDims.y * (fh);
@ -2354,7 +2354,7 @@ void ZeroGS::SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0,
ZZshSetParameter4fv(pfragment->fTexDims, vTexDims, "g_fTexDims");
// ZZshSetParameter4fv(pfragment->fTexBlock, b.vTexBlock, "g_fTexBlock"); // I change it, and it's working. Seems casting from Vector to float[4] is ok.
// ZZshSetParameter4fv(pfragment->fTexBlock, b.vTexBlock, "g_fTexBlock"); // I change it, and it's working. Seems casting from float4 to float[4] is ok.
ZZshSetParameter4fv(pfragment->fTexBlock, &b.vTexBlock.x, "g_fTexBlock");
ZZshSetParameter4fv(pfragment->fTexOffset, v, "g_fTexOffset");
@ -2466,7 +2466,7 @@ void ZeroGS::SetAlphaVariables(const alphaInfo& a)
s_rgbeq = 1;
// s_alphaInfo = a;
vAlphaBlendColor = Vector(1, 2 * 255.0f / 256.0f, 0, 0);
vAlphaBlendColor = float4(1, 2 * 255.0f / 256.0f, 0, 0);
u32 usec = a.c;

View File

@ -2,12 +2,15 @@
*
* Zerofrog's ZeroGS KOSMOS (c)2005-2008
*
* Zerofrog forgot to write any copyright notice after release the plugin into GPLv2
* Zerofrog forgot to write any copyright notice after releasing the plugin into GPLv2
* If someone can contact him successfully to clarify this matter that would be great.
*/
#ifndef ZEROGS_MATH_H
#define ZEROGS_MATH_H
// Now that it's down to 82 lines, and most of it's fairly obvious, perhaps it'd be easier to
// just reimplement it... -arcum42
#ifndef ZZOGLMATH_H_INCLUDED
#define ZZOGLMATH_H_INCLUDED
#ifndef _WIN32
#include <alloca.h>
@ -22,16 +25,16 @@ typedef float dReal;
// class used for 3 and 4 dim vectors and quaternions
// It is better to use this for a 3 dim vector because it is 16byte aligned and SIMD instructions can be used
class Vector
class float4
{
public:
dReal x, y, z, w;
Vector() : x(0), y(0), z(0), w(0) {}
Vector(dReal x, dReal y, dReal z) : x(x), y(y), z(z), w(0) {}
Vector(dReal x, dReal y, dReal z, dReal w) : x(x), y(y), z(z), w(w) {}
Vector(const Vector &vec) : x(vec.x), y(vec.y), z(vec.z), w(vec.w) {}
Vector(const dReal* pf) { assert(pf != NULL); x = pf[0]; y = pf[1]; z = pf[2]; w = 0; }
float4() : x(0), y(0), z(0), w(0) {}
float4(dReal x, dReal y, dReal z) : x(x), y(y), z(z), w(0) {}
float4(dReal x, dReal y, dReal z, dReal w) : x(x), y(y), z(z), w(w) {}
float4(const float4 &vec) : x(vec.x), y(vec.y), z(vec.z), w(vec.w) {}
float4(const dReal* pf) { assert(pf != NULL); x = pf[0]; y = pf[1]; z = pf[2]; w = 0; }
dReal operator[](int i) const { return (&x)[i]; }
dReal& operator[](int i) { return (&x)[i]; }
@ -40,7 +43,7 @@ class Vector
operator const dReal*() const { return (const dReal*)&x; }
// SCALAR FUNCTIONS
inline dReal dot(const Vector &v) const { return x*v.x + y*v.y + z*v.z + w*v.w; }
inline dReal dot(const float4 &v) const { return x*v.x + y*v.y + z*v.z + w*v.w; }
inline void Set3(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; }
inline void Set4(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; w = pvals[3]; }
inline void SetColor(u32 color)
@ -53,28 +56,28 @@ class Vector
// 3 dim cross product, w is not touched
/// this = this x v
/// this = u x v
inline Vector operator-() const { Vector v; v.x = -x; v.y = -y; v.z = -z; v.w = -w; return v; }
inline Vector operator+(const Vector &r) const { Vector v; v.x = x + r.x; v.y = y + r.y; v.z = z + r.z; v.w = w + r.w; return v; }
inline Vector operator-(const Vector &r) const { Vector v; v.x = x - r.x; v.y = y - r.y; v.z = z - r.z; v.w = w - r.w; return v; }
inline Vector operator*(const Vector &r) const { Vector v; v.x = r.x * x; v.y = r.y * y; v.z = r.z * z; v.w = r.w * w; return v; }
inline Vector operator*(dReal k) const { Vector v; v.x = k * x; v.y = k * y; v.z = k * z; v.w = k * w; return v; }
inline Vector& operator += (const Vector& r) { x += r.x; y += r.y; z += r.z; w += r.w; return *this; }
inline Vector& operator -= (const Vector& r) { x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; }
inline Vector& operator *= (const Vector& r) { x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; }
inline Vector& operator *= (const dReal k) { x *= k; y *= k; z *= k; w *= k; return *this; }
inline Vector& operator /= (const dReal _k) { dReal k = 1 / _k; x *= k; y *= k; z *= k; w *= k; return *this; }
friend Vector operator*(float f, const Vector& v);
//friend ostream& operator<<(ostream& O, const Vector& v);
//friend istream& operator>>(istream& I, Vector& v);
inline float4 operator-() const { float4 v; v.x = -x; v.y = -y; v.z = -z; v.w = -w; return v; }
inline float4 operator+(const float4 &r) const { float4 v; v.x = x + r.x; v.y = y + r.y; v.z = z + r.z; v.w = w + r.w; return v; }
inline float4 operator-(const float4 &r) const { float4 v; v.x = x - r.x; v.y = y - r.y; v.z = z - r.z; v.w = w - r.w; return v; }
inline float4 operator*(const float4 &r) const { float4 v; v.x = r.x * x; v.y = r.y * y; v.z = r.z * z; v.w = r.w * w; return v; }
inline float4 operator*(dReal k) const { float4 v; v.x = k * x; v.y = k * y; v.z = k * z; v.w = k * w; return v; }
inline float4& operator += (const float4& r) { x += r.x; y += r.y; z += r.z; w += r.w; return *this; }
inline float4& operator -= (const float4& r) { x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; }
inline float4& operator *= (const float4& r) { x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; }
inline float4& operator *= (const dReal k) { x *= k; y *= k; z *= k; w *= k; return *this; }
inline float4& operator /= (const dReal _k) { dReal k = 1 / _k; x *= k; y *= k; z *= k; w *= k; return *this; }
friend float4 operator*(float f, const float4& v);
//friend ostream& operator<<(ostream& O, const float4& v);
//friend istream& operator>>(istream& I, float4& v);
};
inline Vector operator*(float f, const Vector& left)
inline float4 operator*(float f, const float4& left)
{
Vector v;
float4 v;
v.x = f * left.x;
v.y = f * left.y;
v.z = f * left.z;
return v;
}
#endif
#endif // ZZOGLMATH_H_INCLUDED

View File

@ -192,7 +192,7 @@ void ZZshGLSetTextureParameter(ZZshParameter param, GLuint texobj, const char* n
// Used sometimes for color 1.
void ZZshDefaultOneColor( FRAGMENTSHADER ptr ) {
ShaderHandleName = "Set Default One color";
Vector v = Vector ( 1, 1, 1, 1 );
float4 v = float4 ( 1, 1, 1, 1 );
ZZshSetParameter4fv( ptr.sOneColor, v, "DefaultOne");
}
@ -258,11 +258,11 @@ void SetupFragmentProgramParameters(FRAGMENTSHADER* pf, int context, int type)
pf->set_texture(pf->sInterlace, "g_sInterlace");
// set global shader constants
pf->set_shader_const(Vector(0.5f, (conf.settings().exact_color) ? 0.9f / 256.0f : 0.5f / 256.0f, 0, 1 / 255.0f), "g_fExactColor");
pf->set_shader_const(Vector(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f), "g_fBilinear");
pf->set_shader_const(Vector(1.0f / 256.0f, 1.0004f, 1, 0.5f), "g_fZBias");
pf->set_shader_const(Vector(0, 1, 0.001f, 0.5f), "g_fc0");
pf->set_shader_const(Vector(1 / 1024.0f, 0.2f / 1024.0f, 1 / 128.0f, 1 / 512.0f), "g_fMult");
pf->set_shader_const(float4(0.5f, (conf.settings().exact_color) ? 0.9f / 256.0f : 0.5f / 256.0f, 0, 1 / 255.0f), "g_fExactColor");
pf->set_shader_const(float4(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f), "g_fBilinear");
pf->set_shader_const(float4(1.0f / 256.0f, 1.0004f, 1, 0.5f), "g_fZBias");
pf->set_shader_const(float4(0, 1, 0.001f, 0.5f), "g_fc0");
pf->set_shader_const(float4(1 / 1024.0f, 0.2f / 1024.0f, 1 / 128.0f, 1 / 512.0f), "g_fMult");
}
static bool outdated_shaders = false;
@ -279,13 +279,13 @@ void SetupVertexProgramParameters(ZZshProgram prog, int context)
// Set Z-test, log or no log;
if (conf.settings().no_logz)
{
g_vdepth = Vector(255.0 / 256.0f, 255.0 / 65536.0f, 255.0f / (65535.0f * 256.0f), 1.0f / (65536.0f * 65536.0f));
vlogz = Vector(1.0f, 0.0f, 0.0f, 0.0f);
g_vdepth = float4(255.0 / 256.0f, 255.0 / 65536.0f, 255.0f / (65535.0f * 256.0f), 1.0f / (65536.0f * 65536.0f));
vlogz = float4(1.0f, 0.0f, 0.0f, 0.0f);
}
else
{
g_vdepth = Vector(256.0f * 65536.0f, 65536.0f, 256.0f, 65536.0f * 65536.0f);
vlogz = Vector(0.0f, 1.0f, 0.0f, 0.0f);
g_vdepth = float4(256.0f * 65536.0f, 65536.0f, 256.0f, 65536.0f * 65536.0f);
vlogz = float4(0.0f, 1.0f, 0.0f, 0.0f);
}
p = cgGetNamedParameter(prog, "g_fZ");
@ -311,7 +311,7 @@ void SetupVertexProgramParameters(ZZshProgram prog, int context)
}
}
Vector vnorm = Vector(g_filog32, 0, 0, 0);
float4 vnorm = float4(g_filog32, 0, 0, 0);
p = cgGetNamedParameter(prog, "g_fZNorm");
@ -321,17 +321,17 @@ void SetupVertexProgramParameters(ZZshProgram prog, int context)
p = cgGetNamedParameter(prog, "g_fBilinear");
if (p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE)
cgGLSetParameter4fv(p, Vector(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f));
cgGLSetParameter4fv(p, float4(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f));
p = cgGetNamedParameter(prog, "g_fZBias");
if (p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE)
cgGLSetParameter4fv(p, Vector(1.0f / 256.0f, 1.0004f, 1, 0.5f));
cgGLSetParameter4fv(p, float4(1.0f / 256.0f, 1.0004f, 1, 0.5f));
p = cgGetNamedParameter(prog, "g_fc0");
if (p != NULL && cgIsParameterUsed(p, prog) == CG_TRUE)
cgGLSetParameter4fv(p, Vector(0, 1, 0.001f, 0.5f));
cgGLSetParameter4fv(p, float4(0, 1, 0.001f, 0.5f));
}
#ifndef DEVBUILD

View File

@ -145,7 +145,7 @@ struct FRAGMENTSHADER
return false;
}
bool set_shader_const(Vector v, const char *name)
bool set_shader_const(float4 v, const char *name)
{
ZZshParameter p;
@ -176,8 +176,8 @@ struct VERTEXSHADER
namespace ZeroGS {
// Shaders variables
extern Vector g_vdepth;
extern Vector vlogz;
extern float4 g_vdepth;
extern float4 vlogz;
extern VERTEXSHADER pvsBitBlt;
extern FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne; // ppsOne used to stop using shaders for draw
extern FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;

View File

@ -123,9 +123,9 @@ inline void FillOnlyStencilBuffer()
// used for transformation from vertex position in GS window.coords (I hope)
// to view coordinates (in range 0, 1).
inline Vector ZeroGS::CRenderTarget::DefaultBitBltPos()
inline float4 ZeroGS::CRenderTarget::DefaultBitBltPos()
{
Vector v = Vector(1, -1, 0.5f / (float)RW(fbw), 0.5f / (float)RH(fbh));
float4 v = float4(1, -1, 0.5f / (float)RW(fbw), 0.5f / (float)RH(fbh));
v *= 1.0f / 32767.0f;
ZZshSetParameter4fv(pvsBitBlt.sBitBltPos, v, "g_sBitBltPos");
return v;
@ -133,11 +133,11 @@ inline Vector ZeroGS::CRenderTarget::DefaultBitBltPos()
// Used to transform texture coordinates from GS (when 0,0 is upper left) to
// OpenGL (0,0 - lower left).
inline Vector ZeroGS::CRenderTarget::DefaultBitBltTex()
inline float4 ZeroGS::CRenderTarget::DefaultBitBltTex()
{
// I really sure that -0.5 is correct, because OpenGL have no half-offset
// issue, DirectX known for.
Vector v = Vector(1, -1, 0.5f / (float)RW(fbw), -0.5f / (float)RH(fbh));
float4 v = float4(1, -1, 0.5f / (float)RW(fbw), -0.5f / (float)RH(fbh));
ZZshSetParameter4fv(pvsBitBlt.sBitBltTex, v, "g_sBitBltTex");
return v;
}
@ -223,7 +223,7 @@ void ZeroGS::CRenderTarget::SetTarget(int fbplocal, const Rect2& scissor, int co
if (fbplocal != fbp)
{
Vector v;
float4 v;
// will be rendering to a subregion
u32 bpp = PSMT_ISHALF(psm) ? 2 : 4;
@ -402,7 +402,7 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
((CDepthTarget*)pdepth)->SetDepthStencilSurface();
SetShaderCaller("CRenderTarget::Update");
Vector v = DefaultBitBltPos();
float4 v = DefaultBitBltPos();
CRenderTargetMngr::MAPTARGETS::iterator ittarg;
@ -475,7 +475,7 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
SetTexVariablesInt(0, 0, texframe, false, &ppsBitBlt[bit_idx], 1);
ZZshGLSetTextureParameter(ppsBitBlt[bit_idx].sMemory, vb[0].pmemtarg->ptex->tex, "BitBlt.memory");
v = Vector(1, 1, 0.0f, 0.0f);
v = float4(1, 1, 0.0f, 0.0f);
ZZshSetParameter4fv(pvsBitBlt.sBitBltTex, v, "g_fBitBltTex");
v.x = 1;
@ -537,7 +537,7 @@ void ZeroGS::CRenderTarget::ConvertTo32()
SetShaderCaller("CRenderTarget::ConvertTo32");
// tex coords, test ffx bikanel island when changing these
Vector v = DefaultBitBltPos();
float4 v = DefaultBitBltPos();
v = DefaultBitBltTex();
v.x = (float)RW(16);
@ -641,7 +641,7 @@ void ZeroGS::CRenderTarget::ConvertTo16()
SetShaderCaller("CRenderTarget::ConvertTo16");
// tex coords, test ffx bikanel island when changing these
Vector v = DefaultBitBltPos();
float4 v = DefaultBitBltPos();
v = DefaultBitBltTex();
v.x = 16.0f / (float)fbw;
@ -749,16 +749,16 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
ResetRenderTarget(1);
// tex coords, test ffx bikanel island when changing these
/* Vector v = DefaultBitBltPos();
v = Vector ((float)(RW(fbw+4)), (float)(RH(fbh+4)), +0.25f, -0.25f);
/* float4 v = DefaultBitBltPos();
v = float4 ((float)(RW(fbw+4)), (float)(RH(fbh+4)), +0.25f, -0.25f);
ZZshSetParameter4fv(pvsBitBlt.sBitBltTex, v, "BitBltTex");*/
// tex coords, test ffx bikanel island when changing these
// Vector v = Vector(1, -1, 0.5f / (fbw << AA.x), 0.5f / (fbh << AA.y));
// float4 v = float4(1, -1, 0.5f / (fbw << AA.x), 0.5f / (fbh << AA.y));
// v *= 1/32767.0f;
// cgGLSetParameter4fv(pvsBitBlt.sBitBltPos, v);
Vector v = DefaultBitBltPos();
float4 v = DefaultBitBltPos();
v.x = (float)(RW(fbw));
v.y = (float)(RH(fbh));
@ -979,7 +979,7 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
SetTexVariablesInt(0, 0, texframe, false, &ppsBitBltDepth, 1);
ZZshGLSetTextureParameter(ppsBitBltDepth.sMemory, vb[0].pmemtarg->ptex->tex, "BitBltDepth");
Vector v = DefaultBitBltPos();
float4 v = DefaultBitBltPos();
v = DefaultBitBltTex();
@ -989,7 +989,7 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
v.w = g_filog32;
ZZshSetParameter4fv(ppsBitBltDepth.sOneColor, v, "g_fOneColor");
Vector vdepth = g_vdepth;
float4 vdepth = g_vdepth;
if (psm == PSMT24Z)
{

View File

@ -228,7 +228,7 @@ inline list<ZeroGS::CRenderTarget*> CreateTargetsList(int start, int end)
return listTargs;
}
extern Vector g_vdepth;
extern float4 g_vdepth;
extern int icurctx;
extern GLuint vboRect;

View File

@ -29,7 +29,6 @@
#include "Mem.h"
#include "x86.h"
#include "zerogs.h"
#include "zpipe.h"
#include "targets.h"
#include "GLWin.h"
#include "ZZoglShaders.h"
@ -94,10 +93,10 @@ int nBackbufferWidth, nBackbufferHeight; // ZZ
namespace ZeroGS
{
Vector g_vdepth, vlogz;
float4 g_vdepth, vlogz;
// = Vector( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f));
// Vector g_vdepth = Vector( 65536.0f*65536.0f, 256.0f*65536.0f, 65536.0f, 256.0f);
// = float4( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f));
// float4 g_vdepth = float4( 65536.0f*65536.0f, 256.0f*65536.0f, 65536.0f, 256.0f);
extern CRangeManager s_RangeMngr; // manages overwritten memory
GLenum GetRenderTargetFormat() { return GetRenderFormat() == RFT_byte8 ? 4 : g_internalRGBAFloat16Fmt; }
@ -342,7 +341,7 @@ void ZeroGS::DrawText(const char* pstr, int left, int top, u32 color)
FUNCLOG
ZZshGLDisableProfile();
Vector v;
float4 v;
v.SetColor(color);
glColor3f(v.z, v.y, v.x);
//glColor3f(((color >> 16) & 0xff) / 255.0f, ((color >> 8) & 0xff)/ 255.0f, (color & 0xff) / 255.0f);
@ -491,7 +490,7 @@ void ZeroGS::RenderCustom(float fAlpha)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// tex coords
Vector v = Vector(1 / 32767.0f, 1 / 32767.0f, 0, 0);
float4 v = float4(1 / 32767.0f, 1 / 32767.0f, 0, 0);
ZZshSetParameter4fv(pvsBitBlt.sBitBltPos, v, "g_fBitBltPos");
v.x = (float)nLogoWidth;
v.y = (float)nLogoHeight;
@ -782,7 +781,7 @@ void ZeroGS::SetFogColor(u32 fog)
ZeroGS::FlushBoth();
SetShaderCaller("SetFogColor");
Vector v;
float4 v;
// set it immediately
v.SetColor(gs.fogcol);
@ -796,7 +795,7 @@ void ZeroGS::SetFogColor(GIFRegFOGCOL* fog)
FUNCLOG
SetShaderCaller("SetFogColor");
Vector v;
float4 v;
v.x = fog->FCR / 255.0f;
v.y = fog->FCG / 255.0f;

View File

@ -142,7 +142,7 @@ class CRenderTarget
int fbp, fbw, fbh, fbhCalc; // if fbp is negative, virtual target (not mapped to any real addr)
int start, end; // in bytes
u32 lastused; // time stamp since last used
Vector vposxy;
float4 vposxy;
u32 fbm;
u16 status;
@ -167,8 +167,8 @@ class CRenderTarget
TS_NeedConvert32 = 16,
TS_NeedConvert16 = 32,
};
inline Vector DefaultBitBltPos() ;
inline Vector DefaultBitBltTex() ;
inline float4 DefaultBitBltPos();
inline float4 DefaultBitBltTex();
private:
void _CreateFeedback();