zzogl-pg: A bit of refactoring and debugging code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3208 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-06-15 10:32:22 +00:00
parent 87ebbb652b
commit 6de9dbeca0
5 changed files with 41 additions and 37 deletions

View File

@ -907,7 +907,8 @@ inline int ZZOgl_fbh_Calc(int fbp, int fbw, int psm)
if (PSMT_ISHALF(psm)) fbh *= 2;
if (fbh > 1024) fbh = 1024;
return fbh ;
//ZZLog::Debug_Log("ZZOgl_fbh_Calc: 0x%x", fbh);
return fbh;
}
inline int ZZOgl_fbh_Calc(frameInfo frame)

View File

@ -490,7 +490,7 @@ inline CRenderTarget* FlushReGetTarget(int& tbw, int& tbp0, int& tpsm, VB& curvb
}
}
#ifdef DEBUG
#ifdef _DEBUG
if (tbp0 == 0x3600 && tbw == 0x100)
{
if (ptextarg == NULL)

View File

@ -279,6 +279,7 @@ inline int ZeroGS::VB::CheckFrameResolveDepth(int tbp)
(zbuf.zmsk ? CRenderTargetMngr::TO_Virtual : 0), get_maxheight(zbuf.zbp, gsfb.fbw, 0));
assert(pnewdepth != NULL && prndr != NULL);
if (pnewdepth->fbh != prndr->fbh) ZZLog::Debug_Log("pnewdepth->fbh(0x%x) != prndr->fbh(0x%x)", pnewdepth->fbh, prndr->fbh);
assert(pnewdepth->fbh == prndr->fbh);
if ((pprevdepth != pnewdepth) || (pprevdepth != NULL && (pprevdepth->status & CRenderTarget::TS_NeedUpdate)))

View File

