mirror of https://github.com/PCSX2/pcsx2.git
zzogl-pg: Some refactoring, a bit of work on logging. Some disabled stuff I was fiddling with.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3230 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
3520a29c12
commit
d3266a3921
|
@ -287,8 +287,7 @@ void tex2Write(int i, u32 *data)
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
tex0Info& tex0 = ZeroGS::vb[i].tex0;
|
tex0Info& tex0 = ZeroGS::vb[i].tex0;
|
||||||
|
|
||||||
if (ZeroGS::vb[i].bNeedTexCheck)
|
if (ZeroGS::vb[i].bNeedTexCheck) ZeroGS::vb[i].FlushTexData();
|
||||||
ZeroGS::vb[i].FlushTexData();
|
|
||||||
|
|
||||||
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
|
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
|
||||||
|
|
||||||
|
@ -342,8 +341,7 @@ __forceinline void frameWrite(int i, u32 *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
|
|
||||||
gsfb.fbp = ZZOglGet_fbp_FrameBitsMult(data[0]);
|
gsfb.fbp = ZZOglGet_fbp_FrameBitsMult(data[0]);
|
||||||
gsfb.fbw = ZZOglGet_fbw_FrameBitsMult(data[0]);
|
gsfb.fbw = ZZOglGet_fbw_FrameBitsMult(data[0]);
|
||||||
|
@ -383,7 +381,6 @@ __forceinline void clampWrite(int i, u32 *data)
|
||||||
|
|
||||||
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)))
|
||||||
{
|
{
|
||||||
|
|
||||||
ZeroGS::Flush(i);
|
ZeroGS::Flush(i);
|
||||||
s_uClampData[i] = data[0];
|
s_uClampData[i] = data[0];
|
||||||
|
|
||||||
|
@ -418,10 +415,10 @@ void __fastcall GIFRegHandlerPRIM(u32 *data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
|
|
||||||
if (data[0] & ~0x3ff)
|
//if (data[0] & ~0x3ff)
|
||||||
{
|
//{
|
||||||
//ZZLog::Warn_Log("Warning: unknown bits in prim %8.8lx_%8.8lx", data[1], data[0]);
|
//ZZLog::Warn_Log("Warning: unknown bits in prim %8.8lx_%8.8lx", data[1], data[0]);
|
||||||
}
|
//}
|
||||||
|
|
||||||
gs.nTriFanVert = gs.primIndex;
|
gs.nTriFanVert = gs.primIndex;
|
||||||
|
|
||||||
|
@ -645,8 +642,7 @@ void __fastcall GIFRegHandlerPRMODE(u32* data)
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs._prim[0]._val = (data[0] >> 3) & 0xff;
|
gs._prim[0]._val = (data[0] >> 3) & 0xff;
|
||||||
|
|
||||||
if (gs.prac == 0)
|
if (gs.prac == 0) ZeroGS::Prim();
|
||||||
ZeroGS::Prim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __fastcall GIFRegHandlerTEXCLUT(u32* data)
|
void __fastcall GIFRegHandlerTEXCLUT(u32* data)
|
||||||
|
@ -664,8 +660,7 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data)
|
||||||
void __fastcall GIFRegHandlerSCANMSK(u32* data)
|
void __fastcall GIFRegHandlerSCANMSK(u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
// ZeroGS::Flush(0);
|
// ZeroGS::FlushBoth();
|
||||||
// ZeroGS::Flush(1);
|
|
||||||
// ZeroGS::ResolveC(&ZeroGS::vb[0]);
|
// ZeroGS::ResolveC(&ZeroGS::vb[0]);
|
||||||
// ZeroGS::ResolveZ(&ZeroGS::vb[0]);
|
// ZeroGS::ResolveZ(&ZeroGS::vb[0]);
|
||||||
|
|
||||||
|
@ -730,9 +725,10 @@ void __fastcall GIFRegHandlerTEXA(u32* data)
|
||||||
|
|
||||||
if (*(u32*)&newinfo != *(u32*)&gs.texa)
|
if (*(u32*)&newinfo != *(u32*)&gs.texa)
|
||||||
{
|
{
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
*(u32*)&gs.texa = *(u32*) & newinfo;
|
*(u32*)&gs.texa = *(u32*) & newinfo;
|
||||||
|
|
||||||
gs.texa.fta[0] = newinfo.ta[0] / 255.0f;
|
gs.texa.fta[0] = newinfo.ta[0] / 255.0f;
|
||||||
gs.texa.fta[1] = newinfo.ta[1] / 255.0f;
|
gs.texa.fta[1] = newinfo.ta[1] / 255.0f;
|
||||||
|
|
||||||
|
@ -768,10 +764,8 @@ void __fastcall GIFRegHandlerSCISSOR_1(u32* data)
|
||||||
if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
|
if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
|
||||||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
||||||
{
|
{
|
||||||
|
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::Flush(0);
|
||||||
scissor = newscissor;
|
scissor = newscissor;
|
||||||
|
|
||||||
ZeroGS::vb[0].bNeedFrameCheck = 1;
|
ZeroGS::vb[0].bNeedFrameCheck = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -791,7 +785,6 @@ void __fastcall GIFRegHandlerSCISSOR_2(u32* data)
|
||||||
if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
|
if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
|
||||||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
||||||
{
|
{
|
||||||
|
|
||||||
ZeroGS::Flush(1);
|
ZeroGS::Flush(1);
|
||||||
scissor = newscissor;
|
scissor = newscissor;
|
||||||
|
|
||||||
|
@ -874,8 +867,7 @@ void __fastcall GIFRegHandlerPABE(u32* data)
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
|
//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
|
||||||
//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
|
//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
|
|
||||||
gs.pabe = *data & 0x1;
|
gs.pabe = *data & 0x1;
|
||||||
}
|
}
|
||||||
|
@ -883,16 +875,17 @@ void __fastcall GIFRegHandlerPABE(u32* data)
|
||||||
void __fastcall GIFRegHandlerFBA_1(u32* data)
|
void __fastcall GIFRegHandlerFBA_1(u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
ZeroGS::Flush(0);
|
|
||||||
ZeroGS::Flush(1);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::vb[0].fba.fba = *data & 0x1;
|
ZeroGS::vb[0].fba.fba = *data & 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __fastcall GIFRegHandlerFBA_2(u32* data)
|
void __fastcall GIFRegHandlerFBA_2(u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
ZeroGS::Flush(0);
|
|
||||||
ZeroGS::Flush(1);
|
ZeroGS::FlushBoth();
|
||||||
|
|
||||||
ZeroGS::vb[1].fba.fba = *data & 0x1;
|
ZeroGS::vb[1].fba.fba = *data & 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,8 +918,7 @@ void __fastcall GIFRegHandlerZBUF_1(u32* data)
|
||||||
// error detection
|
// error detection
|
||||||
if (m_Blocks[psm].bpp == 0) return;
|
if (m_Blocks[psm].bpp == 0) return;
|
||||||
|
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
|
|
||||||
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
||||||
zbuf.psm = 0x30 | ((data[0] >> 24) & 0xf);
|
zbuf.psm = 0x30 | ((data[0] >> 24) & 0xf);
|
||||||
|
@ -954,11 +946,9 @@ void __fastcall GIFRegHandlerZBUF_2(u32* data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// error detection
|
// error detection
|
||||||
if (m_Blocks[psm].bpp == 0)
|
if (m_Blocks[psm].bpp == 0) return;
|
||||||
return;
|
|
||||||
|
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
|
|
||||||
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ inline u32 CreateInterlaceTex(int width)
|
||||||
|
|
||||||
glGenTextures(1, &s_ptexInterlace);
|
glGenTextures(1, &s_ptexInterlace);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_ptexInterlace);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, s_ptexInterlace);
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, width, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
|
TextureRect(4, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
@ -283,14 +283,11 @@ inline void RenderStartHelper(u32 bInterlace)
|
||||||
ZZLog::Debug_Log("Disabling MRT depth writing\n");
|
ZZLog::Debug_Log("Disabling MRT depth writing\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Flush(0);
|
FlushBoth();
|
||||||
Flush(1);
|
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
|
|
||||||
FrameSavingHelper();
|
FrameSavingHelper();
|
||||||
|
|
||||||
if (s_RangeMngr.ranges.size() > 0)
|
if (s_RangeMngr.ranges.size() > 0) FlushTransferRanges(NULL);
|
||||||
FlushTransferRanges(NULL);
|
|
||||||
|
|
||||||
SetShaderCaller("RenderStartHelper");
|
SetShaderCaller("RenderStartHelper");
|
||||||
|
|
||||||
|
@ -317,7 +314,7 @@ inline void RenderStartHelper(u32 bInterlace)
|
||||||
|
|
||||||
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
DisableAllgl() ;
|
DisableAllgl();
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -444,11 +441,12 @@ inline void RenderCRTC24helper(u32 bInterlace, int interlace, int psm)
|
||||||
// assume that data is already in ptexMem (do Resolve?)
|
// assume that data is already in ptexMem (do Resolve?)
|
||||||
RenderGetForClip(bInterlace, interlace, psm, &ppsCRTC24[bInterlace]);
|
RenderGetForClip(bInterlace, interlace, psm, &ppsCRTC24[bInterlace]);
|
||||||
SETPIXELSHADER(ppsCRTC24[bInterlace].prog);
|
SETPIXELSHADER(ppsCRTC24[bInterlace].prog);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
DrawTriangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe I do this function global-defined. Calculate bits per pixel for
|
// Maybe I do this function global-defined. Calculate bits per pixel for
|
||||||
// each psm. It's obly place with PSMCT16 which have diffetent bpp.
|
// each psm. It's the only place with PSMCT16 which have a different bpp.
|
||||||
// FIXME: check PSMCT16S
|
// FIXME: check PSMCT16S
|
||||||
inline int RenderGetBpp(int psm)
|
inline int RenderGetBpp(int psm)
|
||||||
{
|
{
|
||||||
|
@ -638,9 +636,7 @@ inline bool RenderCheckForTargets(tex0Info& texframe, list<CRenderTarget*>& list
|
||||||
|
|
||||||
SETPIXELSHADER(ppsCRTCTarg[bInterlace].prog);
|
SETPIXELSHADER(ppsCRTCTarg[bInterlace].prog);
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
DrawTriangle();
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
if (abs(dh - (int)texframe.th) <= 1) return true;
|
if (abs(dh - (int)texframe.th) <= 1) return true;
|
||||||
|
|
||||||
|
@ -711,8 +707,8 @@ inline void RenderCheckForMemory(tex0Info& texframe, list<CRenderTarget*>& listT
|
||||||
RenderCreateInterlaceTex(bInterlace, texframe.th, &ppsCRTC[bInterlace]);
|
RenderCreateInterlaceTex(bInterlace, texframe.th, &ppsCRTC[bInterlace]);
|
||||||
|
|
||||||
SETPIXELSHADER(ppsCRTC[bInterlace].prog);
|
SETPIXELSHADER(ppsCRTC[bInterlace].prog);
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
DrawTriangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put FPS counter on screen (not in window title)
|
// Put FPS counter on screen (not in window title)
|
||||||
|
|
|
@ -456,6 +456,27 @@ inline bool CreateFillExtensionsMap()
|
||||||
|
|
||||||
const static char* g_pShaders[] = { "full", "reduced", "accurate", "accurate-reduced" };
|
const static char* g_pShaders[] = { "full", "reduced", "accurate", "accurate-reduced" };
|
||||||
|
|
||||||
|
void LoadglFunctions()
|
||||||
|
{
|
||||||
|
GL_LOADFN(glIsRenderbufferEXT);
|
||||||
|
GL_LOADFN(glBindRenderbufferEXT);
|
||||||
|
GL_LOADFN(glDeleteRenderbuffersEXT);
|
||||||
|
GL_LOADFN(glGenRenderbuffersEXT);
|
||||||
|
GL_LOADFN(glRenderbufferStorageEXT);
|
||||||
|
GL_LOADFN(glGetRenderbufferParameterivEXT);
|
||||||
|
GL_LOADFN(glIsFramebufferEXT);
|
||||||
|
GL_LOADFN(glBindFramebufferEXT);
|
||||||
|
GL_LOADFN(glDeleteFramebuffersEXT);
|
||||||
|
GL_LOADFN(glGenFramebuffersEXT);
|
||||||
|
GL_LOADFN(glCheckFramebufferStatusEXT);
|
||||||
|
GL_LOADFN(glFramebufferTexture1DEXT);
|
||||||
|
GL_LOADFN(glFramebufferTexture2DEXT);
|
||||||
|
GL_LOADFN(glFramebufferTexture3DEXT);
|
||||||
|
GL_LOADFN(glFramebufferRenderbufferEXT);
|
||||||
|
GL_LOADFN(glGetFramebufferAttachmentParameterivEXT);
|
||||||
|
GL_LOADFN(glGenerateMipmapEXT);
|
||||||
|
}
|
||||||
|
|
||||||
bool ZeroGS::Create(int _width, int _height)
|
bool ZeroGS::Create(int _width, int _height)
|
||||||
{
|
{
|
||||||
GLenum err = GL_NO_ERROR;
|
GLenum err = GL_NO_ERROR;
|
||||||
|
@ -489,23 +510,7 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
|
|
||||||
s_srcrgb = s_dstrgb = s_srcalpha = s_dstalpha = GL_ONE;
|
s_srcrgb = s_dstrgb = s_srcalpha = s_dstalpha = GL_ONE;
|
||||||
|
|
||||||
GL_LOADFN(glIsRenderbufferEXT);
|
LoadglFunctions();
|
||||||
GL_LOADFN(glBindRenderbufferEXT);
|
|
||||||
GL_LOADFN(glDeleteRenderbuffersEXT);
|
|
||||||
GL_LOADFN(glGenRenderbuffersEXT);
|
|
||||||
GL_LOADFN(glRenderbufferStorageEXT);
|
|
||||||
GL_LOADFN(glGetRenderbufferParameterivEXT);
|
|
||||||
GL_LOADFN(glIsFramebufferEXT);
|
|
||||||
GL_LOADFN(glBindFramebufferEXT);
|
|
||||||
GL_LOADFN(glDeleteFramebuffersEXT);
|
|
||||||
GL_LOADFN(glGenFramebuffersEXT);
|
|
||||||
GL_LOADFN(glCheckFramebufferStatusEXT);
|
|
||||||
GL_LOADFN(glFramebufferTexture1DEXT);
|
|
||||||
GL_LOADFN(glFramebufferTexture2DEXT);
|
|
||||||
GL_LOADFN(glFramebufferTexture3DEXT);
|
|
||||||
GL_LOADFN(glFramebufferRenderbufferEXT);
|
|
||||||
GL_LOADFN(glGetFramebufferAttachmentParameterivEXT);
|
|
||||||
GL_LOADFN(glGenerateMipmapEXT);
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
GL_REPORT_ERROR();
|
GL_REPORT_ERROR();
|
||||||
|
@ -523,7 +528,8 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
|
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer);
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer);
|
||||||
|
|
||||||
if (glDrawBuffers != NULL) glDrawBuffers(1, s_drawbuffers);
|
DrawBuffers(s_drawbuffers);
|
||||||
|
|
||||||
GL_REPORT_ERROR();
|
GL_REPORT_ERROR();
|
||||||
|
|
||||||
if (err != GL_NO_ERROR) bSuccess = false;
|
if (err != GL_NO_ERROR) bSuccess = false;
|
||||||
|
@ -582,7 +588,10 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
|
|
||||||
PBITMAPINFO pinfo = (PBITMAPINFO)LockResource(hBitmapGlob);
|
PBITMAPINFO pinfo = (PBITMAPINFO)LockResource(hBitmapGlob);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, pinfo->bmiHeader.biWidth, pinfo->bmiHeader.biHeight, 0, pinfo->bmiHeader.biBitCount == 32 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (u8*)pinfo + pinfo->bmiHeader.biSize);
|
if (pinfo->bmiHeader.biBitCount == 32)
|
||||||
|
TextureRect(4, pinfo->bmiHeader.biWidth, pinfo->bmiHeader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, (u8*)pinfo + pinfo->bmiHeader.biSize);
|
||||||
|
else
|
||||||
|
TextureRect(4, pinfo->bmiHeader.biWidth, pinfo->bmiHeader.biHeight, GL_RGB, GL_UNSIGNED_BYTE, (u8*)pinfo + pinfo->bmiHeader.biSize);
|
||||||
|
|
||||||
nLogoWidth = pinfo->bmiHeader.biWidth;
|
nLogoWidth = pinfo->bmiHeader.biWidth;
|
||||||
nLogoHeight = pinfo->bmiHeader.biHeight;
|
nLogoHeight = pinfo->bmiHeader.biHeight;
|
||||||
|
@ -623,13 +632,13 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
|
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
|
||||||
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
|
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
|
Texture2D(g_internalFloatFmt, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
|
||||||
|
|
||||||
if (glGetError() != GL_NO_ERROR)
|
if (glGetError() != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
// try different internal format
|
// try different internal format
|
||||||
g_internalFloatFmt = GL_FLOAT_R32_NV;
|
g_internalFloatFmt = GL_FLOAT_R32_NV;
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RED, GL_FLOAT, &vBlockData[0]);
|
Texture2D(g_internalFloatFmt, GL_RED, GL_FLOAT, &vBlockData[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
@ -643,7 +652,7 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
g_fBlockMult = 65535.0f * (float)g_fiGPU_TEXWIDTH / 32.0f;
|
g_fBlockMult = 65535.0f * (float)g_fiGPU_TEXWIDTH / 32.0f;
|
||||||
|
|
||||||
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
|
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 2, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_R, GL_UNSIGNED_SHORT, &vBlockData[0]);
|
Texture2D(2, GL_R, GL_UNSIGNED_SHORT, &vBlockData[0]);
|
||||||
|
|
||||||
if (glGetError() != GL_NO_ERROR)
|
if (glGetError() != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -658,13 +667,13 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
// fill in the bilinear blocks
|
// fill in the bilinear blocks
|
||||||
glGenTextures(1, &ptexBilinearBlocks);
|
glGenTextures(1, &ptexBilinearBlocks);
|
||||||
glBindTexture(GL_TEXTURE_2D, ptexBilinearBlocks);
|
glBindTexture(GL_TEXTURE_2D, ptexBilinearBlocks);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
|
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
|
||||||
|
|
||||||
if (glGetError() != GL_NO_ERROR)
|
if (glGetError() != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
|
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
|
||||||
g_internalRGBAFloat16Fmt = GL_FLOAT_RGBA16_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]);
|
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
|
||||||
ZZLog::Error_Log("ZZogl Fill bilinear blocks.");
|
ZZLog::Error_Log("ZZogl Fill bilinear blocks.");
|
||||||
B_G(glGetError() == GL_NO_ERROR, return false);
|
B_G(glGetError() == GL_NO_ERROR, return false);
|
||||||
}
|
}
|
||||||
|
@ -753,6 +762,7 @@ bool ZeroGS::Create(int _width, int _height)
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, &conv16to32data[0]);
|
glTexImage2D(GL_TEXTURE_2D, 0, 4, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, &conv16to32data[0]);
|
||||||
|
nullTex = false;
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Realisation of Flush -- drawing function of GS
|
// Realization of Flush -- drawing function of GS
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -61,7 +61,13 @@ bool g_bSaveResolved = 0;
|
||||||
//#define STENCIL_PBE 16
|
//#define STENCIL_PBE 16
|
||||||
#define STENCIL_CLEAR (2|4|8|16)
|
#define STENCIL_CLEAR (2|4|8|16)
|
||||||
|
|
||||||
#define DRAW() glDrawArrays(primtype[curvb.curprim.prim], 0, curvb.nCount)
|
void Draw(const VB& curvb)
|
||||||
|
{
|
||||||
|
if (nullTex)
|
||||||
|
ZZLog::Debug_Log("DRAW: Drawing arrays without a texture!");
|
||||||
|
else
|
||||||
|
glDrawArrays(primtype[curvb.curprim.prim], 0, curvb.nCount);
|
||||||
|
}
|
||||||
|
|
||||||
#define GL_BLEND_RGB(src, dst) { \
|
#define GL_BLEND_RGB(src, dst) { \
|
||||||
s_srcrgb = src; \
|
s_srcrgb = src; \
|
||||||
|
@ -1241,7 +1247,7 @@ inline void AlphaTest(VB& curvb)
|
||||||
|
|
||||||
if (!curvb.test.ate || curvb.test.atst > 0)
|
if (!curvb.test.ate || curvb.test.atst > 0)
|
||||||
{
|
{
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
@ -1266,7 +1272,7 @@ inline void AlphaPabe(VB& curvb, FRAGMENTSHADER* pfragment, int exactcolor)
|
||||||
|
|
||||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||||
|
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
if (!s_stencilmask) s_stencilfunc = GL_ALWAYS;
|
if (!s_stencilmask) s_stencilfunc = GL_ALWAYS;
|
||||||
|
@ -1341,7 +1347,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
|
||||||
GL_STENCILFUNC(GL_EQUAL, s_stencilref | STENCIL_FBA, s_stencilmask | STENCIL_FBA);
|
GL_STENCILFUNC(GL_EQUAL, s_stencilref | STENCIL_FBA, s_stencilmask | STENCIL_FBA);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -1361,7 +1367,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
|
||||||
|
|
||||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||||
|
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
if (oldabe) glEnable(GL_BLEND);
|
if (oldabe) glEnable(GL_BLEND);
|
||||||
|
@ -1412,7 +1418,7 @@ inline void AlphaSpecialTesting(VB& curvb, FRAGMENTSHADER* pfragment, u32 dwUsin
|
||||||
|
|
||||||
Vector v = Vector(0, exactcolor ? 510.0f : 2.0f, 0, 0);
|
Vector v = Vector(0, exactcolor ? 510.0f : 2.0f, 0, 0);
|
||||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// don't need to restore
|
// don't need to restore
|
||||||
}
|
}
|
||||||
|
@ -1497,7 +1503,7 @@ inline void AlphaColorClamping(VB& curvb, const pixTest curtest)
|
||||||
f = 0;
|
f = 0;
|
||||||
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
||||||
GL_BLENDEQ_RGB(GL_MAX_EXT);
|
GL_BLENDEQ_RGB(GL_MAX_EXT);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bios shows white screen
|
// bios shows white screen
|
||||||
|
@ -1506,7 +1512,7 @@ inline void AlphaColorClamping(VB& curvb, const pixTest curtest)
|
||||||
f = 1;
|
f = 1;
|
||||||
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
||||||
GL_BLENDEQ_RGB(GL_MIN_EXT);
|
GL_BLENDEQ_RGB(GL_MIN_EXT);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!curvb.zbuf.zmsk)
|
if (!curvb.zbuf.zmsk)
|
||||||
|
@ -1597,6 +1603,12 @@ void ZeroGS::Flush(int context)
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__forceinline void ZeroGS::FlushBoth()
|
||||||
|
{
|
||||||
|
Flush(0);
|
||||||
|
Flush(1);
|
||||||
|
}
|
||||||
|
|
||||||
inline void ZeroGS::RenderFBA(const VB& curvb, CGparameter sOneColor)
|
inline void ZeroGS::RenderFBA(const VB& curvb, CGparameter sOneColor)
|
||||||
{
|
{
|
||||||
// add fba to all pixels
|
// add fba to all pixels
|
||||||
|
@ -1620,7 +1632,7 @@ inline void ZeroGS::RenderFBA(const VB& curvb, CGparameter sOneColor)
|
||||||
|
|
||||||
ZZcgSetParameter4fv(sOneColor, v, "g_fOneColor");
|
ZZcgSetParameter4fv(sOneColor, v, "g_fOneColor");
|
||||||
|
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
SetAlphaTest(curvb.test);
|
SetAlphaTest(curvb.test);
|
||||||
|
|
||||||
|
@ -1673,7 +1685,7 @@ __forceinline void ZeroGS::RenderAlphaTest(const VB& curvb, CGparameter sOneColo
|
||||||
glStencilMask(STENCIL_CLEAR);
|
glStencilMask(STENCIL_CLEAR);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
GL_STENCILFUNC_SET();
|
GL_STENCILFUNC_SET();
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
if (curvb.test.ate && curvb.test.afail != 1 && USEALPHATESTING) glEnable(GL_ALPHA_TEST);
|
if (curvb.test.ate && curvb.test.afail != 1 && USEALPHATESTING) glEnable(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
|
@ -1691,7 +1703,7 @@ __forceinline void ZeroGS::RenderAlphaTest(const VB& curvb, CGparameter sOneColo
|
||||||
GL_STENCILFUNC_SET();
|
GL_STENCILFUNC_SET();
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
if (curvb.test.zte) glEnable(GL_DEPTH_TEST);
|
if (curvb.test.zte) glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
@ -1746,17 +1758,17 @@ inline void ZeroGS::ProcessStencil(const VB& curvb)
|
||||||
SetShaderCaller("ProcessStencil");
|
SetShaderCaller("ProcessStencil");
|
||||||
|
|
||||||
SETPIXELSHADER(ppsOne.prog);
|
SETPIXELSHADER(ppsOne.prog);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// process when alpha >= 0xff
|
// process when alpha >= 0xff
|
||||||
GL_STENCILFUNC(GL_EQUAL, STENCIL_PIXELWRITE | STENCIL_FBA | STENCIL_ALPHABIT, STENCIL_PIXELWRITE | STENCIL_FBA);
|
GL_STENCILFUNC(GL_EQUAL, STENCIL_PIXELWRITE | STENCIL_FBA | STENCIL_ALPHABIT, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// clear STENCIL_PIXELWRITE bit
|
// clear STENCIL_PIXELWRITE bit
|
||||||
glStencilMask(STENCIL_CLEAR);
|
glStencilMask(STENCIL_CLEAR);
|
||||||
|
|
||||||
GL_STENCILFUNC(GL_ALWAYS, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
GL_STENCILFUNC(GL_ALWAYS, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
// restore state
|
// restore state
|
||||||
GL_COLORMASK(s_dwColorWrite);
|
GL_COLORMASK(s_dwColorWrite);
|
||||||
|
@ -1807,14 +1819,14 @@ __forceinline void ZeroGS::ProcessFBA(const VB& curvb, CGparameter sOneColor)
|
||||||
float f = 1;
|
float f = 1;
|
||||||
ZZcgSetParameter4fv(sOneColor, &f, "g_fOneColor");
|
ZZcgSetParameter4fv(sOneColor, &f, "g_fOneColor");
|
||||||
SETPIXELSHADER(ppsOne.prog);
|
SETPIXELSHADER(ppsOne.prog);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
// reset bits
|
// reset bits
|
||||||
glStencilMask(STENCIL_CLEAR);
|
glStencilMask(STENCIL_CLEAR);
|
||||||
GL_STENCILFUNC(GL_GREATER, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
GL_STENCILFUNC(GL_GREATER, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
|
||||||
DRAW();
|
Draw(curvb);
|
||||||
|
|
||||||
if (curvb.test.atst && USEALPHATESTING)
|
if (curvb.test.atst && USEALPHATESTING)
|
||||||
{
|
{
|
||||||
|
|
|
@ -240,7 +240,6 @@ inline int ZeroGS::VB::CheckFrameAddConstraints(int tbp)
|
||||||
|
|
||||||
#ifdef DEVBUILD
|
#ifdef DEVBUILD
|
||||||
int noscissorpos = maxpos;
|
int noscissorpos = maxpos;
|
||||||
|
|
||||||
int ConstrainR1 = ConstraintReason;
|
int ConstrainR1 = ConstraintReason;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -249,26 +248,24 @@ inline int ZeroGS::VB::CheckFrameAddConstraints(int tbp)
|
||||||
frame = gsfb;
|
frame = gsfb;
|
||||||
frame.fbh = maxpos;
|
frame.fbh = maxpos;
|
||||||
|
|
||||||
if (!PSMT_ISHALF(frame.psm) || !(g_GameSettings&GAME_FULL16BITRES))
|
if (!PSMT_ISHALF(frame.psm) || !(g_GameSettings&GAME_FULL16BITRES)) CheckFrame32bitRes(maxpos);
|
||||||
CheckFrame32bitRes(maxpos);
|
|
||||||
|
|
||||||
#ifdef DEVBUILD
|
#ifdef DEVBUILD
|
||||||
if (frame.fbh == 0xe2)
|
if (frame.fbh == 0xe2)
|
||||||
ZZLog::Error_Log("Const: %x %x %d| %x %d %x %x", frame.fbh, frame.fbw, ConstraintReason, noscissorpos, ConstrainR1, tbp, frame.fbp);
|
ZZLog::Error_Log("Const: %x %x %d| %x %d %x %x", frame.fbh, frame.fbw, ConstraintReason, noscissorpos, ConstrainR1, tbp, frame.fbp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fixme: Reserved psm for framebuffers
|
// Fixme: Reserved psm for framebuffers
|
||||||
// gsfb.psm &= 0xf; // shadow tower
|
// gsfb.psm &= 0xf; // shadow tower
|
||||||
|
|
||||||
return 0 ;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if after resizing new depth target is needed to be used.
|
// Check if after resizing new depth target is needed to be used.
|
||||||
// it returns 2 if a new depth target is used.
|
// it returns 2 if a new depth target is used.
|
||||||
inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
|
inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
|
||||||
{
|
{
|
||||||
int result = 0 ;
|
int result = 0;
|
||||||
CDepthTarget* pprevdepth = pdepth;
|
CDepthTarget* pprevdepth = pdepth;
|
||||||
pdepth = NULL;
|
pdepth = NULL;
|
||||||
|
|
||||||
|
@ -287,7 +284,7 @@ inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
|
||||||
|
|
||||||
pdepth = pnewdepth;
|
pdepth = pnewdepth;
|
||||||
|
|
||||||
return result ;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if after resizing, a new render target is needed to be used. Also perform deptarget check.
|
// Check if after resizing, a new render target is needed to be used. Also perform deptarget check.
|
||||||
|
@ -330,11 +327,11 @@ inline int ZeroGS::VB::CheckFrameResolveRender(int tbp)
|
||||||
|
|
||||||
prndr = pnewtarg;
|
prndr = pnewtarg;
|
||||||
|
|
||||||
pdepth = pprevdepth ;
|
pdepth = pprevdepth;
|
||||||
|
|
||||||
result |= CheckFrameResolveDepth(tbp) ;
|
result |= CheckFrameResolveDepth(tbp);
|
||||||
|
|
||||||
return result ;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// After frame resetting, it is possible that 16 to 32 or 32 to 16 (color bits) conversion should be made.
|
// After frame resetting, it is possible that 16 to 32 or 32 to 16 (color bits) conversion should be made.
|
||||||
|
@ -362,6 +359,8 @@ inline void ZeroGS::VB::CheckFrame16vs32Conversion()
|
||||||
// If tbp != 0, use it to bound.
|
// If tbp != 0, use it to bound.
|
||||||
void ZeroGS::VB::CheckFrame(int tbp)
|
void ZeroGS::VB::CheckFrame(int tbp)
|
||||||
{
|
{
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
static int bChanged;
|
static int bChanged;
|
||||||
|
|
||||||
if (bNeedZCheck)
|
if (bNeedZCheck)
|
||||||
|
@ -384,7 +383,7 @@ void ZeroGS::VB::CheckFrame(int tbp)
|
||||||
bNeedFrameCheck = 0;
|
bNeedFrameCheck = 0;
|
||||||
bNeedZCheck = 0;
|
bNeedZCheck = 0;
|
||||||
|
|
||||||
if (CheckFrameAddConstraints(tbp) == -1) return ;
|
if (CheckFrameAddConstraints(tbp) == -1) return;
|
||||||
|
|
||||||
if ((prndr != NULL) && (prndr->psm != gsfb.psm))
|
if ((prndr != NULL) && (prndr->psm != gsfb.psm))
|
||||||
{
|
{
|
||||||
|
@ -400,11 +399,11 @@ void ZeroGS::VB::CheckFrame(int tbp)
|
||||||
{
|
{
|
||||||
bNeedZCheck = 0;
|
bNeedZCheck = 0;
|
||||||
|
|
||||||
if (prndr != NULL && gsfb.fbw > 0)
|
if (prndr != NULL && gsfb.fbw > 0) CheckFrameResolveDepth(tbp);
|
||||||
CheckFrameResolveDepth(tbp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prndr != NULL) SetContextTarget(ictx);
|
if (prndr != NULL) SetContextTarget(ictx);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the case, most easy to perform, when nothing was changed
|
// This is the case, most easy to perform, when nothing was changed
|
||||||
|
@ -422,8 +421,7 @@ inline void ZeroGS::VB::FlushTexUnchangedClutDontUpdate()
|
||||||
// update anything except texture itself
|
// update anything except texture itself
|
||||||
inline void ZeroGS::VB::FlushTexClutDontUpdate()
|
inline void ZeroGS::VB::FlushTexClutDontUpdate()
|
||||||
{
|
{
|
||||||
if (!ZZOglClutStorageUnchanged(uCurTex0Data, uNextTex0Data))
|
if (!ZZOglClutStorageUnchanged(uCurTex0Data, uNextTex0Data)) ZeroGS::Flush(ictx);
|
||||||
ZeroGS::Flush(ictx);
|
|
||||||
|
|
||||||
// clut memory isn't going to be loaded so can ignore, but at least update CSA and CPSM!
|
// clut memory isn't going to be loaded so can ignore, but at least update CSA and CPSM!
|
||||||
uCurTex0Data[1] = (uCurTex0Data[1] & CPSM_CSA_NOTMASK) | (uNextTex0Data[1] & CPSM_CSA_BITMASK);
|
uCurTex0Data[1] = (uCurTex0Data[1] & CPSM_CSA_NOTMASK) | (uNextTex0Data[1] & CPSM_CSA_BITMASK);
|
||||||
|
@ -457,8 +455,9 @@ inline void ZeroGS::VB::FlushTexSetNewVars(u32 psm)
|
||||||
// This function made VB state consistant before real Flush.
|
// This function made VB state consistant before real Flush.
|
||||||
void ZeroGS::VB::FlushTexData()
|
void ZeroGS::VB::FlushTexData()
|
||||||
{
|
{
|
||||||
assert(bNeedTexCheck);
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
assert(bNeedTexCheck);
|
||||||
bNeedTexCheck = 0;
|
bNeedTexCheck = 0;
|
||||||
|
|
||||||
u32 psm = ZZOglGet_psm_TexBitsFix(uNextTex0Data[0]);
|
u32 psm = ZZOglGet_psm_TexBitsFix(uNextTex0Data[0]);
|
||||||
|
@ -468,7 +467,7 @@ void ZeroGS::VB::FlushTexData()
|
||||||
if (ZZOglAllExceptClutIsSame(uCurTex0Data, uNextTex0Data))
|
if (ZZOglAllExceptClutIsSame(uCurTex0Data, uNextTex0Data))
|
||||||
{
|
{
|
||||||
// Don't need to do anything if there is no clutting and VB tex data was not changed
|
// Don't need to do anything if there is no clutting and VB tex data was not changed
|
||||||
if (!PSMT_ISCLUT(psm)) return ;
|
if (!PSMT_ISCLUT(psm)) return;
|
||||||
|
|
||||||
// have to write the CLUT again if only CLD was changed
|
// have to write the CLUT again if only CLD was changed
|
||||||
if (ZZOglClutMinusCLDunchanged(uCurTex0Data, uNextTex0Data))
|
if (ZZOglClutMinusCLDunchanged(uCurTex0Data, uNextTex0Data))
|
||||||
|
@ -497,4 +496,5 @@ void ZeroGS::VB::FlushTexData()
|
||||||
FlushTexSetNewVars(psm);
|
FlushTexSetNewVars(psm);
|
||||||
|
|
||||||
if (PSMT_ISCLUT(psm)) ZeroGS::CluttingForFlushedTex(&tex0, uNextTex0Data[1], ictx) ;
|
if (PSMT_ISCLUT(psm)) ZeroGS::CluttingForFlushedTex(&tex0, uNextTex0Data[1], ictx) ;
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#define RHA
|
#define RHA
|
||||||
//#define RW
|
//#define RW
|
||||||
|
|
||||||
|
bool nullTex = false;
|
||||||
|
|
||||||
extern int g_GameSettings;
|
extern int g_GameSettings;
|
||||||
|
|
||||||
using namespace ZeroGS;
|
using namespace ZeroGS;
|
||||||
|
@ -96,16 +98,20 @@ inline void DestroyAllTargetsHelper(void* ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Made an empty rexture and bind it to $ptr_p
|
// Made an empty texture and bind it to $ptr_p
|
||||||
// return false if creating texture was uncuccessfull
|
// return false if creating texture was unsuccessfull
|
||||||
// fbh and fdb should be properly shifter before calling this!.
|
// fbh and fdb should be properly shifted before calling this!.
|
||||||
// We should ignore framebuffer trouble here, we put textures of dufferent sized to it.
|
// We should ignore framebuffer trouble here, we put textures of different sizes to it.
|
||||||
inline bool ZeroGS::CRenderTarget::InitialiseDefaultTexture(u32 *ptr_p, int fbw, int fbh)
|
inline bool ZeroGS::CRenderTarget::InitialiseDefaultTexture(u32 *ptr_p, int fbw, int fbh)
|
||||||
{
|
{
|
||||||
glGenTextures(1, ptr_p);
|
glGenTextures(1, ptr_p);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, *ptr_p);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, *ptr_p);
|
||||||
|
|
||||||
// initialize to default
|
// initialize to default
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GetRenderTargetFormat(), fbw, fbh, 0, GL_RGBA, GetRenderFormat() == RFT_float16 ? GL_FLOAT : GL_UNSIGNED_BYTE, NULL);
|
if (GetRenderFormat() == RFT_float16)
|
||||||
|
TextureRect(GetRenderTargetFormat(), fbw, fbh, GL_RGBA, GL_FLOAT, NULL);
|
||||||
|
else
|
||||||
|
TextureRect(GetRenderTargetFormat(), fbw, fbh, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
|
@ -116,7 +122,7 @@ inline bool ZeroGS::CRenderTarget::InitialiseDefaultTexture(u32 *ptr_p, int fbw,
|
||||||
return ((Error == GL_NO_ERROR) || (Error == GL_INVALID_FRAMEBUFFER_OPERATION_EXT));
|
return ((Error == GL_NO_ERROR) || (Error == GL_INVALID_FRAMEBUFFER_OPERATION_EXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw 4 triangles from binded array using only stenclil buffer
|
// Draw 4 triangles from binded array using only stencil buffer
|
||||||
inline void FillOnlyStencilBuffer()
|
inline void FillOnlyStencilBuffer()
|
||||||
{
|
{
|
||||||
if (ZeroGS::IsWriteDestAlphaTest() && !(g_GameSettings&GAME_NOSTENCIL))
|
if (ZeroGS::IsWriteDestAlphaTest() && !(g_GameSettings&GAME_NOSTENCIL))
|
||||||
|
@ -128,7 +134,7 @@ inline void FillOnlyStencilBuffer()
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
glStencilFunc(GL_ALWAYS, 1, 0xff);
|
glStencilFunc(GL_ALWAYS, 1, 0xff);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
DrawTriangle();
|
||||||
glColorMask(1, 1, 1, 1);
|
glColorMask(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,7 +520,7 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
|
||||||
|
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
DrawTriangle();
|
||||||
|
|
||||||
// fill stencil buf only
|
// fill stencil buf only
|
||||||
FillOnlyStencilBuffer();
|
FillOnlyStencilBuffer();
|
||||||
|
@ -578,9 +584,8 @@ void ZeroGS::CRenderTarget::ConvertTo32()
|
||||||
SET_STREAM();
|
SET_STREAM();
|
||||||
|
|
||||||
// assume depth already set !?
|
// assume depth already set !?
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptexConv, 0);
|
FBTexture(0, ptexConv);
|
||||||
ZeroGS::ResetRenderTarget(1);
|
ZeroGS::ResetRenderTarget(1);
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
|
|
||||||
BindToSample(&ptex) ;
|
BindToSample(&ptex) ;
|
||||||
|
|
||||||
|
@ -596,8 +601,7 @@ void ZeroGS::CRenderTarget::ConvertTo32()
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
|
|
||||||
SETPIXELSHADER(ppsConvert16to32.prog);
|
SETPIXELSHADER(ppsConvert16to32.prog);
|
||||||
|
DrawTriangle();
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if (g_bSaveZUpdate)
|
if (g_bSaveZUpdate)
|
||||||
|
@ -685,8 +689,7 @@ void ZeroGS::CRenderTarget::ConvertTo16()
|
||||||
SET_STREAM();
|
SET_STREAM();
|
||||||
|
|
||||||
// assume depth already set !?
|
// assume depth already set !?
|
||||||
// assume depth already set !?
|
FBTexture(0, ptexConv);
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptexConv, 0);
|
|
||||||
ZeroGS::ResetRenderTarget(1);
|
ZeroGS::ResetRenderTarget(1);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -705,8 +708,7 @@ void ZeroGS::CRenderTarget::ConvertTo16()
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
|
|
||||||
SETPIXELSHADER(ppsConvert32to16.prog);
|
SETPIXELSHADER(ppsConvert32to16.prog);
|
||||||
|
DrawTriangle();
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
//g_bSaveZUpdate = 1;
|
//g_bSaveZUpdate = 1;
|
||||||
|
@ -794,7 +796,7 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vboRect);
|
glBindBuffer(GL_ARRAY_BUFFER, vboRect);
|
||||||
SET_STREAM();
|
SET_STREAM();
|
||||||
|
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptexFeedback, 0);
|
FBTexture(0, ptexFeedback);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -808,8 +810,7 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
|
||||||
// render with an AA shader if possible (bilinearly interpolates data)
|
// render with an AA shader if possible (bilinearly interpolates data)
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
SETPIXELSHADER(ppsBaseTexture.prog);
|
SETPIXELSHADER(ppsBaseTexture.prog);
|
||||||
|
DrawTriangle();
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
// restore
|
// restore
|
||||||
swap(ptex, ptexFeedback);
|
swap(ptex, ptexFeedback);
|
||||||
|
@ -834,7 +835,7 @@ void ZeroGS::CRenderTarget::SetRenderTarget(int targ)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
|
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + targ, GL_TEXTURE_RECTANGLE_NV, ptex, 0);
|
FBTexture(targ, ptex);
|
||||||
|
|
||||||
//GL_REPORT_ERRORD();
|
//GL_REPORT_ERRORD();
|
||||||
//if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
//if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
|
@ -854,8 +855,7 @@ bool ZeroGS::CDepthTarget::Create(const frameInfo& frame)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
|
|
||||||
if (!CRenderTarget::Create(frame))
|
if (!CRenderTarget::Create(frame)) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
GL_REPORT_ERROR();
|
GL_REPORT_ERROR();
|
||||||
|
|
||||||
|
@ -903,8 +903,8 @@ void ZeroGS::CDepthTarget::Destroy()
|
||||||
if (status) // In this case Framebuffer extension is off-use and lead to segfault
|
if (status) // In this case Framebuffer extension is off-use and lead to segfault
|
||||||
{
|
{
|
||||||
ResetRenderTarget(1);
|
ResetRenderTarget(1);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
TextureRect(GL_DEPTH_ATTACHMENT_EXT);
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
TextureRect(GL_STENCIL_ATTACHMENT_EXT);
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
if (pstencil != 0)
|
if (pstencil != 0)
|
||||||
|
@ -1011,9 +1011,9 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
||||||
cgGLSetTextureParameter(ppsBitBltDepth.sMemory, pmemtarg->ptex->tex);
|
cgGLSetTextureParameter(ppsBitBltDepth.sMemory, pmemtarg->ptex->tex);
|
||||||
cgGLEnableTextureParameter(ppsBaseTexture.sFinal);
|
cgGLEnableTextureParameter(ppsBaseTexture.sFinal);
|
||||||
|
|
||||||
Vector v = DefaultBitBltPos() ;
|
Vector v = DefaultBitBltPos();
|
||||||
|
|
||||||
v = DefaultBitBltTex() ;
|
v = DefaultBitBltTex();
|
||||||
|
|
||||||
v.x = 1;
|
v.x = 1;
|
||||||
v.y = 2;
|
v.y = 2;
|
||||||
|
@ -1037,16 +1037,20 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
||||||
ZZcgSetParameter4fv(ppsBitBltDepth.sBitBltZ, ((255.0f / 256.0f)*vdepth), "g_fBitBltZ");
|
ZZcgSetParameter4fv(ppsBitBltDepth.sBitBltZ, ((255.0f / 256.0f)*vdepth), "g_fBitBltZ");
|
||||||
|
|
||||||
assert(pdepth != 0);
|
assert(pdepth != 0);
|
||||||
|
//GLint w1 = 0;
|
||||||
|
//GLint h1 = 0;
|
||||||
|
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptex, 0);
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptex, 0);
|
||||||
|
//glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_WIDTH_EXT, &w1);
|
||||||
|
//glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_HEIGHT_EXT, &h1);
|
||||||
SetDepthStencilSurface();
|
SetDepthStencilSurface();
|
||||||
|
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_NV, 0, 0);
|
FBTexture(1, 0);
|
||||||
|
|
||||||
GLenum buffer = GL_COLOR_ATTACHMENT0_EXT;
|
GLenum buffer = GL_COLOR_ATTACHMENT0_EXT;
|
||||||
|
|
||||||
if (glDrawBuffers != NULL) glDrawBuffers(1, &buffer);
|
//ZZLog::Error_Log("CDepthTarget::Update: w1 = 0x%x; h1 = 0x%x", w1, h1);
|
||||||
|
DrawBuffers(&buffer);
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
|
|
||||||
SetViewport();
|
SetViewport();
|
||||||
|
|
||||||
|
@ -1058,7 +1062,7 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
SETPIXELSHADER(ppsBitBltDepth.prog);
|
SETPIXELSHADER(ppsBitBltDepth.prog);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
DrawTriangle();
|
||||||
|
|
||||||
status = TS_Resolved;
|
status = TS_Resolved;
|
||||||
|
|
||||||
|
@ -1083,12 +1087,12 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
||||||
void ZeroGS::CDepthTarget::SetDepthStencilSurface()
|
void ZeroGS::CDepthTarget::SetDepthStencilSurface()
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, pdepth);
|
TextureRect(GL_DEPTH_ATTACHMENT_EXT, pdepth);
|
||||||
|
|
||||||
if (pstencil)
|
if (pstencil)
|
||||||
{
|
{
|
||||||
// there's a bug with attaching stencil and depth buffers
|
// there's a bug with attaching stencil and depth buffers
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, pstencil);
|
TextureRect(GL_STENCIL_ATTACHMENT_EXT, pstencil);
|
||||||
|
|
||||||
if (icount++ < 8) // not going to fail if succeeded 4 times
|
if (icount++ < 8) // not going to fail if succeeded 4 times
|
||||||
{
|
{
|
||||||
|
@ -1096,20 +1100,18 @@ void ZeroGS::CDepthTarget::SetDepthStencilSurface()
|
||||||
|
|
||||||
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||||
{
|
{
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
TextureRect(GL_STENCIL_ATTACHMENT_EXT);
|
||||||
|
|
||||||
if (pstencil != pdepth)
|
if (pstencil != pdepth) glDeleteRenderbuffersEXT(1, &pstencil);
|
||||||
glDeleteRenderbuffersEXT(1, &pstencil);
|
|
||||||
|
|
||||||
pstencil = 0;
|
pstencil = 0;
|
||||||
|
|
||||||
g_bUpdateStencil = 0;
|
g_bUpdateStencil = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
TextureRect(GL_STENCIL_ATTACHMENT_EXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1751,8 +1753,7 @@ bool ZeroGS::CMemoryTarget::ValidateTex(const tex0Info& tex0, int starttex, int
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
|
|
||||||
if (clearmaxy == 0)
|
if (clearmaxy == 0) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
int checkstarty = max(starttex, clearminy);
|
int checkstarty = max(starttex, clearminy);
|
||||||
int checkendy = min(endtex, clearmaxy);
|
int checkendy = min(endtex, clearmaxy);
|
||||||
|
@ -2167,11 +2168,9 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
if (PSMT_ISHALF_STORAGE(tex0)) fmt = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
if (PSMT_ISHALF_STORAGE(tex0)) fmt = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||||
|
|
||||||
int widthmult = 1;
|
int widthmult = 1;
|
||||||
|
|
||||||
if ((g_MaxTexHeight < 4096) && (end - start > g_MaxTexHeight)) widthmult = 2;
|
|
||||||
|
|
||||||
int channels = 1;
|
int channels = 1;
|
||||||
|
|
||||||
|
if ((g_MaxTexHeight < 4096) && (end - start > g_MaxTexHeight)) widthmult = 2;
|
||||||
channels = NumberOfChannels(tex0.psm);
|
channels = NumberOfChannels(tex0.psm);
|
||||||
|
|
||||||
targ = MemoryTarget_ClearedTargetsSearch(fmt, widthmult, channels, end - start);
|
targ = MemoryTarget_ClearedTargetsSearch(fmt, widthmult, channels, end - start);
|
||||||
|
@ -2251,9 +2250,11 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
|
|
||||||
#if defined(ZEROGS_DEVBUILD)
|
#if defined(ZEROGS_DEVBUILD)
|
||||||
g_TransferredToGPU += GPU_TEXWIDTH * channels * 4 * targ->height;
|
g_TransferredToGPU += GPU_TEXWIDTH * channels * 4 * targ->height;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const int texH = (targ->realheight + widthmult - 1) / widthmult;
|
||||||
|
const int texW = GPU_TEXWIDTH * channels * widthmult;
|
||||||
|
|
||||||
// fill with data
|
// fill with data
|
||||||
if (targ->ptex->memptr == NULL)
|
if (targ->ptex->memptr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -2268,7 +2269,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
|
|
||||||
if (PSMT_ISCLUT(tex0.psm))
|
if (PSMT_ISCLUT(tex0.psm))
|
||||||
{
|
{
|
||||||
texdata.resize((tex0.cpsm <= 1 ? 4 : 2) *GPU_TEXWIDTH*channels*widthmult*(targ->realheight + widthmult - 1) / widthmult);
|
texdata.resize(((tex0.cpsm <= 1) ? 4 : 2) * texW * texH);
|
||||||
ptexdata = &texdata[0];
|
ptexdata = &texdata[0];
|
||||||
|
|
||||||
u8* psrc = (u8*)(g_pbyGSMemory + 4 * GPU_TEXWIDTH * targ->realy);
|
u8* psrc = (u8*)(g_pbyGSMemory + 4 * GPU_TEXWIDTH * targ->realy);
|
||||||
|
@ -2292,7 +2293,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
{
|
{
|
||||||
if (tex0.psm == PSMT16Z || tex0.psm == PSMT16SZ)
|
if (tex0.psm == PSMT16Z || tex0.psm == PSMT16SZ)
|
||||||
{
|
{
|
||||||
texdata.resize(4*GPU_TEXWIDTH*channels*widthmult*(targ->realheight + widthmult - 1) / widthmult
|
texdata.resize(4 * texW * texH
|
||||||
#if defined(ZEROGS_SSE2)
|
#if defined(ZEROGS_SSE2)
|
||||||
+ 15 // reserve additional elements for alignment if SSE2 used.
|
+ 15 // reserve additional elements for alignment if SSE2 used.
|
||||||
// better do it now, so less resizing would be needed
|
// better do it now, so less resizing would be needed
|
||||||
|
@ -2315,7 +2316,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
// Later we would move eax by 16, so only we should verify is first element align
|
// Later we would move eax by 16, so only we should verify is first element align
|
||||||
// FIXME. As I see, texdata used only once here, it does not have any impact on other code.
|
// FIXME. As I see, texdata used only once here, it does not have any impact on other code.
|
||||||
// Probably, usage of _aligned_maloc() would be preferable.
|
// Probably, usage of _aligned_maloc() would be preferable.
|
||||||
int disalignment = 16 - ((u32)(uptr)dst) % 16 ; // This is value of shift. It could be 0 < disalignment <= 15
|
int disalignment = 16 - ((u32)(uptr)dst) % 16; // This is value of shift. It could be 0 < disalignment <= 15
|
||||||
ptexdata = &texdata[disalignment]; // Set pointer to aligned element
|
ptexdata = &texdata[disalignment]; // Set pointer to aligned element
|
||||||
dst = (u16*)ptexdata;
|
dst = (u16*)ptexdata;
|
||||||
ZZLog::GS_Log("Made alignment for texdata, 0x%x", dst);
|
ZZLog::GS_Log("Made alignment for texdata, 0x%x", dst);
|
||||||
|
@ -2357,8 +2358,10 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, targ->ptex->tex);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, targ->ptex->tex);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, fmt == GL_UNSIGNED_BYTE ? 4 : GL_RGB5_A1, GPU_TEXWIDTH*channels*widthmult,
|
if (fmt == GL_UNSIGNED_BYTE)
|
||||||
(targ->realheight + widthmult - 1) / widthmult, 0, GL_RGBA, fmt, ptexdata);
|
TextureRect(4, texW, texH, GL_RGBA, fmt, ptexdata);
|
||||||
|
else
|
||||||
|
TextureRect(GL_RGB5_A1, texW, texH, GL_RGBA, fmt, ptexdata);
|
||||||
|
|
||||||
int realheight = targ->realheight;
|
int realheight = targ->realheight;
|
||||||
|
|
||||||
|
@ -2381,7 +2384,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
||||||
DestroyOldest();
|
DestroyOldest();
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, GPU_TEXWIDTH*channels*widthmult, (targ->realheight + widthmult - 1) / widthmult, 0, GL_RGBA, fmt, ptexdata);
|
TextureRect(4, texW, texH, GL_RGBA, fmt, ptexdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
|
@ -2576,7 +2579,7 @@ u32 ZeroGS::CBitwiseTextureMngr::GetTexInt(u32 bitvalue, u32 ptexDoNotDelete)
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
|
||||||
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on binding bitmask texture.");
|
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on binding bitmask texture.");
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_LUMINANCE16, GPU_TEXMASKWIDTH + 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]);
|
TextureRect(GL_LUMINANCE16, GPU_TEXMASKWIDTH + 1, 1, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]);
|
||||||
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on applying bitmask texture.");
|
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on applying bitmask texture.");
|
||||||
|
|
||||||
// Removing clamping, as it seems lead to numerous troubles at some drivers
|
// Removing clamping, as it seems lead to numerous troubles at some drivers
|
||||||
|
@ -2785,8 +2788,7 @@ void ResolveInRange(int start, int end)
|
||||||
|
|
||||||
if (listTargs.size() > 0)
|
if (listTargs.size() > 0)
|
||||||
{
|
{
|
||||||
Flush(0);
|
FlushBoth();
|
||||||
Flush(1);
|
|
||||||
|
|
||||||
// We need another list, because old one could be brocken by Flush().
|
// We need another list, because old one could be brocken by Flush().
|
||||||
listTargs.clear();
|
listTargs.clear();
|
||||||
|
@ -2835,8 +2837,7 @@ void FlushTransferRanges(const tex0Info* ptex)
|
||||||
s_RTs.GetTargs(start, end, listTransmissionUpdateTargs);*/
|
s_RTs.GetTargs(start, end, listTransmissionUpdateTargs);*/
|
||||||
|
|
||||||
// if( !bHasFlushed && listTransmissionUpdateTargs.size() > 0 ) {
|
// if( !bHasFlushed && listTransmissionUpdateTargs.size() > 0 ) {
|
||||||
// Flush(0);
|
// FlushBoth();
|
||||||
// Flush(1);
|
|
||||||
//
|
//
|
||||||
//#ifdef _DEBUG
|
//#ifdef _DEBUG
|
||||||
// // make sure targets are still the same
|
// // make sure targets are still the same
|
||||||
|
@ -2999,8 +3000,7 @@ void InitTransferHostLocal()
|
||||||
//ZZLog::Prim_Log("trans: bp:%x x:%x y:%x w:%x h:%x\n", gs.dstbuf.bp, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew);
|
//ZZLog::Prim_Log("trans: bp:%x x:%x y:%x w:%x h:%x\n", gs.dstbuf.bp, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew);
|
||||||
|
|
||||||
// if( !bHasFlushed && (vb[0].bNeedFrameCheck || vb[0].bNeedZCheck || vb[1].bNeedFrameCheck || vb[1].bNeedZCheck)) {
|
// if( !bHasFlushed && (vb[0].bNeedFrameCheck || vb[0].bNeedZCheck || vb[1].bNeedFrameCheck || vb[1].bNeedZCheck)) {
|
||||||
// Flush(0);
|
// FlushBoth();
|
||||||
// Flush(1);
|
|
||||||
// bHasFlushed = 1;
|
// bHasFlushed = 1;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -3011,8 +3011,7 @@ void InitTransferHostLocal()
|
||||||
// GetRectMemAddress(tstart, tend, vb[0].tex0.psm, 0, 0, vb[0].tex0.tw, vb[0].tex0.th, vb[0].tex0.tbp0, vb[0].tex0.tbw);
|
// GetRectMemAddress(tstart, tend, vb[0].tex0.psm, 0, 0, vb[0].tex0.tw, vb[0].tex0.th, vb[0].tex0.tbp0, vb[0].tex0.tbw);
|
||||||
//
|
//
|
||||||
// if( start < tend && end > tstart ) {
|
// if( start < tend && end > tstart ) {
|
||||||
// Flush(0);
|
// FlushBoth();
|
||||||
// Flush(1);
|
|
||||||
// bHasFlushed = 1;
|
// bHasFlushed = 1;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -3022,8 +3021,7 @@ void InitTransferHostLocal()
|
||||||
// GetRectMemAddress(tstart, tend, vb[1].tex0.psm, 0, 0, vb[1].tex0.tw, vb[1].tex0.th, vb[1].tex0.tbp0, vb[1].tex0.tbw);
|
// GetRectMemAddress(tstart, tend, vb[1].tex0.psm, 0, 0, vb[1].tex0.tw, vb[1].tex0.th, vb[1].tex0.tbp0, vb[1].tex0.tbw);
|
||||||
//
|
//
|
||||||
// if( start < tend && end > tstart ) {
|
// if( start < tend && end > tstart ) {
|
||||||
// Flush(0);
|
// FlushBoth();
|
||||||
// Flush(1);
|
|
||||||
// bHasFlushed = 1;
|
// bHasFlushed = 1;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#define TARGET_VIRTUAL_KEY 0x80000000
|
#define TARGET_VIRTUAL_KEY 0x80000000
|
||||||
#include "PS2Edefs.h"
|
#include "PS2Edefs.h"
|
||||||
|
|
||||||
|
extern bool nullTex;
|
||||||
|
|
||||||
inline Vector DefaultOneColor(FRAGMENTSHADER ptr)
|
inline Vector DefaultOneColor(FRAGMENTSHADER ptr)
|
||||||
{
|
{
|
||||||
Vector v = Vector(1, 1, 1, 1);
|
Vector v = Vector(1, 1, 1, 1);
|
||||||
|
@ -300,4 +302,64 @@ inline u32 GetFrameKeyDummy(CRenderTarget* frame)
|
||||||
|
|
||||||
} // End of namespace
|
} // End of namespace
|
||||||
|
|
||||||
|
#include "Mem.h"
|
||||||
|
|
||||||
|
// Naive attempt at preventing texures from being drawn if their data is null. (which is undefined behavior.)
|
||||||
|
// Gets rid of garbage at the beginning of Grandia III.
|
||||||
|
// And messes up Kingdom Hearts opening. I need to read up more on OpenGL. :(
|
||||||
|
//#define NO_NULL_TEXTURES
|
||||||
|
|
||||||
|
static __forceinline void DrawTriangle()
|
||||||
|
{
|
||||||
|
#ifdef NO_NULL_TEXTURES
|
||||||
|
if (nullTex)
|
||||||
|
{
|
||||||
|
ZZLog::Debug_Log("Drawing arrays without a texture!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline void DrawBuffers(GLenum *buffer)
|
||||||
|
{
|
||||||
|
if (glDrawBuffers != NULL)
|
||||||
|
{
|
||||||
|
#ifdef NO_NULL_TEXTURES
|
||||||
|
if (nullTex)
|
||||||
|
ZZLog::Debug_Log("Update2: Drawing buffers without a texture!");
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
glDrawBuffers(1, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
}
|
||||||
|
|
||||||
|
static __forceinline void FBTexture(int attach, int id)
|
||||||
|
{
|
||||||
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + attach, GL_TEXTURE_RECTANGLE_NV, id, 0);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Texture2D(GLint iFormat, GLenum format, GLenum type, const GLvoid* pixels)
|
||||||
|
{
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, iFormat, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, format, type, pixels);
|
||||||
|
nullTex = (pixels == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TextureRect(GLint iFormat, GLint width, GLint height, GLenum format, GLenum type, const GLvoid* pixels)
|
||||||
|
{
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, iFormat, width, height, 0, format, type, pixels);
|
||||||
|
nullTex = (pixels == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TextureRect(GLenum attach, GLuint id = 0)
|
||||||
|
{
|
||||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attach, GL_RENDERBUFFER_EXT, id);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,7 +158,7 @@ void ExtWrite();
|
||||||
|
|
||||||
void ResetRenderTarget(int index)
|
void ResetRenderTarget(int index)
|
||||||
{
|
{
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_RECTANGLE_NV, 0, 0);
|
FBTexture(index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
|
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
|
||||||
|
@ -545,8 +545,7 @@ void ZeroGS::RenderCustom(float fAlpha)
|
||||||
|
|
||||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||||
SETPIXELSHADER(ppsBaseTexture.prog);
|
SETPIXELSHADER(ppsBaseTexture.prog);
|
||||||
|
DrawTriangle();
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
|
|
||||||
// restore
|
// restore
|
||||||
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
@ -845,8 +844,7 @@ void ZeroGS::SetFogColor(u32 fog)
|
||||||
// {
|
// {
|
||||||
gs.fogcol = fog;
|
gs.fogcol = fog;
|
||||||
|
|
||||||
ZeroGS::Flush(0);
|
ZeroGS::FlushBoth();
|
||||||
ZeroGS::Flush(1);
|
|
||||||
|
|
||||||
if (!g_bIsLost)
|
if (!g_bIsLost)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,7 +113,7 @@ using namespace std;
|
||||||
GLenum err = glGetError(); \
|
GLenum err = glGetError(); \
|
||||||
if( err != GL_NO_ERROR ) \
|
if( err != GL_NO_ERROR ) \
|
||||||
{ \
|
{ \
|
||||||
ZZLog::Error_Log("%s:%d: gl error %s", __FILE__, (int)__LINE__, error_name(err)); \
|
ZZLog::Error_Log("%s:%d: gl error %s(0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
|
||||||
ZeroGS::HandleGLError(); \
|
ZeroGS::HandleGLError(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ using namespace std;
|
||||||
GLenum err = glGetError(); \
|
GLenum err = glGetError(); \
|
||||||
if( err != GL_NO_ERROR ) \
|
if( err != GL_NO_ERROR ) \
|
||||||
{ \
|
{ \
|
||||||
ZZLog::Error_Log("%s:%d: gl error %s", __FILE__, (int)__LINE__, error_name(err)); \
|
ZZLog::Error_Log("%s:%d: gl error %s (0x%x)", __FILE__, (int)__LINE__, error_name(err), err); \
|
||||||
ZeroGS::HandleGLError(); \
|
ZeroGS::HandleGLError(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
@ -210,12 +210,15 @@ inline const char *error_name(int err)
|
||||||
case GL_TABLE_TOO_LARGE:
|
case GL_TABLE_TOO_LARGE:
|
||||||
return "GL_TABLE_TOO_LARGE";
|
return "GL_TABLE_TOO_LARGE";
|
||||||
|
|
||||||
|
case GL_INVALID_FRAMEBUFFER_OPERATION:
|
||||||
|
return "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "Unknown GL error";
|
return "Unknown GL error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inline for an extemely often used sequence
|
// inline for an extremely often used sequence
|
||||||
// This is turning off all gl functions. Safe to do updates.
|
// This is turning off all gl functions. Safe to do updates.
|
||||||
inline void DisableAllgl()
|
inline void DisableAllgl()
|
||||||
{
|
{
|
||||||
|
@ -823,7 +826,7 @@ void Prim();
|
||||||
void SetTexFlush();
|
void SetTexFlush();
|
||||||
// flush current vertices, call before setting new registers (the main render method)
|
// flush current vertices, call before setting new registers (the main render method)
|
||||||
void Flush(int context);
|
void Flush(int context);
|
||||||
|
void FlushBoth();
|
||||||
void ExtWrite();
|
void ExtWrite();
|
||||||
|
|
||||||
void SetWriteDepth();
|
void SetWriteDepth();
|
||||||
|
|
Loading…
Reference in New Issue