From: notaz Date: Wed, 1 Aug 2012 22:30:57 +0000 (+0300) Subject: gpu_unai: merge Franxis' range fix X-Git-Tag: r15~1 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ed4ca47610027e8a0448d61389df5a583bd659b;p=pcsx_rearmed.git gpu_unai: merge Franxis' range fix --- diff --git a/plugins/gpu_unai/gpu.cpp b/plugins/gpu_unai/gpu.cpp index 3c30ffaf..46552acd 100644 --- a/plugins/gpu_unai/gpu.cpp +++ b/plugins/gpu_unai/gpu.cpp @@ -107,12 +107,10 @@ u32 GPU_GP1; // GPU Raster Macros #define GPU_RGB16(rgb) ((((rgb)&0xF80000)>>9)|(((rgb)&0xF800)>>6)|(((rgb)&0xF8)>>3)) -#define GPU_EXPANDSIGN_POLY(x) (((s32)(x)<<20)>>20) -//#define GPU_EXPANDSIGN_POLY(x) (((s32)(x)<<21)>>21) -#define GPU_EXPANDSIGN_SPRT(x) (((s32)(x)<<21)>>21) +#define GPU_EXPANDSIGN(x) (((s32)(x)<<21)>>21) -//#define GPU_TESTRANGE(x) { if((u32)(x+1024) > 2047) return; } -#define GPU_TESTRANGE(x) { if ((x<-1023) || (x>1023)) return; } +#define CHKMAX_X 1024 +#define CHKMAX_Y 512 #define GPU_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);} diff --git a/plugins/gpu_unai/gpu_raster_line.h b/plugins/gpu_unai/gpu_raster_line.h index 6d66c7d1..4edfa06f 100644 --- a/plugins/gpu_unai/gpu_raster_line.h +++ b/plugins/gpu_unai/gpu_raster_line.h @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * ***************************************************************************/ +#define GPU_TESTRANGE(x) { if((u32)(x+1024) > 2047) return; } + /////////////////////////////////////////////////////////////////////////////// // GPU internal line drawing functions diff --git a/plugins/gpu_unai/gpu_raster_polygon.h b/plugins/gpu_unai/gpu_raster_polygon.h index 4b338f70..c4b03509 100644 --- a/plugins/gpu_unai/gpu_raster_polygon.h +++ b/plugins/gpu_unai/gpu_raster_polygon.h @@ -18,6 +18,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * ***************************************************************************/ +#define GPU_TESTRANGE3() \ +{ \ + if(x0<0) { if((x1-x0)>CHKMAX_X) return; if((x2-x0)>CHKMAX_X) return; } \ + if(x1<0) { if((x0-x1)>CHKMAX_X) return; if((x2-x1)>CHKMAX_X) return; } \ + if(x2<0) { if((x0-x2)>CHKMAX_X) return; if((x1-x2)>CHKMAX_X) return; } \ + if(y0<0) { if((y1-y0)>CHKMAX_Y) return; if((y2-y0)>CHKMAX_Y) return; } \ + if(y1<0) { if((y0-y1)>CHKMAX_Y) return; if((y2-y1)>CHKMAX_Y) return; } \ + if(y2<0) { if((y0-y2)>CHKMAX_Y) return; if((y1-y2)>CHKMAX_Y) return; } \ +} + /////////////////////////////////////////////////////////////////////////////// // GPU internal polygon drawing functions @@ -31,12 +41,14 @@ void gpuDrawF3(const PP gpuPolySpanDriver) s32 x0, x1, x2, x3, dx3=0, x4, dx4=0, dx; s32 y0, y1, y2; - x0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[2]); GPU_TESTRANGE(x0); - y0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[3]); GPU_TESTRANGE(y0); - x1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[4]); GPU_TESTRANGE(x1); - y1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[5]); GPU_TESTRANGE(y1); - x2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[6]); GPU_TESTRANGE(x2); - y2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[7]); GPU_TESTRANGE(y2); + x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2]); + y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3]); + x1 = GPU_EXPANDSIGN(PacketBuffer.S2[4]); + y1 = GPU_EXPANDSIGN(PacketBuffer.S2[5]); + x2 = GPU_EXPANDSIGN(PacketBuffer.S2[6]); + y2 = GPU_EXPANDSIGN(PacketBuffer.S2[7]); + + GPU_TESTRANGE3(); x0 += DrawingOffset[0]; x1 += DrawingOffset[0]; x2 += DrawingOffset[0]; y0 += DrawingOffset[1]; y1 += DrawingOffset[1]; y2 += DrawingOffset[1]; @@ -164,12 +176,14 @@ void gpuDrawFT3(const PP gpuPolySpanDriver) s32 u0, u1, u2, u3, du3=0; s32 v0, v1, v2, v3, dv3=0; - x0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[2] ); GPU_TESTRANGE(x0); - y0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[3] ); GPU_TESTRANGE(y0); - x1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[6] ); GPU_TESTRANGE(x1); - y1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[7] ); GPU_TESTRANGE(y1); - x2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[10]); GPU_TESTRANGE(x2); - y2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[11]); GPU_TESTRANGE(y2); + x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2] ); + y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3] ); + x1 = GPU_EXPANDSIGN(PacketBuffer.S2[6] ); + y1 = GPU_EXPANDSIGN(PacketBuffer.S2[7] ); + x2 = GPU_EXPANDSIGN(PacketBuffer.S2[10]); + y2 = GPU_EXPANDSIGN(PacketBuffer.S2[11]); + + GPU_TESTRANGE3(); x0 += DrawingOffset[0]; x1 += DrawingOffset[0]; x2 += DrawingOffset[0]; y0 += DrawingOffset[1]; y1 += DrawingOffset[1]; y2 += DrawingOffset[1]; @@ -352,12 +366,14 @@ void gpuDrawG3(const PP gpuPolySpanDriver) s32 g0, g1, g2, g3, dg3=0; s32 b0, b1, b2, b3, db3=0; - x0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[2] ); GPU_TESTRANGE(x0); - y0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[3] ); GPU_TESTRANGE(y0); - x1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[6] ); GPU_TESTRANGE(x1); - y1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[7] ); GPU_TESTRANGE(y1); - x2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[10]); GPU_TESTRANGE(x2); - y2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[11]); GPU_TESTRANGE(y2); + x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2] ); + y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3] ); + x1 = GPU_EXPANDSIGN(PacketBuffer.S2[6] ); + y1 = GPU_EXPANDSIGN(PacketBuffer.S2[7] ); + x2 = GPU_EXPANDSIGN(PacketBuffer.S2[10]); + y2 = GPU_EXPANDSIGN(PacketBuffer.S2[11]); + + GPU_TESTRANGE3(); x0 += DrawingOffset[0]; x1 += DrawingOffset[0]; x2 += DrawingOffset[0]; y0 += DrawingOffset[1]; y1 += DrawingOffset[1]; y2 += DrawingOffset[1]; @@ -536,12 +552,14 @@ void gpuDrawGT3(const PP gpuPolySpanDriver) s32 g0, g1, g2, g3, dg3=0; s32 b0, b1, b2, b3, db3=0; - x0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[2] ); GPU_TESTRANGE(x0); - y0 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[3] ); GPU_TESTRANGE(y0); - x1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[8] ); GPU_TESTRANGE(x1); - y1 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[9] ); GPU_TESTRANGE(y1); - x2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[14]); GPU_TESTRANGE(x2); - y2 = GPU_EXPANDSIGN_POLY(PacketBuffer.S2[15]); GPU_TESTRANGE(y2); + x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2] ); + y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3] ); + x1 = GPU_EXPANDSIGN(PacketBuffer.S2[8] ); + y1 = GPU_EXPANDSIGN(PacketBuffer.S2[9] ); + x2 = GPU_EXPANDSIGN(PacketBuffer.S2[14]); + y2 = GPU_EXPANDSIGN(PacketBuffer.S2[15]); + + GPU_TESTRANGE3(); x0 += DrawingOffset[0]; x1 += DrawingOffset[0]; x2 += DrawingOffset[0]; y0 += DrawingOffset[1]; y1 += DrawingOffset[1]; y2 += DrawingOffset[1]; diff --git a/plugins/gpu_unai/gpu_raster_sprite.h b/plugins/gpu_unai/gpu_raster_sprite.h index 5075227e..a700db32 100644 --- a/plugins/gpu_unai/gpu_raster_sprite.h +++ b/plugins/gpu_unai/gpu_raster_sprite.h @@ -29,8 +29,8 @@ void gpuDrawS(const PS gpuSpriteSpanDriver) s32 u0; s32 v0; - x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0]; - y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1]; + x1 = x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2]) + DrawingOffset[0]; + y1 = y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3]) + DrawingOffset[1]; x1+= PacketBuffer.S2[6]; y1+= PacketBuffer.S2[7]; @@ -95,8 +95,8 @@ void gpuDrawS16(void) s32 ymin, ymax; u32 h = 16; - x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0]; - y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1]; + x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2]) + DrawingOffset[0]; + y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3]) + DrawingOffset[1]; xmin = DrawingArea[0]; xmax = DrawingArea[2]; ymin = DrawingArea[1]; ymax = DrawingArea[3]; @@ -131,8 +131,8 @@ void gpuDrawT(const PT gpuTileSpanDriver) s32 x0, y0; s32 x1, y1; - x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0]; - y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1]; + x1 = x0 = GPU_EXPANDSIGN(PacketBuffer.S2[2]) + DrawingOffset[0]; + y1 = y0 = GPU_EXPANDSIGN(PacketBuffer.S2[3]) + DrawingOffset[1]; x1+= PacketBuffer.S2[4]; y1+= PacketBuffer.S2[5]; diff --git a/plugins/gpu_unai/gpulib_if.cpp b/plugins/gpu_unai/gpulib_if.cpp index d6658952..38e7ce1a 100644 --- a/plugins/gpu_unai/gpulib_if.cpp +++ b/plugins/gpu_unai/gpulib_if.cpp @@ -111,12 +111,10 @@ static u32 GPU_GP1; // GPU Raster Macros #define GPU_RGB16(rgb) ((((rgb)&0xF80000)>>9)|(((rgb)&0xF800)>>6)|(((rgb)&0xF8)>>3)) -#define GPU_EXPANDSIGN_POLY(x) (((s32)(x)<<20)>>20) -//#define GPU_EXPANDSIGN_POLY(x) (((s32)(x)<<21)>>21) -#define GPU_EXPANDSIGN_SPRT(x) (((s32)(x)<<21)>>21) +#define GPU_EXPANDSIGN(x) (((s32)(x)<<21)>>21) -//#define GPU_TESTRANGE(x) { if((u32)(x+1024) > 2047) return; } -#define GPU_TESTRANGE(x) { if ((x<-1023) || (x>1023)) return; } +#define CHKMAX_X 1024 +#define CHKMAX_Y 512 #define GPU_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);}