ZZOgl-pg: Catch up with some of the changes in recent revisions of zzogl.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3677 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-08-22 09:42:28 +00:00
parent 4da64590d9
commit 661ddf088c
11 changed files with 104 additions and 122 deletions

View File

@ -44,14 +44,6 @@ LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// }
break;
case WM_ACTIVATE:
if (wParam != WA_INACTIVE)
{
//ZZLog::Debug_Log("Restoring device.");
ZeroGS::Restore();
}
break;
case WM_SIZE:
nWindowWidth = lParam & 0xffff;
nWindowHeight = lParam >> 16;

View File

@ -133,8 +133,6 @@
{
FUNCLOG
//if (g_bIsLost) return;
#if defined(ZEROGS_DEVBUILD)
if (gs.trxpos.dx + gs.imageWnew > gs.dstbuf.bw)
ZZLog::Warn_Log("Transfer error, width exceeded.");
@ -178,8 +176,6 @@
{
FUNCLOG
// if (g_bIsLost) return;
int start, end;
GetRectMemAddress(start, end, gs.dstbuf.psm, gs.imageX, gs.imageY, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw);

View File

@ -44,25 +44,27 @@ GIFRegHandler g_GIFTempRegHandlers[16] = {0};
u32 s_uTex1Data[2][2] = {{0, }};
u32 s_uClampData[2] = {0, };
u32 results[65535] = {0, };
//u32 results[65535] = {0, };
// return true if triangle SHOULD be painted.
// My brain hurts. --arcum42
// return true if triangle SHOULD be painted.
inline bool NoHighlights(int i)
{
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
int resultA = prim->iip + ((prim->tme) << 1) + ((prim->fge) << 2) + ((prim->abe) << 3) + ((prim->aa1) << 4) + ((prim->fst) << 5) + ((prim->ctxt) << 6) + ((prim->fix) << 7) +
((ZeroGS::vb[i].zbuf.psm) << 8);
int dummy = 0;
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
const pixTest curtest = ZeroGS::vb[i].test;
int result = curtest.ate + ((curtest.atst) << 1) + ((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst) << 9);
if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
// Old code
//Old code
return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ;
}

View File

@ -42,47 +42,41 @@ GIFRegHandler g_GIFTempRegHandlers[16] = {0};
u32 s_uTex1Data[2][2] = {{0, }};
u32 s_uClampData[2] = {0, };
u32 results[65535] = {0, };
//u32 results[65535] = {0, };
// return true if triangle SHOULD be painted.
inline bool NoHighlights(int i)
{
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
// I'd have thought we could just test prim->_val and ZeroGS::vb[i].zbuf.psm directly...
int resultA = prim->iip + ((prim->tme) << 1) + ((prim->fge) << 2) + ((prim->abe) << 3) + ((prim->aa1) << 4) + ((prim->fst) << 5) + ((prim->ctxt) << 6) + ((prim->fix) << 7) +
((ZeroGS::vb[i].zbuf.psm) << 8);
int dummy = 0;
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
// if ( results[resultA] == 0 ) {
// results[resultA] = 1;
// ZZLog::Error_Log("%x = %d %d %d %d %d %d %d %d psm: %x", resultA, prim->iip, (prim->tme), (prim->fge), (prim->abe) , (prim->aa1) ,(prim->fst), (prim->ctxt), (prim->fix), ZeroGS::vb[i].zbuf.psm) ;
// ZZLog::ERROR_LOG("%x = %d %d %d %d %d %d %d %d \n", resultA, prim->iip, (prim->tme), (prim->fge), (prim->abe) , (prim->aa1) ,(prim->fst), (prim->ctxt), (prim->fix)) ;
// }
// if (resultA == 0xb && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
const pixTest curtest = ZeroGS::vb[i].test;
// Again, couldn't we just test curtest._val?
int result = curtest.ate + ((curtest.atst) << 1) + ((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst) << 9);
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
// if (resultA == 0xb)
// if ( results[result] == 0) {
// results[result] = 1;
// ZZLog::Error_Log("0x%x = %d %d %d %d %d %d %d %d ", result, curtest.ate, curtest.atst, curtest.aref, curtest.afail, curtest.date, curtest.datm, curtest.zte, curtest.ztst);
// }
// 0, -50b, -500, !-300, -30a, -50a, -5cb, +100 (zte==1), -50d
// if (result == 0x50b && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
// if psm is 16S or 24, tme, abe, & fst are true, the rest are false, result is 0x302 or 0x700, and there is a mask.
//if (result == 0x50b && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
//if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
//if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
// if psm is 24, abe is true, tme doesn't matter, the rest are false, result is 0x54c or 0x50c and there is a mask.
if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
// if psm is 24, abe & tme are true, the rest are false, and no result.
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
// if psm is 16S, tme, abe, fst, and ctxt are true, the rest are false, result is 0x330 or 0x500, and there is a mask.
if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
//if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
// if ((resultA == 0x300b) && (result == 0x300) && ZeroGS::vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
//if ((resultA == 0x300b) && (result == 0x300) && ZeroGS::vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
// Old code
return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ;

View File

@ -742,7 +742,7 @@ inline void AfterRendererUnimportantJob()
AfterRenderCountStatistics();
if (s_nNewWidth >= 0 && s_nNewHeight >= 0/* && !g_bIsLost*/)
if (s_nNewWidth >= 0 && s_nNewHeight >= 0)
AfterRendererResizeWindow();
maxmin = 608;
@ -830,7 +830,7 @@ int count = 0;
// The main renderer function
void ZeroGS::RenderCRTC(int interlace)
{
if (/*g_bIsLost || */FrameSkippingHelper()) return;
if (FrameSkippingHelper()) return;
u32 bInterlace = SMODE2->INT && SMODE2->FFMD && (conf.interlace < 2);
@ -847,7 +847,15 @@ void ZeroGS::RenderCRTC(int interlace)
tex0Info& texframe = dispinfo[i];
if (texframe.th <= 1) continue;
if (SMODE2->INT && SMODE2->FFMD) texframe.th >>= 1;
if (SMODE2->INT && SMODE2->FFMD)
{
texframe.th >>= 1;
// Final Fantasy X-2 issue here.
if (conf.interlace == 2 && texframe.th >= 512)
texframe.th >>= 1;
}
if (i == 0) RenderSetupBlending();
if (bUsingStencil) RenderSetupStencil(i);

View File

@ -32,8 +32,6 @@ extern HDC hDC; // Private GDI Device Context
extern HGLRC hRC; // Permanent Rendering Context
#endif
//extern bool g_bIsLost;
extern int s_frameskipping;
extern float fFPS;
extern unsigned char zgsrevision, zgsbuild, zgsminor;

View File

@ -616,65 +616,86 @@ bool ZeroGS::Create(int _width, int _height)
// create the blocks texture
g_fBlockMult = 1;
bool do_not_use_billinear = false;
vector<char> vBlockData, vBilinearData;
BLOCK::FillBlocks(vBlockData, vBilinearData, 1);
glGenTextures(1, &ptexBlocks);
glBindTexture(GL_TEXTURE_2D, ptexBlocks);
g_internalFloatFmt = GL_ALPHA_FLOAT32_ATI;
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
Texture2D(g_internalFloatFmt, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
g_internalFloatFmt = GL_RGBA32F; // This is OpenGL 3.0 standard format, so it should be implemented in new cards.
g_internalRGBAFloatFmt = GL_RGBA32F;
g_internalRGBAFloat16Fmt = GL_RGBA16F;
if (glGetError() != GL_NO_ERROR)
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
// try different internal format
g_internalFloatFmt = GL_FLOAT_R32_NV;
Texture2D(g_internalFloatFmt, GL_RED, GL_FLOAT, &vBlockData[0]);
g_internalFloatFmt = GL_ALPHA_FLOAT32_ATI;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
// This case is bad. But for really old cards it could be nice.
g_fBlockMult = 65535.0f*(float)g_fiGPU_TEXWIDTH ;
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
g_internalFloatFmt = GL_ALPHA16 ;
// We store block data on u16 rather float numbers. It's not as precise, but ALPHA16 is OpenGL 2.0 standard
// and uses only 16 bit. Old zerogs use red channel, but it does not work.
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_UNSIGNED_SHORT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Could not fill blocks.");
return false;
}
do_not_use_billinear = true;
ZZLog::Debug_Log("Using non-bilinear fill, quallity is outdated!");
}
else
ZZLog::Debug_Log("Use ATI_texture_float for blockdata.");
}
else
ZZLog::Debug_Log("Use GL_RGBA32F for blockdata.");
setTex2DFilters(GL_NEAREST);
setTex2DWrap(GL_REPEAT);
if (glGetError() != GL_NO_ERROR)
if (!do_not_use_billinear)
{
// error, resort to 16bit
g_fBlockMult = 65535.0f * (float)g_fiGPU_TEXWIDTH / 32.0f;
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
Texture2D(2, GL_R, GL_UNSIGNED_SHORT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Could not fill blocks.");
return false;
}
ZZLog::GS_Log("Using non-bilinear fill.");
}
else
{
// fill in the bilinear blocks
// fill in the bilinear blocks (main variant).
glGenTextures(1, &ptexBilinearBlocks);
glBindTexture(GL_TEXTURE_2D, ptexBilinearBlocks);
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
if (glGetError() != GL_NO_ERROR)
{
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
g_internalRGBAFloat16Fmt = GL_FLOAT_RGBA16_NV;
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
ZZLog::Debug_Log("ZZogl Fill bilinear blocks. ");
B_G(glGetError() == GL_NO_ERROR, return false);
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
{
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
g_internalRGBAFloat16Fmt = GL_FLOAT_RGBA16_NV;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Fill bilinear blocks failed!");
return false;
}
else
ZZLog::Debug_Log("Fill bilinear blocks with NVidia_float.");
}
else
ZZLog::Debug_Log("Fill bilinear blocks with ATI_texture_float.");
}
else
{
// No, they failed on the first clause of the if statement, not the second.
//ZZLog::Error_Log("Fill bilinear blocks failed!");
}
ZZLog::Debug_Log("Fill bilinear blocks OK.!");
setTex2DFilters(GL_NEAREST);
setTex2DWrap(GL_REPEAT);

View File

@ -117,7 +117,6 @@ void Draw(const VB& curvb)
//------------------ variables
//extern bool g_bIsLost;
extern int g_nDepthBias;
extern float g_fBlockMult;
bool g_bUpdateStencil = 1;
@ -376,7 +375,7 @@ inline void FlushUpdateEffect()
// Check, maybe we cold skip flush
inline bool IsFlushNoNeed(VB& curvb, const pixTest& curtest)
{
if (curvb.nCount == 0 || (curtest.zte && curtest.ztst == 0) /*|| g_bIsLost*/)
if (curvb.nCount == 0 || (curtest.zte && curtest.ztst == 0))
{
curvb.nCount = 0;
return true;

View File

@ -33,7 +33,6 @@
using namespace ZeroGS;
extern int g_TransferredToGPU;
//extern bool g_bIsLost;
extern bool g_bUpdateStencil;
#if !defined(ZEROGS_DEVBUILD)

View File

@ -48,10 +48,6 @@ extern int g_nFrame, g_nRealFrame;
//extern int s_nFullscreen;
//-------------------------- Variables
// Context is lost -- could not draw.
// Setting this variable to true is also lost. Fixme.
//bool g_bIsLost = false;
primInfo *prim;
CGprogram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ
@ -484,8 +480,6 @@ void ZeroGS::Prim()
{
FUNCLOG
// if (g_bIsLost) return;
VB& curvb = vb[prim->ctxt];
if (curvb.CheckPrim()) Flush(prim->ctxt);
@ -579,21 +573,6 @@ void ZeroGS::RenderCustom(float fAlpha)
GL_REPORT_ERROR();
}
void ZeroGS::Restore()
{
FUNCLOG
return;
/*if (!g_bIsLost) return;
//if( SUCCEEDED(pd3dDevice->Reset(&d3dpp)) ) {
g_bIsLost = false;
// handle lost states
ZeroGS::ChangeDeviceSize(nBackbufferWidth, nBackbufferHeight);*/
//}
}
//////////////////////////
// Internal Definitions //
//////////////////////////
@ -848,18 +827,15 @@ void ZeroGS::SetFogColor(u32 fog)
ZeroGS::FlushBoth();
//if (!g_bIsLost)
//{
SetShaderCaller("SetFogColor");
Vector v;
SetShaderCaller("SetFogColor");
Vector v;
// set it immediately
// v.x = (gs.fogcol & 0xff) / 255.0f;
// v.y = ((gs.fogcol >> 8) & 0xff) / 255.0f;
// v.z = ((gs.fogcol >> 16) & 0xff) / 255.0f;
v.SetColor(gs.fogcol);
ZZcgSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
//}
// set it immediately
// v.x = (gs.fogcol & 0xff) / 255.0f;
// v.y = ((gs.fogcol >> 8) & 0xff) / 255.0f;
// v.z = ((gs.fogcol >> 16) & 0xff) / 255.0f;
v.SetColor(gs.fogcol);
ZZcgSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
// }
}
@ -1116,8 +1092,6 @@ void ZeroGS::texClutWrite(int ctx)
FUNCLOG
s_bTexFlush = false;
//if (g_bIsLost) return;
tex0Info& tex0 = vb[ctx].tex0;
assert(PSMT_ISCLUT(tex0.psm));

View File

@ -470,7 +470,6 @@ inline bool Create_Window(int _width, int _height);
bool Create(int width, int height);
void Destroy(bool bD3D);
void Restore(); // call to restore device
void Reset(); // call to destroy video resources
void GSStateReset();
void GSReset();