From 58d1f7cee15f7fb54bd7e5d51cc59e9d19425889 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 16 May 2022 13:04:38 +0200 Subject: [PATCH] pvr: reset nextContext in Reset(). Use tactx_Alloc for direct fb render Fix crash with multipass renders Issue #634 --- core/hw/pvr/Renderer_if.cpp | 3 +-- core/hw/pvr/ta_ctx.cpp | 2 +- core/hw/pvr/ta_ctx.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index f62e38e76..7e8f4e019 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -268,8 +268,7 @@ void rend_vblank() if (!render_called && fb_dirty && FB_R_CTRL.fb_enable) { DEBUG_LOG(PVR, "Direct framebuffer write detected"); - TA_context *ctx = new TA_context(); - ctx->Alloc(); + TA_context *ctx = tactx_Alloc(); ctx->rend.isRenderFramebuffer = true; rend_start_render(ctx); fb_dirty = false; diff --git a/core/hw/pvr/ta_ctx.cpp b/core/hw/pvr/ta_ctx.cpp index d5cd184bf..545860f7b 100644 --- a/core/hw/pvr/ta_ctx.cpp +++ b/core/hw/pvr/ta_ctx.cpp @@ -106,7 +106,7 @@ static std::mutex mtx_pool; static std::vector ctx_pool; static std::vector ctx_list; -static TA_context *tactx_Alloc() +TA_context *tactx_Alloc() { TA_context *ctx = nullptr; diff --git a/core/hw/pvr/ta_ctx.h b/core/hw/pvr/ta_ctx.h index c934fb272..ab4b31209 100644 --- a/core/hw/pvr/ta_ctx.h +++ b/core/hw/pvr/ta_ctx.h @@ -348,6 +348,7 @@ struct TA_context { verify(tad.End() - tad.thd_root <= TA_DATA_SIZE); tad.Clear(); + nextContext = nullptr; rend_inuse.lock(); rend.Clear(); rend.proc_end = rend.proc_start = tad.thd_root; @@ -377,6 +378,7 @@ extern tad_context ta_tad; TA_context* tactx_Pop(u32 addr); void tactx_Term(); +TA_context *tactx_Alloc(); /* Ta Context