From 846344d40d18b731488e874ea67ef5d66173f62b Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 2 Nov 2023 10:49:09 +0100 Subject: [PATCH] unai: Preserve MSB in light routines Apply the "MSB_PRESERVED" speed hack to non-ARM architectures. Signed-off-by: Paul Cercueil --- plugins/gpu_unai/gpu_inner.h | 7 +++---- plugins/gpu_unai/gpu_inner_light.h | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) 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); } -- 2.39.5