From: Paul Cercueil Date: Thu, 2 Nov 2023 09:49:09 +0000 (+0100) Subject: unai: Preserve MSB in light routines X-Git-Tag: r24~65 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=846344d40d18b731488e874ea67ef5d66173f62b;p=pcsx_rearmed.git unai: Preserve MSB in light routines Apply the "MSB_PRESERVED" speed hack to non-ARM architectures. Signed-off-by: Paul Cercueil --- diff --git a/plugins/gpu_unai/gpu_inner.h b/plugins/gpu_unai/gpu_inner.h index eb209ef4..9f18735d 100644 --- a/plugins/gpu_unai/gpu_inner.h +++ b/plugins/gpu_unai/gpu_inner.h @@ -62,17 +62,16 @@ #define gpuLightingRGB gpuLightingRGBARM #define gpuLightingTXT gpuLightingTXTARM #define gpuLightingTXTGouraud gpuLightingTXTGouraudARM -// Non-dithering lighting and blending functions preserve uSrc -// MSB. This saves a few operations and useless load/stores. -#define MSB_PRESERVED (!CF_DITHER) #else #define gpuBlending gpuBlendingGeneric #define gpuLightingRGB gpuLightingRGBGeneric #define gpuLightingTXT gpuLightingTXTGeneric #define gpuLightingTXTGouraud gpuLightingTXTGouraudGeneric -#define MSB_PRESERVED 0 #endif +// Non-dithering lighting and blending functions preserve uSrc +// MSB. This saves a few operations and useless load/stores. +#define MSB_PRESERVED (!CF_DITHER) // If defined, Gouraud colors are fixed-point 5.11, otherwise they are 8.16 // This is only for debugging/verification of low-precision colors in C. diff --git a/plugins/gpu_unai/gpu_inner_light.h b/plugins/gpu_unai/gpu_inner_light.h index f90e8ec1..f4f685bb 100644 --- a/plugins/gpu_unai/gpu_inner_light.h +++ b/plugins/gpu_unai/gpu_inner_light.h @@ -172,7 +172,8 @@ GPU_INLINE uint_fast16_t gpuLightingTXTGeneric(uint_fast16_t uSrc, u8 r5, u8 g5, { return (gpu_unai.LightLUT[((uSrc&0x7C00)>>5) | b5] << 10) | (gpu_unai.LightLUT[ (uSrc&0x03E0) | g5] << 5) | - (gpu_unai.LightLUT[((uSrc&0x001F)<<5) | r5] ); + (gpu_unai.LightLUT[((uSrc&0x001F)<<5) | r5] ) | + (uSrc & 0x8000); } @@ -194,7 +195,8 @@ GPU_INLINE uint_fast16_t gpuLightingTXTGouraudGeneric(uint_fast16_t uSrc, u32 gC { return (gpu_unai.LightLUT[((uSrc&0x7C00)>>5) | ((gCol>> 5)&0x1F)]<<10) | (gpu_unai.LightLUT[ (uSrc&0x03E0) | ((gCol>>16)&0x1F)]<< 5) | - (gpu_unai.LightLUT[((uSrc&0x001F)<<5) | (gCol>>27) ] ); + (gpu_unai.LightLUT[((uSrc&0x001F)<<5) | (gCol>>27) ]) | + (uSrc & 0x8000); }