From e3bb0a09ab40fd8c365f9de8ccf5b1aa9c4c83f9 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 26 Sep 2018 09:42:43 +0200 Subject: [PATCH] Detect TA overruns and cancel the rendering. Increase vertices, indices and translucent polygons max count. Fixes crashes in D2 and Triggerheart Exelica. --- core/hw/pvr/ta_ctx.h | 6 +++--- core/hw/pvr/ta_vtx.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/hw/pvr/ta_ctx.h b/core/hw/pvr/ta_ctx.h index 832f656ff..92fe66080 100644 --- a/core/hw/pvr/ta_ctx.h +++ b/core/hw/pvr/ta_ctx.h @@ -159,12 +159,12 @@ struct TA_context { tad.Reset((u8*)OS_aligned_malloc(32, 8*1024*1024)); - rend.verts.InitBytes(1024*1024,&rend.Overrun); //up to 1 mb of vtx data/frame = ~ 38k vtx/frame - rend.idx.Init(60*1024,&rend.Overrun); //up to 60K indexes ( idx have stripification overhead ) + rend.verts.InitBytes(2*1024*1024,&rend.Overrun); //up to 2 mb of vtx data/frame = ~ 76k vtx/frame + rend.idx.Init(120*1024,&rend.Overrun); //up to 120K indexes ( idx have stripification overhead ) rend.global_param_op.Init(4096,&rend.Overrun); rend.global_param_pt.Init(4096,&rend.Overrun); rend.global_param_mvo.Init(4096,&rend.Overrun); - rend.global_param_tr.Init(4096,&rend.Overrun); + rend.global_param_tr.Init(8192,&rend.Overrun); rend.modtrig.Init(8192,&rend.Overrun); diff --git a/core/hw/pvr/ta_vtx.cpp b/core/hw/pvr/ta_vtx.cpp index dc9506340..5277ab292 100644 --- a/core/hw/pvr/ta_vtx.cpp +++ b/core/hw/pvr/ta_vtx.cpp @@ -1437,8 +1437,6 @@ int ta_parse_cnt = 0; */ bool ta_parse_vdrc(TA_context* ctx) { - bool rv=false; - verify( vd_ctx == 0); vd_ctx = ctx; vd_rc = vd_ctx->rend; @@ -1457,15 +1455,18 @@ bool ta_parse_vdrc(TA_context* ctx) } while(ta_data<=ta_data_end); - - rv = true; //whatever } + bool overrun = ctx->rend.Overrun; vd_ctx->rend = vd_rc; vd_ctx = 0; ctx->rend_inuse.Unlock(); - return rv; + ctx->rend.Overrun = overrun; + if (overrun) + printf("Warning: TA context overrun\n"); + + return !overrun; }