pvr: re-use TA contexts if not used for 60 frames
This commit is contained in:
parent
d3aed076a6
commit
37c17e4300
|
@ -144,38 +144,56 @@ static void tactx_Recycle(TA_context* ctx)
|
|||
|
||||
static TA_context *tactx_Find(u32 addr, bool allocnew)
|
||||
{
|
||||
TA_context *oldCtx = nullptr;
|
||||
for (TA_context *ctx : ctx_list)
|
||||
{
|
||||
if (ctx->Address == addr)
|
||||
{
|
||||
ctx->lastFrameUsed = FrameCount;
|
||||
return ctx;
|
||||
}
|
||||
if (FrameCount - ctx->lastFrameUsed > 60)
|
||||
oldCtx = ctx;
|
||||
}
|
||||
|
||||
if (allocnew)
|
||||
{
|
||||
TA_context *ctx = tactx_Alloc();
|
||||
TA_context *ctx;
|
||||
if (oldCtx != nullptr)
|
||||
{
|
||||
ctx = oldCtx;
|
||||
ctx->Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx = tactx_Alloc();
|
||||
ctx_list.push_back(ctx);
|
||||
}
|
||||
ctx->Address = addr;
|
||||
ctx_list.push_back(ctx);
|
||||
ctx->lastFrameUsed = FrameCount;
|
||||
|
||||
return ctx;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TA_context* tactx_Pop(u32 addr)
|
||||
TA_context *tactx_Pop(u32 addr)
|
||||
{
|
||||
for (size_t i=0; i<ctx_list.size(); i++)
|
||||
for (size_t i = 0; i < ctx_list.size(); i++)
|
||||
{
|
||||
if (ctx_list[i]->Address==addr)
|
||||
if (ctx_list[i]->Address == addr)
|
||||
{
|
||||
TA_context* rv = ctx_list[i];
|
||||
TA_context *ctx = ctx_list[i];
|
||||
|
||||
if (ta_ctx == rv)
|
||||
if (::ta_ctx == ctx)
|
||||
SetCurrentTARC(TACTX_NONE);
|
||||
|
||||
ctx_list.erase(ctx_list.begin() + i);
|
||||
|
||||
return rv;
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void tactx_Term()
|
||||
|
|
|
@ -307,6 +307,7 @@ struct rend_context
|
|||
struct TA_context
|
||||
{
|
||||
u32 Address;
|
||||
u32 lastFrameUsed;
|
||||
|
||||
tad_context tad;
|
||||
rend_context rend;
|
||||
|
|
Loading…
Reference in New Issue