Cleanup textures after they are dead for a while
This commit is contained in:
parent
e22fd18ff8
commit
66d8b96ae3
|
@ -60,7 +60,7 @@
|
|||
*/
|
||||
|
||||
u32 VertexCount=0;
|
||||
u32 FrameCount=0;
|
||||
u32 FrameCount=1;
|
||||
|
||||
Renderer* rend;
|
||||
cResetEvent rs(false,true);
|
||||
|
|
|
@ -1558,6 +1558,8 @@ void FillBGP(TA_context* ctx)
|
|||
u32 vertex_ptr=strip_vert_num*strip_vs+strip_base +3*4;
|
||||
//now , all the info is ready :p
|
||||
|
||||
bgpp->texid = -1;
|
||||
|
||||
bgpp->isp.full=vri(strip_base);
|
||||
bgpp->tsp.full=vri(strip_base+4);
|
||||
bgpp->tcw.full=vri(strip_base+8);
|
||||
|
|
|
@ -197,8 +197,10 @@ __forceinline
|
|||
if (gp->texid != cache.texture)
|
||||
{
|
||||
cache.texture=gp->texid;
|
||||
if (gp->texid != -1)
|
||||
if (gp->texid != -1) {
|
||||
//verify(glIsTexture(gp->texid));
|
||||
glBindTexture(GL_TEXTURE_2D, gp->texid);
|
||||
}
|
||||
}
|
||||
|
||||
if (gp->tsp.full!=cache.tsp.full)
|
||||
|
|
|
@ -1178,11 +1178,15 @@ bool ProcessFrame(TA_context* ctx)
|
|||
if (!ta_parse_vdrc(ctx))
|
||||
return false;
|
||||
|
||||
CollectCleanup();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderFrame()
|
||||
{
|
||||
DoCleanup();
|
||||
|
||||
bool is_rtt=pvrrc.isRTT;
|
||||
|
||||
OSD_HOOK();
|
||||
|
|
|
@ -80,6 +80,9 @@ struct gl_ctx
|
|||
extern gl_ctx gl;
|
||||
|
||||
GLuint GetTexture(TSP tsp,TCW tcw);
|
||||
void CollectCleanup();
|
||||
void DoCleanup();
|
||||
|
||||
void BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt);
|
||||
int GetProgramID(u32 cp_AlphaTest, u32 pp_ClipTestMode,
|
||||
u32 pp_Texture, u32 pp_UseAlpha, u32 pp_IgnoreTexA, u32 pp_ShadInstr, u32 pp_Offset,
|
||||
|
|
|
@ -78,7 +78,7 @@ struct TextureCacheData
|
|||
PvrTexInfo* tex;
|
||||
TexConvFP* texconv;
|
||||
|
||||
bool dirty;
|
||||
u32 dirty;
|
||||
vram_block* lock_block;
|
||||
|
||||
u32 Lookups;
|
||||
|
@ -128,7 +128,7 @@ struct TextureCacheData
|
|||
//Reset state info ..
|
||||
Lookups=0;
|
||||
Updates=0;
|
||||
dirty=true;
|
||||
dirty=FrameCount;
|
||||
lock_block=0;
|
||||
|
||||
//decode info from tsp/tcw into the texture struct
|
||||
|
@ -242,7 +242,7 @@ struct TextureCacheData
|
|||
{
|
||||
//texture state tracking stuff
|
||||
Updates++;
|
||||
dirty=false;
|
||||
dirty=0;
|
||||
|
||||
GLuint textype=tex->type;
|
||||
|
||||
|
@ -419,6 +419,32 @@ GLuint GetTexture(TSP tsp,TCW tcw)
|
|||
return tf->texID;
|
||||
}
|
||||
|
||||
void CollectCleanup() {
|
||||
vector<u64> list;
|
||||
|
||||
u32 TargetFrame = max(120,FrameCount) - 120;
|
||||
|
||||
for (TexCacheIter i=TexCache.begin();i!=TexCache.end();i++)
|
||||
{
|
||||
if ( i->second.dirty && i->second.dirty < TargetFrame) {
|
||||
list.push_back(i->first);
|
||||
}
|
||||
|
||||
if (list.size() > 5)
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i=0; i<list.size(); i++) {
|
||||
//printf("Deleting %d\n",TexCache[list[i]].texID);
|
||||
TexCache[list[i]].Delete();
|
||||
|
||||
TexCache.erase(list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void DoCleanup() {
|
||||
|
||||
}
|
||||
void killtex()
|
||||
{
|
||||
for (TexCacheIter i=TexCache.begin();i!=TexCache.end();i++)
|
||||
|
@ -432,7 +458,7 @@ void killtex()
|
|||
void rend_text_invl(vram_block* bl)
|
||||
{
|
||||
TextureCacheData* tcd = (TextureCacheData*)bl->userdata;
|
||||
tcd->dirty=true;
|
||||
tcd->dirty=FrameCount;
|
||||
tcd->lock_block=0;
|
||||
|
||||
libCore_vramlock_Unlock_block_wb(bl);
|
||||
|
|
Loading…
Reference in New Issue