@ -1249,6 +1249,17 @@ inline bool CheckWidthIsSame(const frameInfo& frame, CRenderTarget* ptarg)
return (2 * frame.fbw == ptarg->fbw);
}
void ZeroGS::CRenderTargetMngr::PrintTargets()
{
#ifdef _DEBUG
for (MAPTARGETS::iterator it1 = mapDummyTargs.begin(); it1 != mapDummyTargs.end(); ++it1)
ZZLog::Debug_Log("\t Dummy Targets(0x%x) fbw:0x%x fbh:0x%x psm:0x%x fbp:0x%x", GetFrameKey(it1->second), it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
for (MAPTARGETS::iterator it1 = mapTargets.begin(); it1 != mapTargets.end(); ++it1)
ZZLog::Debug_Log("\t Targets(0x%x) fbw:0x%x fbh:0x%x psm:0x%x fbp:0x%x", GetFrameKey(it1->second), it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
#endif
}
CRenderTarget* ZeroGS::CRenderTargetMngr::GetTarg(const frameInfo& frame, u32 opts, int maxposheight)
{
FUNCLOG
@ -1503,18 +1514,9 @@ CRenderTarget* ZeroGS::CRenderTargetMngr::GetTarg(const frameInfo& frame, u32 op
if (it != mapDummyTargs.end())
{
#ifdef DEBUG
printf("A %x %x %x %x\n", frame.fbw, frame.fbh, frame.psm, frame.fbp);
for (MAPTARGETS::iterator it1 = mapDummyTargs.begin(); it1 != mapDummyTargs.end(); ++it1)
printf("\t %x %x %x %x\n", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
for (MAPTARGETS::iterator it1 = mapTargets.begin(); it1 != mapTargets.end(); ++it1)
printf("\t ! %x %x %x %x\n", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
printf("\t\t %x %x %x %x\n", it->second->fbw, it->second->fbh, it->second->psm, it->second->fbp);
#endif
ZZLog::Debug_Log("Dummy Frame fbw:0x%x fbh:0x%x psm:0x%x fbp:0x%x", frame.fbw, frame.fbh, frame.psm, frame.fbp);
PrintTargets();
ZZLog::Debug_Log("Dummy it->second fbw:0x%x fbh:0x%x psm:0x%x fbp:0x%x", it->second->fbw, it->second->fbh, it->second->psm, it->second->fbp);
ptarg = it->second;
mapDummyTargs.erase(it);
@ -1530,16 +1532,8 @@ CRenderTarget* ZeroGS::CRenderTargetMngr::GetTarg(const frameInfo& frame, u32 op
}
else
{
#ifdef DEBUG
printf("A %x %x %x %x\n", frame.fbw, frame.fbh, frame.psm, frame.fbp);
for (MAPTARGETS::iterator it1 = mapDummyTargs.begin(); it1 != mapDummyTargs.end(); ++it1)
printf("\t %x %x %x %x\n", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
for (MAPTARGETS::iterator it1 = mapTargets.begin(); it1 != mapTargets.end(); ++it1)
printf("\t ! %x %x %x %x\n", it1->second->fbw, it1->second->fbh, it1->second->psm, it1->second->fbp);
#endif
ZZLog::Debug_Log("Frame fbw:0x%x fbh:0x%x psm:0x%x fbp:0x%x", frame.fbw, frame.fbh, frame.psm, frame.fbp);
PrintTargets();
// create anew
ptarg = (opts & TO_DepthBuffer) ? new CDepthTarget : new CRenderTarget;
CRenderTargetMngr* pmngrs[2] = { &s_DepthRTs, this == &s_RTs ? &s_RTs : NULL };

View File

@ -115,7 +115,7 @@ class CRenderTargetMngr
}
static void DestroyTarg(CRenderTarget* ptarg);
void PrintTargets();
MAPTARGETS mapTargets, mapDummyTargs;
};
@ -268,26 +268,34 @@ inline u16 ShiftHeight(int fbh, int fbp, int fbhCalc)
return fbh;
}
//#define FRAME_KEY_BY_FBH
//FIXME: this code is for P4 and KH1. It should not be so strange!
//Dummy targets was deleted from mapTargets, but not erased.
inline u32 GetFrameKeyDummy(int fbp, int fbw, int fbh, int psm)
{
// if (fbp > 0x2000 && ZZOgl_fbh_Calc(fbp, fbw, psm) < 0x400 && ZZOgl_fbh_Calc(fbp, fbw, psm) != fbh)
// ZZLog::Debug_Log("Z %x %x %x %x\n", fbh, fbhCalc, fbp, ZZOgl_fbh_Calc(fbp, fbw, psm));
// height over 1024 would shrink to 1024, so dummy targets with calculated size more than 0x400 should be
// distinct by real height. But in FFX there is 3e0 height target, so I put 0x300 as limit.
#ifndef FRAME_KEY_BY_FBH
int calc = ZZOgl_fbh_Calc(fbp, fbw, psm);
if (/*fbp > 0x2000 && */calc < 0x300)
return ((fbw << 16) | calc);
else
#endif
return ((fbw << 16) | fbh);
}
inline u32 GetFrameKeyDummy(const frameInfo& frame)
{
// if (frame.fbp > 0x2000 && ZZOgl_fbh_Calc(frame) < 0x400 && ZZOgl_fbh_Calc(frame) != frame.fbh)
// printf ("Z %x %x %x %x\n", frame.fbh, frame.fbhCalc, frame.fbp, ZZOgl_fbh_Calc(frame));
// height over 1024 would shrink to 1024, so dummy targets with calculated size more than 0x400 should be
// distinct by real height. But in FFX there is 3e0 height target, so I put 0x300 as limit
if (/*frame.fbp > 0x2000 && */ZZOgl_fbh_Calc(frame) < 0x300)
return (((frame.fbw) << 16) | ZZOgl_fbh_Calc(frame));
else
return (((frame.fbw) << 16) | frame.fbh);
return GetFrameKeyDummy(frame.fbp, frame.fbw, frame.fbh, frame.psm);
}
inline u32 GetFrameKeyDummy(CRenderTarget* frame)
{
if (/*frame->fbp > 0x2000 && */ZZOgl_fbh_Calc(frame->fbp, frame->fbw, frame->psm) < 0x300)
return (((frame->fbw) << 16) | ZZOgl_fbh_Calc(frame->fbp, frame->fbw, frame->psm));
else
return (((frame->fbw) << 16) | frame->fbh);
return GetFrameKeyDummy(frame->fbp, frame->fbw, frame->fbh, frame->psm);
}
} // End of namespace