From a0b50cd41d13bc6bf246721b0613b60746198951 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 17 Jan 2023 11:36:00 +0100 Subject: [PATCH] pvr: don't crash on invalid poly list types. log and ignore Fix for MINIDUMP-3Z --- core/hw/pvr/ta_vtx.cpp | 48 ++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/core/hw/pvr/ta_vtx.cpp b/core/hw/pvr/ta_vtx.cpp index 19b48cd44..8fe3730d7 100644 --- a/core/hw/pvr/ta_vtx.cpp +++ b/core/hw/pvr/ta_vtx.cpp @@ -45,19 +45,32 @@ class BaseTAParser } public: - static void startList(u32 listType) + static bool startList(u32 listType) { if (CurrentList != ListType_None) - return; - CurrentList = listType; - if (listType == ListType_Opaque) + return true; + switch (listType) + { + case ListType_Opaque: CurrentPPlist = &vd_rc.global_param_op; - else if (listType == ListType_Punch_Through) + break; + case ListType_Punch_Through: CurrentPPlist = &vd_rc.global_param_pt; - else if (listType == ListType_Translucent) + break; + case ListType_Translucent: CurrentPPlist = &vd_rc.global_param_tr; - + break; + case ListType_Opaque_Modifier_Volume: + case ListType_Translucent_Modifier_Volume: + break; + default: + WARN_LOG(PVR, "Invalid list type %d", listType); + return false; + } + CurrentList = listType; CurrentPP = nullptr; + + return true; } static void endList() @@ -404,15 +417,17 @@ strip_end: TileClipMode(data->pcw.User_Clip); //Yep , C++ IS lame & limited #include "ta_const_df.h" - if (CurrentList==ListType_None) - startList(data->pcw.ListType); - - if (IsModVolList(CurrentList)) + if (CurrentList == ListType_None && !startList(data->pcw.ListType)) + { + // Invalid list type + data += SZ32; + } + else if (IsModVolList(CurrentList)) { //accept mod data StartModVol((TA_ModVolParam*)data); VertexDataFP = ta_mod_vol_data; - data+=SZ32; + data += SZ32; } else { @@ -451,16 +466,13 @@ strip_end: //32B //Sets Sprite info , and switches to ta_sprite_data function case ParamType_Sprite: + TileClipMode(data->pcw.User_Clip); + if (CurrentList != ListType_None || startList(data->pcw.ListType)) { - - TileClipMode(data->pcw.User_Clip); - if (CurrentList==ListType_None) - startList(data->pcw.ListType); - VertexDataFP = ta_sprite_data; AppendSpriteParam((TA_SpriteParam*)data); - data+=SZ32; } + data += SZ32; break; //Variable size