mirror of https://github.com/PCSX2/pcsx2.git
zzogl: Misc cleanup.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3751 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
45eb60439a
commit
48f3a6d273
|
@ -117,6 +117,7 @@ enum PSM_value
|
|||
|
||||
// Check target bit mode. PSMCT32 and 32Z return 0, 24 and 24Z - 1
|
||||
// 16, 16S, 16Z, 16SZ -- 2, PSMT8 and 8H - 3, PSMT4, 4HL, 4HH -- 4.
|
||||
// This code returns the same value on Z-textures, so texel storage mode is (BITMODE and !ISZTEX).
|
||||
inline int PSMT_BITMODE(int psm) {return (psm & 0x7);}
|
||||
|
||||
inline int PSMT_BITS_NUM(int psm)
|
||||
|
@ -168,6 +169,11 @@ inline bool PSMT_IS16Z(int psm) {return ((psm & 0x32) == 0x32);}
|
|||
// I'll have to look closer at it, because it'd seem like it'd return true for 24 bits.
|
||||
inline bool PSMT_IS32BIT(int psm) {return !!(psm <= 1);}
|
||||
|
||||
// When color format is RGB24 (PSMCT24) or RGBA16 (PSMCT16 & 16S) alpha value expanded, based on
|
||||
// TEXA register and AEM status.
|
||||
inline int PSMT_ALPHAEXP(int psm) {return (psm == PSMCT24 || psm == PSMCT16 || psm == PSMCT16S);}
|
||||
|
||||
|
||||
// This function updates the 6th and 5th bit of psm
|
||||
// 00 or 11 -> 00 ; 01 -> 10 ; 10 -> 01
|
||||
inline int Switch_Top_Bytes (int X) {
|
||||
|
@ -177,6 +183,19 @@ inline int Switch_Top_Bytes (int X) {
|
|||
return (X ^ 0x30);
|
||||
}
|
||||
|
||||
// How many pixel stored in 1 word.
|
||||
// PSMT8 has 4 pixels per 32bit, PSMT4 has 8. All 16-bit textures are 2 pixel per bit. And all others are 1 pixel in texture.
|
||||
inline int PIXELS_PER_WORD(int psm)
|
||||
{
|
||||
if (psm == PSMT8)
|
||||
return 4;
|
||||
if (psm == PSMT4)
|
||||
return 8;
|
||||
if (PSMT_IS16BIT(psm))
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Some storage formats could share the same memory block (2 textures in 1 format). This include following combinations:
|
||||
// PSMT24(24Z) with either 8H, 4HL, 4HH and PSMT4HL with PSMT4HH.
|
||||
// We use slightly different versions of this function on comparison with GSDX, Storage format XOR 0x30 made Z-textures
|
||||
|
@ -589,14 +608,17 @@ inline float Clamp(float fx, float fmin, float fmax)
|
|||
return fx > fmax ? fmax : fx;
|
||||
}
|
||||
|
||||
// PSMT16, 16S have shorter color per pixel, also cluted textures with half storage.
|
||||
inline bool PSMT_ISHALF_STORAGE(const tex0Info& tex0)
|
||||
{
|
||||
if (PSMT_IS16BIT(tex0.psm) || (PSMT_ISCLUT(tex0.psm) && tex0.cpsm > 1))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
// Get pixel storage format from tex0. Clutted textures store pixels in cpsm format.
|
||||
inline int PIXEL_STORAGE_FORMAT(const tex0Info& tex) {
|
||||
if (PSMT_ISCLUT(tex.psm))
|
||||
return tex.cpsm;
|
||||
else
|
||||
return tex.psm;
|
||||
}
|
||||
|
||||
// If pixel storage format not PSMCT24 ot PSMCT32, then it is 16-bit.
|
||||
// Z-textures have 0x30 upper bits, so we eliminate them by &&(~0x30)
|
||||
inline bool PSMT_ISHALF_STORAGE(const tex0Info& tex0) { return ((PIXEL_STORAGE_FORMAT(tex0) & (~0x30)) > 1); }
|
||||
|
||||
//--------------------------- Inlines for bitwise ops
|
||||
//--------------------------- textures
|
||||
|
|
|
@ -111,6 +111,7 @@ void __gifCall GIFPackedRegHandlerRGBA(const u32* data)
|
|||
void __gifCall GIFPackedRegHandlerSTQ(const u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
// Despite this code generating a warning, it's correct. float -> float reduction. S and Y are missed mantissas.
|
||||
*(u32*)&gs.vertexregs.s = data[0] & 0xffffff00;
|
||||
*(u32*)&gs.vertexregs.t = data[1] & 0xffffff00;
|
||||
*(u32*)&gs.q = data[2];
|
||||
|
|
|
@ -352,6 +352,6 @@ extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
|
|||
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
|
||||
#endif
|
||||
|
||||
|
||||
extern bool g_bDisplayFPS; // should we display FPS on screen?
|
||||
|
||||
#endif // UTIL_H_INCLUDED
|
||||
|
|
|
@ -96,7 +96,6 @@ void ProcessAASetting(bool reverse)
|
|||
void ProcessFPS()
|
||||
{
|
||||
FUNCLOG
|
||||
extern bool g_bDisplayFPS;
|
||||
g_bDisplayFPS ^= 1;
|
||||
ZZLog::Debug_Log("Toggled FPS.");
|
||||
}
|
||||
|
|
|
@ -66,17 +66,6 @@
|
|||
}
|
||||
|
||||
#define GL_BLEND_SET() zgsBlendFuncSeparateEXT(s_srcrgb, s_dstrgb, s_srcalpha, s_dstalpha)
|
||||
|
||||
#define GL_STENCILFUNC(func, ref, mask) { \
|
||||
s_stencilfunc = func; \
|
||||
s_stencilref = ref; \
|
||||
s_stencilmask = mask; \
|
||||
glStencilFunc(func, ref, mask); \
|
||||
}
|
||||
|
||||
#define GL_STENCILFUNC_SET() glStencilFunc(s_stencilfunc, s_stencilref, s_stencilmask)
|
||||
|
||||
#define VB_BUFFERSIZE 0x400
|
||||
#define VB_NUMBUFFERS 512
|
||||
|
||||
// ----------------- Types
|
||||
|
@ -139,7 +128,6 @@ void (APIENTRY *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum) = NULL;
|
|||
//------------------ variables
|
||||
////////////////////////////
|
||||
// State parameters
|
||||
float fiRendWidth, fiRendHeight;
|
||||
|
||||
extern u8* s_lpShaderResources;
|
||||
CGprogram pvs[16] = {NULL};
|
||||
|
@ -167,6 +155,8 @@ int nLogoWidth, nLogoHeight;
|
|||
u32 s_ptexInterlace = 0; // holds interlace fields
|
||||
|
||||
//------------------ Global Variables
|
||||
int GPU_TEXWIDTH = 512;
|
||||
float g_fiGPU_TEXWIDTH = 1/512.0f;
|
||||
int g_MaxTexWidth = 4096, g_MaxTexHeight = 4096;
|
||||
u32 s_uFramebuffer = 0;
|
||||
CGprofile cgvProf, cgfProf;
|
||||
|
@ -179,7 +169,6 @@ float g_fBlockMult = 1;
|
|||
u32 ptexBlocks = 0, ptexConv16to32 = 0; // holds information on block tiling
|
||||
u32 ptexBilinearBlocks = 0;
|
||||
u32 ptexConv32to16 = 0;
|
||||
bool g_bDisplayMsg = 1;
|
||||
int g_nDepthBias = 0;
|
||||
//u32 g_bSaveFlushedFrame = 0;
|
||||
|
||||
|
@ -190,13 +179,10 @@ bool ZeroGS::IsGLExt(const char* szTargetExtension)
|
|||
return mapGLExtensions.find(string(szTargetExtension)) != mapGLExtensions.end();
|
||||
}
|
||||
|
||||
inline bool
|
||||
ZeroGS::Create_Window(int _width, int _height)
|
||||
inline bool ZeroGS::Create_Window(int _width, int _height)
|
||||
{
|
||||
nBackbufferWidth = _width;
|
||||
nBackbufferHeight = _height;
|
||||
fiRendWidth = 1.0f / nBackbufferWidth;
|
||||
fiRendHeight = 1.0f / nBackbufferHeight;
|
||||
|
||||
if (!GLWin.DisplayWindow(_width, _height)) return false;
|
||||
|
||||
|
@ -501,10 +487,10 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
// Limit the texture size supported to 8192. We do not need bigger texture.
|
||||
// Besides the following assertion is false when texture are too big.
|
||||
// ZZoglFlush.cpp:2349: assert(fblockstride >= 1.0f)
|
||||
g_MaxTexWidth = min(8192, g_MaxTexWidth);
|
||||
//g_MaxTexWidth = min(8192, g_MaxTexWidth);
|
||||
|
||||
g_MaxTexHeight = g_MaxTexWidth / 4;
|
||||
GPU_TEXWIDTH = g_MaxTexWidth / 8;
|
||||
GPU_TEXWIDTH = min (g_MaxTexWidth/8, 1024);
|
||||
g_fiGPU_TEXWIDTH = 1.0f / GPU_TEXWIDTH;
|
||||
|
||||
if (!CreateOpenShadersFile()) return false;
|
||||
|
@ -837,9 +823,6 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
|
||||
B_G(LoadEffects(), return false);
|
||||
|
||||
g_bDisplayMsg = 0;
|
||||
|
||||
|
||||
// create a sample shader
|
||||
clampInfo temp;
|
||||
|
||||
|
@ -871,8 +854,6 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
}
|
||||
}
|
||||
|
||||
g_bDisplayMsg = 1;
|
||||
|
||||
if (g_nPixelShaderVer & SHADER_REDUCED) conf.bilinear = 0;
|
||||
|
||||
ZZLog::GS_Log("Creating extra effects.");
|
||||
|
|
|
@ -119,13 +119,10 @@ void Draw(const VB& curvb)
|
|||
//------------------ variables
|
||||
|
||||
extern int g_nDepthBias;
|
||||
extern float g_fBlockMult;
|
||||
extern float g_fBlockMult; // used for old cards, that do not support Alpha-32float textures. We store block data in u16 and use it.
|
||||
bool g_bUpdateStencil = 1;
|
||||
//u32 g_SaveFrameNum = 0; // ZZ
|
||||
|
||||
int GPU_TEXWIDTH = 512;
|
||||
float g_fiGPU_TEXWIDTH = 1 / 512.0f;
|
||||
|
||||
extern CGprogram g_psprog; // 2 -- ZZ
|
||||
|
||||
// local alpha blending settings
|
||||
|
@ -249,6 +246,14 @@ inline void SetAlphaTest(const pixTest& curtest)
|
|||
glAlphaFunc(g_dwAlphaCmp[curtest.atst], AlphaReferedValue(curtest.aref));
|
||||
}
|
||||
}
|
||||
|
||||
// Return, if tcc, aem or psm mode told us, than Alpha test should be used
|
||||
// if tcc == 0 than no alpha used, aem used for alpha expanding and I am not sure
|
||||
// that it's correct, psm -- color mode,
|
||||
inline bool IsAlphaTestExpansion(tex0Info tex0)
|
||||
{
|
||||
return (tex0.tcc && gs.texa.aem && PSMT_ALPHAEXP(PIXEL_STORAGE_FORMAT(tex0)));
|
||||
}
|
||||
|
||||
// Switch wireframe rendering off for first flush, so it's draw few solid primitives
|
||||
inline void SwitchWireframeOff()
|
||||
|
@ -951,11 +956,11 @@ inline FRAGMENTSHADER* FlushUseExistRenderTarget(VB& curvb, CRenderTarget* ptext
|
|||
|
||||
GLuint ptexclut = 0;
|
||||
|
||||
//int psm = GetTexCPSM(curvb.tex0);
|
||||
//int psm = PIXEL_STORAGE_FORMAT(curvb.tex0);
|
||||
int shadertype = FlushGetShaderType(curvb, ptextarg, ptexclut);
|
||||
|
||||
FRAGMENTSHADER* pfragment = LoadShadeEffect(shadertype, 0, curvb.curprim.fge,
|
||||
IsAlphaTestExpansion(curvb), exactcolor, curvb.clamp, context, NULL);
|
||||
IsAlphaTestExpansion(curvb.tex0), exactcolor, curvb.clamp, context, NULL);
|
||||
|
||||
Vector vpageoffset = FlushSetPageOffset(pfragment, shadertype, ptextarg);
|
||||
|
||||
|
@ -997,7 +1002,7 @@ inline FRAGMENTSHADER* FlushMadeNewTarget(VB& curvb, int exactcolor, int context
|
|||
}
|
||||
|
||||
FRAGMENTSHADER* pfragment = LoadShadeEffect(0, GetTexFilter(curvb.tex1), curvb.curprim.fge,
|
||||
IsAlphaTestExpansion(curvb), exactcolor, curvb.clamp, context, NULL);
|
||||
IsAlphaTestExpansion(curvb.tex0), exactcolor, curvb.clamp, context, NULL);
|
||||
|
||||
if (pfragment == NULL)
|
||||
ZZLog::Error_Log("Could not find memory target shader.");
|
||||
|
@ -1116,9 +1121,6 @@ inline void AlphaSetDepthTest(VB& curvb, const pixTest curtest, FRAGMENTSHADER*
|
|||
|
||||
GL_ZTEST(curtest.zte);
|
||||
|
||||
// glEnable (GL_POLYGON_OFFSET_FILL);
|
||||
// glPolygonOffset (-1., -1.);
|
||||
|
||||
if (s_bWriteDepth)
|
||||
{
|
||||
if (!curvb.zbuf.zmsk)
|
||||
|
@ -1469,12 +1471,11 @@ inline void AlphaSaveTarget(VB& curvb)
|
|||
//#endif
|
||||
// char str[255];
|
||||
// sprintf(str, "frames/frame%.4d.tga", g_SaveFrameNum++);
|
||||
// if( (g_bSaveFlushedFrame & 2) ) {
|
||||
// //glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
|
||||
// //glFlush();
|
||||
// //SaveTexture("tex.jpg", GL_TEXTURE_RECTANGLE_NV, curvb.prndr->ptex, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh));
|
||||
// SaveRenderTarget(str, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh), 0);
|
||||
// }
|
||||
|
||||
// //glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
|
||||
// //glFlush();
|
||||
// //SaveTexture("tex.jpg", GL_TEXTURE_RECTANGLE_NV, curvb.prndr->ptex, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh));
|
||||
// SaveRenderTarget(str, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh), 0);
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
|
@ -2122,9 +2123,9 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
Vector valpha, valpha2 ;
|
||||
|
||||
// if clut, use the frame format
|
||||
int psm = GetTexCPSM(tex0);
|
||||
int psm = PIXEL_STORAGE_FORMAT(tex0);
|
||||
|
||||
// printf ( "A %d psm, is-clut %d. cpsm %d | %d %d\n", psm, PSMT_ISCLUT(psm), tex0.cpsm, tex0.tfx, tex0.tcc );
|
||||
// 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;
|
||||
vblack.x = vblack.y = vblack.z = vblack.w = 10;
|
||||
|
@ -2149,7 +2150,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
valpha2.z = (tex0.tfx != 1) * 2 ;
|
||||
valpha2.w = (tex0.tfx == 0) ;
|
||||
|
||||
if (tex0.tcc == 0 || !nNeedAlpha(psm))
|
||||
if (tex0.tcc == 0 || !PSMT_ALPHAEXP(psm))
|
||||
{
|
||||
valpha.x = 0 ;
|
||||
valpha.y = (!!tex0.tcc) * (1 + (tex0.tfx == 0)) ;
|
||||
|
@ -2157,7 +2158,8 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
else
|
||||
{
|
||||
valpha.x = (gs.texa.fta[0]) * (1 + (tex0.tfx == 0)) ;
|
||||
valpha.y = (gs.texa.fta[psm!=1] - gs.texa.fta[0]) * (1 + (tex0.tfx == 0)) ;
|
||||
valpha.y = (gs.texa.fta[psm != PSMCT24] - gs.texa.fta[0]) * (1 + (tex0.tfx == 0)) ;
|
||||
|
||||
}
|
||||
|
||||
valpha.z = (tex0.tfx >= 3) ;
|
||||
|
@ -2206,7 +2208,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
valpha4.z = 0; valpha4.w = 0;
|
||||
}
|
||||
|
||||
if( nNeedAlpha(psm) ) {
|
||||
if( PSMT_ALPHAEXP(psm) ) {
|
||||
|
||||
if( tex0.tfx == 0 ) {
|
||||
// make sure alpha is mult by two when the output is Cv = Ct*Cf
|
||||
|
@ -2241,17 +2243,17 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
}
|
||||
|
||||
if ( equal_vectors(valpha, valpha3) && equal_vectors(valpha2, valpha4) ) {
|
||||
if (CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][nNeedAlpha(psm)] == 0) {
|
||||
printf ( "Good issue %d %d %d %d\n", tex0.tfx, tex0.tcc, psm, nNeedAlpha(psm) );
|
||||
CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][nNeedAlpha(psm) ] = 1;
|
||||
if (CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][PSMT_ALPHAEXP(psm)] == 0) {
|
||||
printf ( "Good issue %d %d %d %d\n", tex0.tfx, tex0.tcc, psm, PSMT_ALPHAEXP(psm) );
|
||||
CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][PSMT_ALPHAEXP(psm) ] = 1;
|
||||
}
|
||||
}
|
||||
else if (CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][nNeedAlpha(psm)] == -1) {
|
||||
else if (CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][PSMT_ALPHAEXP(psm)] == -1) {
|
||||
printf ("Bad array, %d %d %d %d\n\tolf valpha %f, %f, %f, %f : valpha2 %f %f %f %f\n\tnew valpha %f, %f, %f, %f : valpha2 %f %f %f %f\n",
|
||||
tex0.tfx, tex0.tcc, psm, nNeedAlpha(psm),
|
||||
tex0.tfx, tex0.tcc, psm, PSMT_ALPHAEXP(psm),
|
||||
valpha3.x, valpha3.y, valpha3.z, valpha3.w, valpha4.x, valpha4.y, valpha4.z, valpha4.w,
|
||||
valpha.x, valpha.y, valpha.z, valpha.w, valpha2.x, valpha2.y, valpha2.z, valpha2.w);
|
||||
CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][nNeedAlpha(psm)] = -1 ;
|
||||
CheckTexArray[tex0.tfx][tex0.tcc][psm!=1][PSMT_ALPHAEXP(psm)] = -1 ;
|
||||
}
|
||||
|
||||
// Test;*/
|
||||
|
@ -2259,7 +2261,7 @@ void ZeroGS::SetTexVariables(int context, FRAGMENTSHADER* pfragment)
|
|||
ZZcgSetParameter4fv(pfragment->fTexAlpha, valpha, "g_fTexAlpha");
|
||||
ZZcgSetParameter4fv(pfragment->fTexAlpha2, valpha2, "g_fTexAlpha2");
|
||||
|
||||
if (tex0.tcc && gs.texa.aem && nNeedAlpha(psm))
|
||||
if (IsAlphaTestExpansion(tex0))
|
||||
ZZcgSetParameter4fv(pfragment->fTestBlack, vblack, "g_fTestBlack");
|
||||
|
||||
SetTexClamping(context, pfragment);
|
||||
|
@ -2284,7 +2286,7 @@ void ZeroGS::SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0,
|
|||
|
||||
if (pmemtarg == NULL || pfragment == NULL || pmemtarg->ptex == NULL)
|
||||
{
|
||||
printf("SetTexVariablesInt error\n");
|
||||
ZZLog::Error_Log("SetTexVariablesInt error.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
|
|||
const char* ShaderCallerName = "";
|
||||
const char* ShaderHandleName = "";
|
||||
|
||||
extern u32 ptexBlocks; // holds information on block tiling
|
||||
extern u32 ptexConv16to32;
|
||||
extern u32 ptexBlocks; // holds information on block tiling. Its texture number in OpenGL -- if 0 than such texture
|
||||
extern u32 ptexConv16to32; // does not exist. This textures should be created on start and released on finish.
|
||||
extern u32 ptexConv32to16;
|
||||
bool g_bCRTCBilinear = true;
|
||||
u8* s_lpShaderResources = NULL;
|
||||
|
|
|
@ -459,6 +459,8 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
|
|||
}
|
||||
else
|
||||
{
|
||||
u32 bit_idx = (s_AAx == 0) ? 0 : 1;
|
||||
|
||||
// align the rect to the nearest page
|
||||
// note that fbp is always aligned on page boundaries
|
||||
tex0Info texframe;
|
||||
|
@ -472,16 +474,17 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
|
|||
// write color and zero out stencil buf, always 0 context!
|
||||
// force bilinear if using AA
|
||||
// Fix in r133 -- FFX movies and Gust backgrounds!
|
||||
SetTexVariablesInt(0, 0*(s_AAx || s_AAy) ? 2 : 0, texframe, pmemtarg, &ppsBitBlt[!!s_AAx], 1);
|
||||
cgGLSetTextureParameter(ppsBitBlt[!!s_AAx].sMemory, pmemtarg->ptex->tex);
|
||||
cgGLEnableTextureParameter(ppsBitBlt[!!s_AAx].sMemory);
|
||||
//SetTexVariablesInt(0, 0*(s_AAx || s_AAy) ? 2 : 0, texframe, pmemtarg, &ppsBitBlt[!!s_AAx], 1);
|
||||
SetTexVariablesInt(0, 0, texframe, pmemtarg, &ppsBitBlt[bit_idx], 1);
|
||||
cgGLSetTextureParameter(ppsBitBlt[bit_idx].sMemory, pmemtarg->ptex->tex);
|
||||
cgGLEnableTextureParameter(ppsBitBlt[bit_idx].sMemory);
|
||||
|
||||
v = Vector(1, 1, 0.0f, 0.0f);
|
||||
ZZcgSetParameter4fv(pvsBitBlt.sBitBltTex, v, "g_fBitBltTex");
|
||||
|
||||
v.x = 1;
|
||||
v.y = 2;
|
||||
ZZcgSetParameter4fv(ppsBitBlt[!!s_AAx].sOneColor, v, "g_fOneColor");
|
||||
ZZcgSetParameter4fv(ppsBitBlt[bit_idx].sOneColor, v, "g_fOneColor");
|
||||
|
||||
assert(ptex != 0);
|
||||
|
||||
|
@ -496,8 +499,8 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
|
|||
}
|
||||
|
||||
// render with an AA shader if possible (bilinearly interpolates data)
|
||||
//cgGLLoadProgram(ppsBitBlt[!!s_AAx].prog);
|
||||
SETPIXELSHADER(ppsBitBlt[!!s_AAx].prog);
|
||||
//cgGLLoadProgram(ppsBitBlt[bit_idx].prog);
|
||||
SETPIXELSHADER(ppsBitBlt[bit_idx].prog);
|
||||
}
|
||||
|
||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
|
@ -1892,7 +1895,7 @@ static __forceinline void BuildClut(u32 psm, u32 height, T* pclut, u8* psrc, T*
|
|||
|
||||
#define TARGET_THRESH 0x500
|
||||
|
||||
extern int g_MaxTexWidth, g_MaxTexHeight;
|
||||
extern int g_MaxTexWidth, g_MaxTexHeight; // Maximum height & width of supported texture.
|
||||
|
||||
//#define SORT_TARGETS
|
||||
inline list<CMemoryTarget>::iterator ZeroGS::CMemoryTargetMngr::DestroyTargetIter(list<CMemoryTarget>::iterator& it)
|
||||
|
@ -2057,29 +2060,6 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::MemoryTarget_SearchExistTarget
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static __forceinline int NumberOfChannels(int psm)
|
||||
{
|
||||
int channels = 1;
|
||||
|
||||
if (PSMT_ISCLUT(psm))
|
||||
{
|
||||
if (psm == PSMT8)
|
||||
channels = 4;
|
||||
else if (psm == PSMT4)
|
||||
channels = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PSMT_IS16BIT(psm))
|
||||
{
|
||||
// 16z needs to be a8r8g8b8
|
||||
channels = 2;
|
||||
}
|
||||
}
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::MemoryTarget_ClearedTargetsSearch(int fmt, int widthmult, int channels, int height)
|
||||
{
|
||||
CMemoryTarget* targ = NULL;
|
||||
|
@ -2093,9 +2073,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::MemoryTarget_ClearedTargetsSea
|
|||
if ((height <= itbest->realheight) && (itbest->fmt == fmt) && (itbest->widthmult == widthmult) && (itbest->channels == channels))
|
||||
{
|
||||
// check channels
|
||||
int targchannels = NumberOfChannels(itbest->psm);
|
||||
|
||||
if (targchannels == channels) break;
|
||||
if (PIXELS_PER_WORD(itbest->psm) == channels) break;
|
||||
}
|
||||
|
||||
++itbest;
|
||||
|
@ -2140,12 +2118,14 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
|||
|
||||
u32 fmt = GL_UNSIGNED_BYTE;
|
||||
|
||||
// RGBA16 storage format
|
||||
if (PSMT_ISHALF_STORAGE(tex0)) fmt = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
|
||||
int widthmult = 1, channels = 1;
|
||||
|
||||
// If our texture is too big and could not be placed in 1 GPU texture. Pretty rare.
|
||||
if ((g_MaxTexHeight < 4096) && (end - start > g_MaxTexHeight)) widthmult = 2;
|
||||
channels = NumberOfChannels(tex0.psm);
|
||||
channels = PIXELS_PER_WORD(tex0.psm);
|
||||
|
||||
targ = MemoryTarget_ClearedTargetsSearch(fmt, widthmult, channels, end - start);
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ void ZeroGS::SetNegAA(int mode)
|
|||
void ZeroGS::SetAA(int mode)
|
||||
{
|
||||
FUNCLOG
|
||||
float f;
|
||||
float f = 1.0f;
|
||||
|
||||
// need to flush all targets
|
||||
s_RTs.ResolveAll();
|
||||
|
@ -453,27 +453,27 @@ void ZeroGS::SetAA(int mode)
|
|||
s_DepthRTs.Destroy();
|
||||
|
||||
s_AAx = s_AAy = 0; // This is code for x0, x2, x4, x8 and x16 anti-aliasing.
|
||||
|
||||
|
||||
if (mode > 0)
|
||||
{
|
||||
s_AAx = (mode + 1) / 2; // ( 1, 0 ) ; ( 1, 1 ) ; ( 2, 1 ) ; ( 2, 2 ) -- it's used as binary shift, so x >> s_AAx, y >> s_AAy
|
||||
// ( 1, 0 ) ; ( 1, 1 ) ; ( 2, 1 ) ; ( 2, 2 )
|
||||
// it's used as a binary shift, so x >> s_AAx, y >> s_AAy
|
||||
s_AAx = (mode + 1) / 2;
|
||||
s_AAy = mode / 2;
|
||||
f = 2.0f;
|
||||
}
|
||||
|
||||
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
|
||||
|
||||
s_nLastResolveReset = 0;
|
||||
|
||||
vb[0].prndr = NULL;
|
||||
vb[0].pdepth = NULL;
|
||||
vb[0].bNeedFrameCheck = 1;
|
||||
vb[0].bNeedZCheck = 1;
|
||||
vb[1].prndr = NULL;
|
||||
vb[1].pdepth = NULL;
|
||||
vb[1].bNeedFrameCheck = 1;
|
||||
vb[1].bNeedZCheck = 1;
|
||||
|
||||
vb[0].bNeedFrameCheck = vb[0].bNeedZCheck = 1;
|
||||
vb[1].bNeedFrameCheck = vb[1].bNeedZCheck = 1;
|
||||
|
||||
f = mode > 0 ? 2.0f : 1.0f;
|
||||
glPointSize(f);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
//------------------------ Constants ----------------------
|
||||
#define VB_BUFFERSIZE 0x400
|
||||
|
||||
|
@ -48,7 +46,6 @@ const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
|
|||
|
||||
//------------------------ Inlines -------------------------
|
||||
|
||||
|
||||
// Calculate maximum height for target
|
||||
inline int get_maxheight(int fbp, int fbw, int psm)
|
||||
{
|
||||
|
@ -62,29 +59,13 @@ inline int get_maxheight(int fbp, int fbw, int psm)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// Does psm need Alpha test with alpha expansion?
|
||||
inline int nNeedAlpha(u8 psm)
|
||||
{
|
||||
return (psm == PSMCT24 || psm == PSMCT16 || psm == PSMCT16S);
|
||||
}
|
||||
|
||||
// Get color storage model psm, that is important on flush stage.
|
||||
inline u8 GetTexCPSM(const tex0Info& tex)
|
||||
{
|
||||
if (PSMT_ISCLUT(tex.psm))
|
||||
return tex.cpsm;
|
||||
else
|
||||
return tex.psm;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ Variables -------------------------
|
||||
|
||||
// all textures have this width
|
||||
//#define GPU_TEXWIDTH 512
|
||||
extern int GPU_TEXWIDTH;
|
||||
extern float g_fiGPU_TEXWIDTH;
|
||||
#define MASKDIVISOR 0
|
||||
#define GPU_TEXMASKWIDTH (1024 >> MASKDIVISOR) // bitwise mask width for region repeat mode
|
||||
#define MASKDIVISOR 0 // Used for decrement bitwise mask texture size if 1024 is too big
|
||||
#define GPU_TEXMASKWIDTH (1024 >> MASKDIVISOR) // bitwise mask width for region repeat mode
|
||||
|
||||
extern u32 ptexBilinearBlocks;
|
||||
|
||||
|
@ -423,15 +404,6 @@ union
|
|||
|
||||
};
|
||||
|
||||
// Return, if tcc, aem or psm mode told us, than Alpha test should be used
|
||||
// if tcc == 0 than no alpha used, aem used for alpha expanding and I am not sure
|
||||
// that it's correct, psm -- color mode,
|
||||
inline bool
|
||||
IsAlphaTestExpansion(VB& curvb)
|
||||
{
|
||||
return (curvb.tex0.tcc && gs.texa.aem && nNeedAlpha(GetTexCPSM(curvb.tex0)));
|
||||
}
|
||||
|
||||
// visible members
|
||||
extern DrawFn drawfn[8];
|
||||
|
||||
|
|
Loading…
Reference in New Issue