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
|
||||
tex0Info& tex0 = ZeroGS::vb[i].tex0;
|
||||
|
||||
if (ZeroGS::vb[i].bNeedTexCheck)
|
||||
ZeroGS::vb[i].FlushTexData();
|
||||
if (ZeroGS::vb[i].bNeedTexCheck) ZeroGS::vb[i].FlushTexData();
|
||||
|
||||
u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
|
||||
|
||||
|
@ -342,8 +341,7 @@ __forceinline void frameWrite(int i, u32 *data)
|
|||
return;
|
||||
}
|
||||
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
gsfb.fbp = ZZOglGet_fbp_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)))
|
||||
{
|
||||
|
||||
ZeroGS::Flush(i);
|
||||
s_uClampData[i] = data[0];
|
||||
|
||||
|
@ -418,10 +415,10 @@ void __fastcall GIFRegHandlerPRIM(u32 *data)
|
|||
{
|
||||
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]);
|
||||
}
|
||||
//}
|
||||
|
||||
gs.nTriFanVert = gs.primIndex;
|
||||
|
||||
|
@ -645,8 +642,7 @@ void __fastcall GIFRegHandlerPRMODE(u32* data)
|
|||
FUNCLOG
|
||||
gs._prim[0]._val = (data[0] >> 3) & 0xff;
|
||||
|
||||
if (gs.prac == 0)
|
||||
ZeroGS::Prim();
|
||||
if (gs.prac == 0) ZeroGS::Prim();
|
||||
}
|
||||
|
||||
void __fastcall GIFRegHandlerTEXCLUT(u32* data)
|
||||
|
@ -664,8 +660,7 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data)
|
|||
void __fastcall GIFRegHandlerSCANMSK(u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
// ZeroGS::Flush(0);
|
||||
// ZeroGS::Flush(1);
|
||||
// ZeroGS::FlushBoth();
|
||||
// ZeroGS::ResolveC(&ZeroGS::vb[0]);
|
||||
// ZeroGS::ResolveZ(&ZeroGS::vb[0]);
|
||||
|
||||
|
@ -730,9 +725,10 @@ void __fastcall GIFRegHandlerTEXA(u32* data)
|
|||
|
||||
if (*(u32*)&newinfo != *(u32*)&gs.texa)
|
||||
{
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
*(u32*)&gs.texa = *(u32*) & newinfo;
|
||||
|
||||
gs.texa.fta[0] = newinfo.ta[0] / 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 ||
|
||||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
||||
{
|
||||
|
||||
ZeroGS::Flush(0);
|
||||
scissor = newscissor;
|
||||
|
||||
ZeroGS::vb[0].bNeedFrameCheck = 1;
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +785,6 @@ void __fastcall GIFRegHandlerSCISSOR_2(u32* data)
|
|||
if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
|
||||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
|
||||
{
|
||||
|
||||
ZeroGS::Flush(1);
|
||||
scissor = newscissor;
|
||||
|
||||
|
@ -874,8 +867,7 @@ void __fastcall GIFRegHandlerPABE(u32* data)
|
|||
FUNCLOG
|
||||
//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
|
||||
//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
gs.pabe = *data & 0x1;
|
||||
}
|
||||
|
@ -883,16 +875,17 @@ void __fastcall GIFRegHandlerPABE(u32* data)
|
|||
void __fastcall GIFRegHandlerFBA_1(u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
|
||||
ZeroGS::FlushBoth();
|
||||
ZeroGS::vb[0].fba.fba = *data & 0x1;
|
||||
}
|
||||
|
||||
void __fastcall GIFRegHandlerFBA_2(u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
ZeroGS::vb[1].fba.fba = *data & 0x1;
|
||||
}
|
||||
|
||||
|
@ -925,8 +918,7 @@ void __fastcall GIFRegHandlerZBUF_1(u32* data)
|
|||
// error detection
|
||||
if (m_Blocks[psm].bpp == 0) return;
|
||||
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
||||
zbuf.psm = 0x30 | ((data[0] >> 24) & 0xf);
|
||||
|
@ -954,11 +946,9 @@ void __fastcall GIFRegHandlerZBUF_2(u32* data)
|
|||
}
|
||||
|
||||
// error detection
|
||||
if (m_Blocks[psm].bpp == 0)
|
||||
return;
|
||||
if (m_Blocks[psm].bpp == 0) return;
|
||||
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
zbuf.zbp = (data[0] & 0x1ff) * 32;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ inline u32 CreateInterlaceTex(int width)
|
|||
|
||||
glGenTextures(1, &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_MIN_FILTER, GL_NEAREST);
|
||||
GL_REPORT_ERRORD();
|
||||
|
@ -283,14 +283,11 @@ inline void RenderStartHelper(u32 bInterlace)
|
|||
ZZLog::Debug_Log("Disabling MRT depth writing\n");
|
||||
}
|
||||
|
||||
Flush(0);
|
||||
Flush(1);
|
||||
GL_REPORT_ERRORD();
|
||||
FlushBoth();
|
||||
|
||||
FrameSavingHelper();
|
||||
|
||||
if (s_RangeMngr.ranges.size() > 0)
|
||||
FlushTransferRanges(NULL);
|
||||
if (s_RangeMngr.ranges.size() > 0) FlushTransferRanges(NULL);
|
||||
|
||||
SetShaderCaller("RenderStartHelper");
|
||||
|
||||
|
@ -317,7 +314,7 @@ inline void RenderStartHelper(u32 bInterlace)
|
|||
|
||||
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
DisableAllgl() ;
|
||||
DisableAllgl();
|
||||
|
||||
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?)
|
||||
RenderGetForClip(bInterlace, interlace, psm, &ppsCRTC24[bInterlace]);
|
||||
SETPIXELSHADER(ppsCRTC24[bInterlace].prog);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
}
|
||||
|
||||
// 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
|
||||
inline int RenderGetBpp(int psm)
|
||||
{
|
||||
|
@ -638,9 +636,7 @@ inline bool RenderCheckForTargets(tex0Info& texframe, list<CRenderTarget*>& list
|
|||
|
||||
SETPIXELSHADER(ppsCRTCTarg[bInterlace].prog);
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
DrawTriangle();
|
||||
|
||||
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]);
|
||||
|
||||
SETPIXELSHADER(ppsCRTC[bInterlace].prog);
|
||||
GL_REPORT_ERRORD();
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
}
|
||||
|
||||
// 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" };
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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);
|
||||
LoadglFunctions();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
GL_REPORT_ERROR();
|
||||
|
@ -523,7 +528,8 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, s_uFramebuffer);
|
||||
|
||||
if (glDrawBuffers != NULL) glDrawBuffers(1, s_drawbuffers);
|
||||
DrawBuffers(s_drawbuffers);
|
||||
|
||||
GL_REPORT_ERROR();
|
||||
|
||||
if (err != GL_NO_ERROR) bSuccess = false;
|
||||
|
@ -582,7 +588,10 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
|
||||
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;
|
||||
nLogoHeight = pinfo->bmiHeader.biHeight;
|
||||
|
@ -622,14 +631,14 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
g_internalFloatFmt = GL_ALPHA_FLOAT32_ATI;
|
||||
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_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)
|
||||
{
|
||||
// try different internal format
|
||||
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);
|
||||
|
@ -643,7 +652,7 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
g_fBlockMult = 65535.0f * (float)g_fiGPU_TEXWIDTH / 32.0f;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -658,13 +667,13 @@ bool ZeroGS::Create(int _width, int _height)
|
|||
// fill in the bilinear blocks
|
||||
glGenTextures(1, &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)
|
||||
{
|
||||
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]);
|
||||
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
|
||||
ZZLog::Error_Log("ZZogl Fill bilinear blocks.");
|
||||
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]);
|
||||
nullTex = false;
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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
|
||||
*/
|
||||
|
||||
// Realisation of Flush -- drawing function of GS
|
||||
// Realization of Flush -- drawing function of GS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -61,7 +61,13 @@ bool g_bSaveResolved = 0;
|
|||
//#define STENCIL_PBE 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) { \
|
||||
s_srcrgb = src; \
|
||||
|
@ -1241,7 +1247,7 @@ inline void AlphaTest(VB& curvb)
|
|||
|
||||
if (!curvb.test.ate || curvb.test.atst > 0)
|
||||
{
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
}
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
@ -1266,7 +1272,7 @@ inline void AlphaPabe(VB& curvb, FRAGMENTSHADER* pfragment, int exactcolor)
|
|||
|
||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// reset
|
||||
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);
|
||||
}
|
||||
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
|
@ -1361,7 +1367,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
|
|||
|
||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// reset
|
||||
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);
|
||||
ZZcgSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor");
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// don't need to restore
|
||||
}
|
||||
|
@ -1497,7 +1503,7 @@ inline void AlphaColorClamping(VB& curvb, const pixTest curtest)
|
|||
f = 0;
|
||||
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
||||
GL_BLENDEQ_RGB(GL_MAX_EXT);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
}
|
||||
|
||||
// bios shows white screen
|
||||
|
@ -1506,7 +1512,7 @@ inline void AlphaColorClamping(VB& curvb, const pixTest curtest)
|
|||
f = 1;
|
||||
ZZcgSetParameter4fv(ppsOne.sOneColor, &f, "g_fOneColor");
|
||||
GL_BLENDEQ_RGB(GL_MIN_EXT);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
}
|
||||
|
||||
if (!curvb.zbuf.zmsk)
|
||||
|
@ -1597,6 +1603,12 @@ void ZeroGS::Flush(int context)
|
|||
GL_REPORT_ERRORD();
|
||||
}
|
||||
|
||||
__forceinline void ZeroGS::FlushBoth()
|
||||
{
|
||||
Flush(0);
|
||||
Flush(1);
|
||||
}
|
||||
|
||||
inline void ZeroGS::RenderFBA(const VB& curvb, CGparameter sOneColor)
|
||||
{
|
||||
// add fba to all pixels
|
||||
|
@ -1620,7 +1632,7 @@ inline void ZeroGS::RenderFBA(const VB& curvb, CGparameter sOneColor)
|
|||
|
||||
ZZcgSetParameter4fv(sOneColor, v, "g_fOneColor");
|
||||
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
SetAlphaTest(curvb.test);
|
||||
|
||||
|
@ -1673,7 +1685,7 @@ __forceinline void ZeroGS::RenderAlphaTest(const VB& curvb, CGparameter sOneColo
|
|||
glStencilMask(STENCIL_CLEAR);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
GL_STENCILFUNC_SET();
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
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();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
if (curvb.test.zte) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
@ -1746,17 +1758,17 @@ inline void ZeroGS::ProcessStencil(const VB& curvb)
|
|||
SetShaderCaller("ProcessStencil");
|
||||
|
||||
SETPIXELSHADER(ppsOne.prog);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// process when alpha >= 0xff
|
||||
GL_STENCILFUNC(GL_EQUAL, STENCIL_PIXELWRITE | STENCIL_FBA | STENCIL_ALPHABIT, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// clear STENCIL_PIXELWRITE bit
|
||||
glStencilMask(STENCIL_CLEAR);
|
||||
|
||||
GL_STENCILFUNC(GL_ALWAYS, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
// restore state
|
||||
GL_COLORMASK(s_dwColorWrite);
|
||||
|
@ -1807,14 +1819,14 @@ __forceinline void ZeroGS::ProcessFBA(const VB& curvb, CGparameter sOneColor)
|
|||
float f = 1;
|
||||
ZZcgSetParameter4fv(sOneColor, &f, "g_fOneColor");
|
||||
SETPIXELSHADER(ppsOne.prog);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
// reset bits
|
||||
glStencilMask(STENCIL_CLEAR);
|
||||
GL_STENCILFUNC(GL_GREATER, 0, STENCIL_PIXELWRITE | STENCIL_FBA);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
|
||||
DRAW();
|
||||
Draw(curvb);
|
||||
|
||||
if (curvb.test.atst && USEALPHATESTING)
|
||||
{
|
||||
|
|
|
@ -240,7 +240,6 @@ inline int ZeroGS::VB::CheckFrameAddConstraints(int tbp)
|
|||
|
||||
#ifdef DEVBUILD
|
||||
int noscissorpos = maxpos;
|
||||
|
||||
int ConstrainR1 = ConstraintReason;
|
||||
#endif
|
||||
|
||||
|
@ -249,26 +248,24 @@ inline int ZeroGS::VB::CheckFrameAddConstraints(int tbp)
|
|||
frame = gsfb;
|
||||
frame.fbh = maxpos;
|
||||
|
||||
if (!PSMT_ISHALF(frame.psm) || !(g_GameSettings&GAME_FULL16BITRES))
|
||||
CheckFrame32bitRes(maxpos);
|
||||
if (!PSMT_ISHALF(frame.psm) || !(g_GameSettings&GAME_FULL16BITRES)) CheckFrame32bitRes(maxpos);
|
||||
|
||||
#ifdef DEVBUILD
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
||||
// Fixme: Reserved psm for framebuffers
|
||||
// gsfb.psm &= 0xf; // shadow tower
|
||||
|
||||
return 0 ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if after resizing new depth target is needed to be used.
|
||||
// it returns 2 if a new depth target is used.
|
||||
inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
|
||||
{
|
||||
int result = 0 ;
|
||||
int result = 0;
|
||||
CDepthTarget* pprevdepth = pdepth;
|
||||
pdepth = NULL;
|
||||
|
||||
|
@ -287,7 +284,7 @@ inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
|
|||
|
||||
pdepth = pnewdepth;
|
||||
|
||||
return result ;
|
||||
return result;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
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.
|
||||
|
@ -362,6 +359,8 @@ inline void ZeroGS::VB::CheckFrame16vs32Conversion()
|
|||
// If tbp != 0, use it to bound.
|
||||
void ZeroGS::VB::CheckFrame(int tbp)
|
||||
{
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
static int bChanged;
|
||||
|
||||
if (bNeedZCheck)
|
||||
|
@ -384,7 +383,7 @@ void ZeroGS::VB::CheckFrame(int tbp)
|
|||
bNeedFrameCheck = 0;
|
||||
bNeedZCheck = 0;
|
||||
|
||||
if (CheckFrameAddConstraints(tbp) == -1) return ;
|
||||
if (CheckFrameAddConstraints(tbp) == -1) return;
|
||||
|
||||
if ((prndr != NULL) && (prndr->psm != gsfb.psm))
|
||||
{
|
||||
|
@ -400,11 +399,11 @@ void ZeroGS::VB::CheckFrame(int tbp)
|
|||
{
|
||||
bNeedZCheck = 0;
|
||||
|
||||
if (prndr != NULL && gsfb.fbw > 0)
|
||||
CheckFrameResolveDepth(tbp);
|
||||
if (prndr != NULL && gsfb.fbw > 0) CheckFrameResolveDepth(tbp);
|
||||
}
|
||||
|
||||
if (prndr != NULL) SetContextTarget(ictx);
|
||||
GL_REPORT_ERRORD();
|
||||
}
|
||||
|
||||
// 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
|
||||
inline void ZeroGS::VB::FlushTexClutDontUpdate()
|
||||
{
|
||||
if (!ZZOglClutStorageUnchanged(uCurTex0Data, uNextTex0Data))
|
||||
ZeroGS::Flush(ictx);
|
||||
if (!ZZOglClutStorageUnchanged(uCurTex0Data, uNextTex0Data)) ZeroGS::Flush(ictx);
|
||||
|
||||
// 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);
|
||||
|
@ -457,8 +455,9 @@ inline void ZeroGS::VB::FlushTexSetNewVars(u32 psm)
|
|||
// This function made VB state consistant before real Flush.
|
||||
void ZeroGS::VB::FlushTexData()
|
||||
{
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
assert(bNeedTexCheck);
|
||||
|
||||
bNeedTexCheck = 0;
|
||||
|
||||
u32 psm = ZZOglGet_psm_TexBitsFix(uNextTex0Data[0]);
|
||||
|
@ -468,7 +467,7 @@ void ZeroGS::VB::FlushTexData()
|
|||
if (ZZOglAllExceptClutIsSame(uCurTex0Data, uNextTex0Data))
|
||||
{
|
||||
// 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
|
||||
if (ZZOglClutMinusCLDunchanged(uCurTex0Data, uNextTex0Data))
|
||||
|
@ -497,4 +496,5 @@ void ZeroGS::VB::FlushTexData()
|
|||
FlushTexSetNewVars(psm);
|
||||
|
||||
if (PSMT_ISCLUT(psm)) ZeroGS::CluttingForFlushedTex(&tex0, uNextTex0Data[1], ictx) ;
|
||||
GL_REPORT_ERRORD();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#define RHA
|
||||
//#define RW
|
||||
|
||||
bool nullTex = false;
|
||||
|
||||
extern int g_GameSettings;
|
||||
|
||||
using namespace ZeroGS;
|
||||
|
@ -96,17 +98,21 @@ inline void DestroyAllTargetsHelper(void* ptr)
|
|||
}
|
||||
}
|
||||
|
||||
// Made an empty rexture and bind it to $ptr_p
|
||||
// return false if creating texture was uncuccessfull
|
||||
// fbh and fdb should be properly shifter before calling this!.
|
||||
// We should ignore framebuffer trouble here, we put textures of dufferent sized to it.
|
||||
// Made an empty texture and bind it to $ptr_p
|
||||
// return false if creating texture was unsuccessfull
|
||||
// fbh and fdb should be properly shifted before calling this!.
|
||||
// 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)
|
||||
{
|
||||
glGenTextures(1, ptr_p);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, *ptr_p);
|
||||
|
||||
// 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_T, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
// Draw 4 triangles from binded array using only stenclil buffer
|
||||
// Draw 4 triangles from binded array using only stencil buffer
|
||||
inline void FillOnlyStencilBuffer()
|
||||
{
|
||||
if (ZeroGS::IsWriteDestAlphaTest() && !(g_GameSettings&GAME_NOSTENCIL))
|
||||
|
@ -127,8 +133,8 @@ inline void FillOnlyStencilBuffer()
|
|||
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
glStencilFunc(GL_ALWAYS, 1, 0xff);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
glColorMask(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
@ -514,8 +520,8 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
|
|||
|
||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
|
||||
// fill stencil buf only
|
||||
FillOnlyStencilBuffer();
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
@ -578,9 +584,8 @@ void ZeroGS::CRenderTarget::ConvertTo32()
|
|||
SET_STREAM();
|
||||
|
||||
// assume depth already set !?
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, ptexConv, 0);
|
||||
FBTexture(0, ptexConv);
|
||||
ZeroGS::ResetRenderTarget(1);
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
BindToSample(&ptex) ;
|
||||
|
||||
|
@ -596,9 +601,8 @@ void ZeroGS::CRenderTarget::ConvertTo32()
|
|||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
|
||||
SETPIXELSHADER(ppsConvert16to32.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (g_bSaveZUpdate)
|
||||
{
|
||||
|
@ -685,8 +689,7 @@ void ZeroGS::CRenderTarget::ConvertTo16()
|
|||
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);
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
|
@ -705,9 +708,8 @@ void ZeroGS::CRenderTarget::ConvertTo16()
|
|||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
|
||||
SETPIXELSHADER(ppsConvert32to16.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
|
||||
#ifdef _DEBUG
|
||||
//g_bSaveZUpdate = 1;
|
||||
if (g_bSaveZUpdate)
|
||||
|
@ -794,7 +796,7 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
|
|||
glBindBuffer(GL_ARRAY_BUFFER, vboRect);
|
||||
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);
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
|
@ -808,9 +810,8 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
|
|||
// render with an AA shader if possible (bilinearly interpolates data)
|
||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
SETPIXELSHADER(ppsBaseTexture.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
|
||||
// restore
|
||||
swap(ptex, ptexFeedback);
|
||||
|
||||
|
@ -833,8 +834,8 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
|
|||
void ZeroGS::CRenderTarget::SetRenderTarget(int targ)
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + targ, GL_TEXTURE_RECTANGLE_NV, ptex, 0);
|
||||
|
||||
FBTexture(targ, ptex);
|
||||
|
||||
//GL_REPORT_ERRORD();
|
||||
//if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
|
@ -854,8 +855,7 @@ bool ZeroGS::CDepthTarget::Create(const frameInfo& frame)
|
|||
{
|
||||
FUNCLOG
|
||||
|
||||
if (!CRenderTarget::Create(frame))
|
||||
return false;
|
||||
if (!CRenderTarget::Create(frame)) return false;
|
||||
|
||||
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
|
||||
{
|
||||
ResetRenderTarget(1);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
|
||||
TextureRect(GL_DEPTH_ATTACHMENT_EXT);
|
||||
TextureRect(GL_STENCIL_ATTACHMENT_EXT);
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
if (pstencil != 0)
|
||||
|
@ -1011,9 +1011,9 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
|||
cgGLSetTextureParameter(ppsBitBltDepth.sMemory, pmemtarg->ptex->tex);
|
||||
cgGLEnableTextureParameter(ppsBaseTexture.sFinal);
|
||||
|
||||
Vector v = DefaultBitBltPos() ;
|
||||
Vector v = DefaultBitBltPos();
|
||||
|
||||
v = DefaultBitBltTex() ;
|
||||
v = DefaultBitBltTex();
|
||||
|
||||
v.x = 1;
|
||||
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");
|
||||
|
||||
assert(pdepth != 0);
|
||||
//GLint w1 = 0;
|
||||
//GLint h1 = 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();
|
||||
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_NV, 0, 0);
|
||||
FBTexture(1, 0);
|
||||
|
||||
GLenum buffer = GL_COLOR_ATTACHMENT0_EXT;
|
||||
|
||||
if (glDrawBuffers != NULL) glDrawBuffers(1, &buffer);
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
//ZZLog::Error_Log("CDepthTarget::Update: w1 = 0x%x; h1 = 0x%x", w1, h1);
|
||||
DrawBuffers(&buffer);
|
||||
|
||||
SetViewport();
|
||||
|
||||
|
@ -1058,7 +1062,7 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
|||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
SETPIXELSHADER(ppsBitBltDepth.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
DrawTriangle();
|
||||
|
||||
status = TS_Resolved;
|
||||
|
||||
|
@ -1083,12 +1087,12 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
|
|||
void ZeroGS::CDepthTarget::SetDepthStencilSurface()
|
||||
{
|
||||
FUNCLOG
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, pdepth);
|
||||
TextureRect(GL_DEPTH_ATTACHMENT_EXT, pdepth);
|
||||
|
||||
if (pstencil)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
@ -1096,20 +1100,18 @@ void ZeroGS::CDepthTarget::SetDepthStencilSurface()
|
|||
|
||||
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)
|
||||
glDeleteRenderbuffersEXT(1, &pstencil);
|
||||
if (pstencil != pdepth) glDeleteRenderbuffersEXT(1, &pstencil);
|
||||
|
||||
pstencil = 0;
|
||||
|
||||
g_bUpdateStencil = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
if (clearmaxy == 0)
|
||||
return true;
|
||||
if (clearmaxy == 0) return true;
|
||||
|
||||
int checkstarty = max(starttex, clearminy);
|
||||
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;
|
||||
|
||||
int widthmult = 1;
|
||||
|
||||
if ((g_MaxTexHeight < 4096) && (end - start > g_MaxTexHeight)) widthmult = 2;
|
||||
|
||||
int channels = 1;
|
||||
|
||||
if ((g_MaxTexHeight < 4096) && (end - start > g_MaxTexHeight)) widthmult = 2;
|
||||
channels = NumberOfChannels(tex0.psm);
|
||||
|
||||
targ = MemoryTarget_ClearedTargetsSearch(fmt, widthmult, channels, end - start);
|
||||
|
@ -2251,9 +2250,11 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
|||
|
||||
#if defined(ZEROGS_DEVBUILD)
|
||||
g_TransferredToGPU += GPU_TEXWIDTH * channels * 4 * targ->height;
|
||||
|
||||
#endif
|
||||
|
||||
const int texH = (targ->realheight + widthmult - 1) / widthmult;
|
||||
const int texW = GPU_TEXWIDTH * channels * widthmult;
|
||||
|
||||
// fill with data
|
||||
if (targ->ptex->memptr == NULL)
|
||||
{
|
||||
|
@ -2268,7 +2269,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
|||
|
||||
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];
|
||||
|
||||
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)
|
||||
{
|
||||
texdata.resize(4*GPU_TEXWIDTH*channels*widthmult*(targ->realheight + widthmult - 1) / widthmult
|
||||
texdata.resize(4 * texW * texH
|
||||
#if defined(ZEROGS_SSE2)
|
||||
+ 15 // reserve additional elements for alignment if SSE2 used.
|
||||
// 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
|
||||
// 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.
|
||||
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
|
||||
dst = (u16*)ptexdata;
|
||||
ZZLog::GS_Log("Made alignment for texdata, 0x%x", dst);
|
||||
|
@ -2356,9 +2357,11 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
|||
if (targ->ptex->tex == 0) glGenTextures(1, &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,
|
||||
(targ->realheight + widthmult - 1) / widthmult, 0, GL_RGBA, fmt, ptexdata);
|
||||
|
||||
if (fmt == GL_UNSIGNED_BYTE)
|
||||
TextureRect(4, texW, texH, GL_RGBA, fmt, ptexdata);
|
||||
else
|
||||
TextureRect(GL_RGB5_A1, texW, texH, GL_RGBA, fmt, ptexdata);
|
||||
|
||||
int realheight = targ->realheight;
|
||||
|
||||
|
@ -2380,8 +2383,8 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
|
|||
|
||||
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);
|
||||
|
@ -2576,7 +2579,7 @@ u32 ZeroGS::CBitwiseTextureMngr::GetTexInt(u32 bitvalue, u32 ptexDoNotDelete)
|
|||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
|
||||
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.");
|
||||
|
||||
// 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)
|
||||
{
|
||||
Flush(0);
|
||||
Flush(1);
|
||||
FlushBoth();
|
||||
|
||||
// We need another list, because old one could be brocken by Flush().
|
||||
listTargs.clear();
|
||||
|
@ -2835,8 +2837,7 @@ void FlushTransferRanges(const tex0Info* ptex)
|
|||
s_RTs.GetTargs(start, end, listTransmissionUpdateTargs);*/
|
||||
|
||||
// if( !bHasFlushed && listTransmissionUpdateTargs.size() > 0 ) {
|
||||
// Flush(0);
|
||||
// Flush(1);
|
||||
// FlushBoth();
|
||||
//
|
||||
//#ifdef _DEBUG
|
||||
// // 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);
|
||||
|
||||
// if( !bHasFlushed && (vb[0].bNeedFrameCheck || vb[0].bNeedZCheck || vb[1].bNeedFrameCheck || vb[1].bNeedZCheck)) {
|
||||
// Flush(0);
|
||||
// Flush(1);
|
||||
// FlushBoth();
|
||||
// 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);
|
||||
//
|
||||
// if( start < tend && end > tstart ) {
|
||||
// Flush(0);
|
||||
// Flush(1);
|
||||
// FlushBoth();
|
||||
// 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);
|
||||
//
|
||||
// if( start < tend && end > tstart ) {
|
||||
// Flush(0);
|
||||
// Flush(1);
|
||||
// FlushBoth();
|
||||
// bHasFlushed = 1;
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#define TARGET_VIRTUAL_KEY 0x80000000
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
extern bool nullTex;
|
||||
|
||||
inline Vector DefaultOneColor(FRAGMENTSHADER ptr)
|
||||
{
|
||||
Vector v = Vector(1, 1, 1, 1);
|
||||
|
@ -300,4 +302,64 @@ inline u32 GetFrameKeyDummy(CRenderTarget* frame)
|
|||
|
||||
} // 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
|
||||
|
|
|
@ -158,7 +158,7 @@ void ExtWrite();
|
|||
|
||||
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,
|
||||
|
@ -545,9 +545,8 @@ void ZeroGS::RenderCustom(float fAlpha)
|
|||
|
||||
SETVERTEXSHADER(pvsBitBlt.prog);
|
||||
SETPIXELSHADER(ppsBaseTexture.prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
DrawTriangle();
|
||||
|
||||
// restore
|
||||
if (conf.options & GSOPTION_WIREFRAME) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
|
@ -845,8 +844,7 @@ void ZeroGS::SetFogColor(u32 fog)
|
|||
// {
|
||||
gs.fogcol = fog;
|
||||
|
||||
ZeroGS::Flush(0);
|
||||
ZeroGS::Flush(1);
|
||||
ZeroGS::FlushBoth();
|
||||
|
||||
if (!g_bIsLost)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ using namespace std;
|
|||
GLenum err = glGetError(); \
|
||||
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(); \
|
||||
} \
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ using namespace std;
|
|||
GLenum err = glGetError(); \
|
||||
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(); \
|
||||
} \
|
||||
}
|
||||
|
@ -210,12 +210,15 @@ inline const char *error_name(int err)
|
|||
case GL_TABLE_TOO_LARGE:
|
||||
return "GL_TABLE_TOO_LARGE";
|
||||
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION:
|
||||
return "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||
|
||||
default:
|
||||
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.
|
||||
inline void DisableAllgl()
|
||||
{
|
||||
|
@ -823,7 +826,7 @@ void Prim();
|
|||
void SetTexFlush();
|
||||
// flush current vertices, call before setting new registers (the main render method)
|
||||
void Flush(int context);
|
||||
|
||||
void FlushBoth();
|
||||
void ExtWrite();
|
||||
|
||||
void SetWriteDepth();
|
||||
|
|
Loading…
Reference in New Issue