From 537c2a4ed66ab806f02f310f34e1ce69c2f4cab9 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sat, 21 Sep 2019 22:53:09 +0200 Subject: [PATCH] pvr: reset face and offset colors when not set in poly param Fixes black ice in NHL 2K2 and black players in NHL 2K Clean up Don't build soft renderer --- core/hw/pvr/ta.cpp | 6 ++--- core/hw/pvr/ta_ctx.h | 9 +++++-- core/hw/pvr/ta_vtx.cpp | 51 ++++++++++++++++++++++++++++++++-------- core/rend/gles/gles.h | 2 +- core/rend/gles/gltex.cpp | 20 +++++++--------- core/serialize.cpp | 4 ++-- shell/linux/Makefile | 8 ------- 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/core/hw/pvr/ta.cpp b/core/hw/pvr/ta.cpp index 95b6cf79c..6a6d1f53b 100644 --- a/core/hw/pvr/ta.cpp +++ b/core/hw/pvr/ta.cpp @@ -225,10 +225,6 @@ static NOINLINE void DYNACALL ta_handle_cmd(u32 trans) ta_fsm_cl=dat->pcw.ListType; //printf("List %d ended\n",ta_fsm_cl); - if (ta_fsm_cl==ListType_Translucent) - { - //ta_tad.early=os_GetSeconds(); - } asic_RaiseInterrupt( ListEndInterrupt[ta_fsm_cl]); ta_fsm_cl=7; trans=TAS_NS; @@ -271,6 +267,7 @@ void ta_vtx_ListCont() ta_tad.Continue(); ta_cur_state=TAS_NS; + ta_fsm_cl = 7; } void ta_vtx_ListInit() { @@ -278,6 +275,7 @@ void ta_vtx_ListInit() ta_tad.ClearPartial(); ta_cur_state=TAS_NS; + ta_fsm_cl = 7; } void ta_vtx_SoftReset() { diff --git a/core/hw/pvr/ta_ctx.h b/core/hw/pvr/ta_ctx.h index 2b0f95ffd..ee7963f44 100644 --- a/core/hw/pvr/ta_ctx.h +++ b/core/hw/pvr/ta_ctx.h @@ -118,8 +118,6 @@ struct rend_context bool isRTT; bool isRenderFramebuffer; - double early; - FB_X_CLIP_type fb_X_CLIP; FB_Y_CLIP_type fb_Y_CLIP; @@ -152,7 +150,14 @@ struct rend_context Overrun=false; fZ_min= 1000000.0f; fZ_max= 1.0f; + isRTT = false; isRenderFramebuffer = false; + fb_X_CLIP.min = 0; + fb_X_CLIP.max = 639; + fb_Y_CLIP.min = 0; + fb_Y_CLIP.max = 479; + fog_clamp_min = 0; + fog_clamp_max = 0xffffffff; } }; diff --git a/core/hw/pvr/ta_vtx.cpp b/core/hw/pvr/ta_vtx.cpp index a51fdeb94..13026db1b 100644 --- a/core/hw/pvr/ta_vtx.cpp +++ b/core/hw/pvr/ta_vtx.cpp @@ -82,7 +82,7 @@ typedef void TACALL TaPolyParamFP(void* ptr); static TaListFP* TaCmd; static u32 CurrentList; -static TaListFP* VerxexDataFP; +static TaListFP* VertexDataFP; static bool ListIsFinished[5]; static f32 f16(u16 v) @@ -363,7 +363,7 @@ public: //printf("End list %X\n",CurrentList); ListIsFinished[CurrentList]=true; CurrentList=ListType_None; - VerxexDataFP=NullVertexData; + VertexDataFP = NullVertexData; data+=SZ32; TA_EOL; } @@ -403,7 +403,7 @@ public: { //accept mod data StartModVol((TA_ModVolParam*)data); - VerxexDataFP=ta_mod_vol_data; + VertexDataFP = ta_mod_vol_data; data+=SZ32; } else @@ -414,7 +414,7 @@ public: u32 pdid=(u8)(uid); u32 ppid=(u8)(uid>>8); - VerxexDataFP=ta_poly_data_lut[pdid]; + VertexDataFP = ta_poly_data_lut[pdid]; if (data != data_end || psz==1) @@ -447,7 +447,7 @@ public: if (CurrentList==ListType_None) ta_list_start(data->pcw.ListType); //start a list ;) - VerxexDataFP=ta_sprite_data; + VertexDataFP = ta_sprite_data; //printf("Sprite \n"); AppendSpriteParam((TA_SpriteParam*)data); data+=SZ32; @@ -459,9 +459,9 @@ public: //log ("vtx"); { - //printf("VTX:0x%08X\n",VerxexDataFP); - //verify(VerxexDataFP!=NullVertexData); - data=VerxexDataFP(data,data_end); + //printf("VTX:0x%08X\n", VertexDataFP); + //verify(VertexDataFP != NullVertexData); + data = VertexDataFP(data, data_end); } break; @@ -499,7 +499,7 @@ public: ta_type_lut[i]=rv; } - VerxexDataFP = NullVertexData; + VertexDataFP = NullVertexData; } /* Volume,Col_Type,Texture,Offset,Gouraud,16bit_UV @@ -686,6 +686,16 @@ public: CurrentList = ListType_None; ListIsFinished[0] = ListIsFinished[1] = ListIsFinished[2] = ListIsFinished[3] = ListIsFinished[4] = false; tileclip_val = 0; + VertexDataFP = NullVertexData; + memset(FaceBaseColor, 0, sizeof(FaceBaseColor)); + memset(FaceOffsColor, 0, sizeof(FaceOffsColor)); + memset(FaceBaseColor1, 0, sizeof(FaceBaseColor1)); + memset(FaceOffsColor1, 0, sizeof(FaceOffsColor1)); + SFaceBaseColor = 0; + SFaceOffsColor = 0; + lmr = NULL; + CurrentPP = NULL; + CurrentPPlist = NULL; } __forceinline @@ -778,14 +788,20 @@ public: #define poly_float_color(to,src) \ poly_float_color_(to,pp->src##A,pp->src##R,pp->src##G,pp->src##B) - //poly param handling + // Poly param handling + + // Packed/Floating Color __forceinline static void TACALL AppendPolyParam0(void* vpp) { TA_PolyParam0* pp=(TA_PolyParam0*)vpp; glob_param_bdc(pp); + memset(FaceBaseColor, 0xff, sizeof(FaceBaseColor)); + memset(FaceOffsColor, 0xff, sizeof(FaceOffsColor)); } + + // Intensity, no Offset Color __forceinline static void TACALL AppendPolyParam1(void* vpp) { @@ -793,7 +809,10 @@ public: glob_param_bdc(pp); poly_float_color(FaceBaseColor,FaceColor); + memset(FaceOffsColor, 0xff, sizeof(FaceOffsColor)); } + + // Intensity, use Offset Color __forceinline static void TACALL AppendPolyParam2A(void* vpp) { @@ -801,6 +820,7 @@ public: glob_param_bdc(pp); } + __forceinline static void TACALL AppendPolyParam2B(void* vpp) { @@ -809,18 +829,26 @@ public: poly_float_color(FaceBaseColor,FaceColor); poly_float_color(FaceOffsColor,FaceOffset); } + + // Packed Color, with Two Volumes __forceinline static void TACALL AppendPolyParam3(void* vpp) { TA_PolyParam3* pp=(TA_PolyParam3*)vpp; glob_param_bdc(pp); + memset(FaceBaseColor, 0xff, sizeof(FaceBaseColor)); + memset(FaceOffsColor, 0xff, sizeof(FaceOffsColor)); + memset(FaceBaseColor1, 0xff, sizeof(FaceBaseColor1)); + memset(FaceOffsColor1, 0xff, sizeof(FaceOffsColor1)); CurrentPP->tsp1.full = pp->tsp1.full; CurrentPP->tcw1.full = pp->tcw1.full; if (pp->pcw.Texture) CurrentPP->texid1 = renderer->GetTexture(pp->tsp1, pp->tcw1); } + + // Intensity, with Two Volumes __forceinline static void TACALL AppendPolyParam4A(void* vpp) { @@ -833,6 +861,7 @@ public: if (pp->pcw.Texture) CurrentPP->texid1 = renderer->GetTexture(pp->tsp1, pp->tcw1); } + __forceinline static void TACALL AppendPolyParam4B(void* vpp) { @@ -840,6 +869,8 @@ public: poly_float_color(FaceBaseColor, FaceColor0); poly_float_color(FaceBaseColor1, FaceColor1); + memset(FaceOffsColor, 0xff, sizeof(FaceOffsColor)); + memset(FaceOffsColor1, 0xff, sizeof(FaceOffsColor1)); } //Poly Strip handling diff --git a/core/rend/gles/gles.h b/core/rend/gles/gles.h index 0ac0d8da5..a993c0696 100755 --- a/core/rend/gles/gles.h +++ b/core/rend/gles/gles.h @@ -260,7 +260,7 @@ struct TextureCacheData u32 w,h; //width & height of the texture u32 size; //size, in bytes, in vram - PvrTexInfo* tex; + const PvrTexInfo* tex; TexConvFP* texconv; TexConvFP32* texconv32; diff --git a/core/rend/gles/gltex.cpp b/core/rend/gles/gltex.cpp index 9e20951c2..fd873fe3c 100644 --- a/core/rend/gles/gltex.cpp +++ b/core/rend/gles/gltex.cpp @@ -47,7 +47,7 @@ struct PvrTexInfo TexConvFP32 *VQ32; }; -PvrTexInfo format[8]= +static const PvrTexInfo format[8] = { // name bpp GL format Planar Twiddled VQ Planar(32b) Twiddled(32b) VQ (32b) {"1555", 16, GL_UNSIGNED_SHORT_5_5_5_1, tex1555_PL, tex1555_TW, tex1555_VQ, tex1555_PL32, tex1555_TW32, tex1555_VQ32 }, //1555 {"565", 16, GL_UNSIGNED_SHORT_5_6_5, tex565_PL, tex565_TW, tex565_VQ, tex565_PL32, tex565_TW32, tex565_VQ32 }, //565 @@ -59,7 +59,7 @@ PvrTexInfo format[8]= {"ns/1555", 0}, // Not supported (1555) }; -const u32 MipPoint[8] = +static const u32 MipPoint[8] = { 0x00006,//8 0x00016,//16 @@ -71,10 +71,10 @@ const u32 MipPoint[8] = 0x15556//1024 }; -const GLuint PAL_TYPE[4]= +static const GLuint PAL_TYPE[4]= {GL_UNSIGNED_SHORT_5_5_5_1,GL_UNSIGNED_SHORT_5_6_5,GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_BYTE}; -CustomTexture custom_texture; +static CustomTexture custom_texture; static void dumpRtTexture(u32 name, u32 w, u32 h) { char sname[256]; @@ -470,12 +470,10 @@ bool TextureCacheData::Delete() return true; } - -#include -map TexCache; +static map TexCache; typedef map::iterator TexCacheIter; -TextureCacheData *getTextureCacheData(TSP tsp, TCW tcw); +static TextureCacheData *getTextureCacheData(TSP tsp, TCW tcw); void BindRTT(u32 addy, u32 fbw, u32 fbh, u32 channels, u32 fmt) { @@ -704,11 +702,11 @@ static float LastTexCacheStats; // Only use TexU and TexV from TSP in the cache key // TexV : 7, TexU : 7 -const TSP TSPTextureCacheMask = { { 7, 7 } }; +static const TSP TSPTextureCacheMask = { { 7, 7 } }; // TexAddr : 0x1FFFFF, Reserved : 0, StrideSel : 0, ScanOrder : 1, PixelFmt : 7, VQ_Comp : 1, MipMapped : 1 -const TCW TCWTextureCacheMask = { { 0x1FFFFF, 0, 0, 1, 7, 1, 1 } }; +static const TCW TCWTextureCacheMask = { { 0x1FFFFF, 0, 0, 1, 7, 1, 1 } }; -TextureCacheData *getTextureCacheData(TSP tsp, TCW tcw) { +static TextureCacheData *getTextureCacheData(TSP tsp, TCW tcw) { u64 key = tsp.full & TSPTextureCacheMask.full; if (tcw.PixelFmt == PixelPal4 || tcw.PixelFmt == PixelPal8) // Paletted textures have a palette selection that must be part of the key diff --git a/core/serialize.cpp b/core/serialize.cpp index e45fd27dd..c30e552be 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -712,7 +712,6 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_US(i); // SFaceBaseColor REICAST_US(i); // SFaceOffsColor - pal_needs_update = true; REICAST_US(i); // palette_index REICAST_US(dumbool); // KillTex REICAST_SKIP(4 * 1024); // palette16_ram @@ -720,6 +719,7 @@ static bool dc_unserialize_libretro(void **data, unsigned int *total_size) REICAST_SKIP(2 * 8 * 4 * 1024); // detwiddle[][] REICAST_USA(vram.data, vram.size); + pal_needs_update = true; REICAST_USA(OnChipRAM.data,OnChipRAM_SIZE); register_unserialize(CCN, data, total_size, V7_LIBRETRO) ; @@ -1078,9 +1078,9 @@ bool dc_unserialize(void **data, unsigned int *total_size) REICAST_SKIP(4); REICAST_SKIP(4); } - pal_needs_update = true; REICAST_USA(vram.data, vram.size); + pal_needs_update = true; REICAST_USA(OnChipRAM.data,OnChipRAM_SIZE); diff --git a/shell/linux/Makefile b/shell/linux/Makefile index 6e3b2bc5b..9a024f5fd 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -109,10 +109,6 @@ ifneq (,$(findstring x86,$(platform))) CFLAGS += -m32 -D TARGET_LINUX_x86 -D TARGET_NO_AREC -fno-builtin-sqrtf CXXFLAGS += -fexceptions - ifneq (,$(findstring sse4_1,$(platform))) - HAS_SOFTREND := 1 - endif - # Generic 64 bit x86 (a.k.a. x64/AMD64/x86_64/Intel64/EM64T) else ifneq (,$(findstring x64,$(platform))) X64_REC := 1 @@ -122,10 +118,6 @@ else ifneq (,$(findstring x64,$(platform))) CXXFLAGS += -fexceptions LDFLAGS := -no-pie - ifneq (,$(findstring sse4_1,$(platform))) - HAS_SOFTREND := 1 - endif - # Generic 64 bit ARM (armv8) Linux else ifneq (,$(findstring arm64,$(platform))) NOT_ARM := 1