X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpu-gles%2FgpuPrim.c;h=5d17f2de33106f4ac0da0c258c927935a86556e9;hp=9b718a5f2004e03621a11246f61fdc43a0737878;hb=9f58cabba9806e2c365c64f7a3701efa6282aa72;hpb=ce879073e4f228deec8bec5db8a2ff640636c88f diff --git a/plugins/gpu-gles/gpuPrim.c b/plugins/gpu-gles/gpuPrim.c index 9b718a5f..5d17f2de 100644 --- a/plugins/gpu-gles/gpuPrim.c +++ b/plugins/gpu-gles/gpuPrim.c @@ -26,13 +26,6 @@ #define _IN_PRIMDRAW -#ifdef _WINDOWS -#include "stdafx.h" -#include "externals.h" -#include "gpu.h" -#include "draw.h" -#include "texture.h" -#else #include "gpuStdafx.h" #include "gpuExternals.h" #include "gpuPlugin.h" @@ -40,8 +33,6 @@ #include "gpuTexture.h" #include "gpuPrim.h" -#endif - //////////////////////////////////////////////////////////////////////// // defines //////////////////////////////////////////////////////////////////////// @@ -53,10 +44,9 @@ // globals //////////////////////////////////////////////////////////////////////// -#ifndef _WINDOWS EGLSurface surface; EGLDisplay display; -#endif + BOOL bDrawTextured; // current active drawing states BOOL bDrawSmoothShaded; @@ -146,66 +136,6 @@ void UpdateGlobalTP(unsigned short gdata) // Some ASM color convertion... Lewpy's special... //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -#pragma warning (disable : 4035) - -unsigned long DoubleBGR2RGB (unsigned long BGR) -{ - - __asm - { - mov eax, BGR /* this can hold the G value */ - mov ebx, eax /* this can hold the R value */ - mov edx, eax /* this can hold the B value */ - and ebx, 000000ffh /* mask the R value */ - shl ebx, 1 - test ebx, 00000100h - jz RSKIP - mov ebx, 000000ffh - -RSKIP: - and eax, 0000ff00h /* mask the G value */ - shl eax, 1 - test eax, 00010000h - jz GSKIP - mov eax, 0000ff00h - -GSKIP: - and edx, 00ff0000h /* mask the B value */ - shl edx, 1 - test edx, 01000000h - jz BSKIP - mov edx, 00ff0000h - -BSKIP: - or eax, ebx /* add R to G value */ - or eax, edx /* add B to RG value */ - } - /* Result returned in EAX */ -} - -unsigned short BGR24to16 (unsigned long BGR) -{ - __asm - { - mov eax, BGR /* this can hold the G value */ - mov ebx, eax /* this can hold the R value */ - mov edx, eax /* this can hold the B value */ - shr ebx, 3 /* move the R value */ - and edx, 00f80000h /* mask the B value */ - shr edx, 9 /* move the B value */ - and eax, 00f800h /* mask the G value */ - shr eax, 6 /* move the G value */ - and ebx, 0000001fh /* mask the R value */ - or eax, ebx /* add R to G value */ - or eax, edx /* add B to RG value */ - } - /* Result returned in AX */ -} - -#pragma warning (default : 4035) - -#else unsigned long DoubleBGR2RGB (unsigned long BGR) { @@ -228,13 +158,12 @@ unsigned short BGR24to16 (unsigned long BGR) return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6); } -#endif //////////////////////////////////////////////////////////////////////// // OpenGL primitive drawing commands //////////////////////////////////////////////////////////////////////// -__inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, +void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4) { @@ -732,7 +661,7 @@ void SetSemiTrans(void) if(!DrawSemiTrans) // no semi trans at all? { if(bBlendEnable) - {glDisable(GL_BLEND);bBlendEnable=FALSE;} // -> don't wanna blend + {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend ubGloAlpha=ubGloColAlpha=255; // -> full alpha return; // -> and bye } @@ -740,7 +669,7 @@ void SetSemiTrans(void) ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha; if(!bBlendEnable) - {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend + {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend if(TransSets[GlobalTextABR].srcFac!=obm1 || TransSets[GlobalTextABR].dstFac!=obm2) @@ -749,7 +678,7 @@ void SetSemiTrans(void) { obm1=TransSets[GlobalTextABR].srcFac; obm2=TransSets[GlobalTextABR].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } /*else if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR) @@ -780,7 +709,7 @@ void SetScanTrans(void) // blending for scan line */ obm1=TransSets[0].srcFac; obm2=TransSets[0].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } void SetScanTexTrans(void) // blending for scan mask texture @@ -793,7 +722,7 @@ void SetScanTexTrans(void) // blending for scan mask */ obm1=TransSets[2].srcFac; obm2=TransSets[2].dstFac; - glBlendFunc(obm1,obm2); // set blend func + glBlendFunc(obm1,obm2); glError(); // set blend func } //////////////////////////////////////////////////////////////////////// @@ -873,11 +802,11 @@ void SetSemiTransMulti(int Pass) } if(!bBlendEnable) - {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend + {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend if(bm1!=obm1 || bm2!=obm2) { - glBlendFunc(bm1,bm2); // set blend func + glBlendFunc(bm1,bm2); glError(); // set blend func obm1=bm1;obm2=bm2; } } @@ -1018,14 +947,14 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) else currTex=SelectSubTextureS(GlobalTextTP,ulClutID); if(gTexName!=currTex) - {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex);} + {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();} if(!bTexEnabled) // -> turn texturing on - {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D);} + {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();} } else // no texture ? if(bTexEnabled) - {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D);} // -> turn texturing off + {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off if(bSCol) // also set color ? { @@ -1051,6 +980,7 @@ void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol) { if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading else glShadeModel(GL_FLAT); + glError(); bOldSmoothShaded=bDrawSmoothShaded; } } @@ -1514,7 +1444,7 @@ void PrepareFullScreenUpload (long Position) //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -u8 * LoadDirectMovieFast(void); +unsigned char * LoadDirectMovieFast(void); void UploadScreenEx(long Position) { @@ -1523,14 +1453,14 @@ void UploadScreenEx(long Position) if(!PSXDisplay.DisplayMode.x) return; if(!PSXDisplay.DisplayMode.y) return; - glDisable(GL_SCISSOR_TEST); - glShadeModel(GL_FLAT); + glDisable(GL_SCISSOR_TEST); glError(); + glShadeModel(GL_FLAT); glError(); bOldSmoothShaded=FALSE; - glDisable(GL_BLEND); + glDisable(GL_BLEND); glError(); bBlendEnable=FALSE; - glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); glError(); bTexEnabled=FALSE; - glDisable(GL_ALPHA_TEST); + glDisable(GL_ALPHA_TEST); glError(); //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x), // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y))); @@ -1594,8 +1524,8 @@ void UploadScreenEx(long Position) // glPixelZoom(1.0F,1.0F); - glEnable(GL_ALPHA_TEST); - glEnable(GL_SCISSOR_TEST); + glEnable(GL_ALPHA_TEST); glError(); + glEnable(GL_SCISSOR_TEST); glError(); } //////////////////////////////////////////////////////////////////////// @@ -1745,7 +1675,7 @@ BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff) //Mask1 Set mask bit while drawing. 1 = on //Mask2 Do not draw to mask areas. 1= on -void cmdSTP(u8 * baseAddr) +void cmdSTP(unsigned char * baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; @@ -1763,13 +1693,13 @@ void cmdSTP(u8 * baseAddr) bCheckMask=TRUE; if(iDepthFunc==0) return; iDepthFunc=0; - glDepthFunc(GL_LESS); + glDepthFunc(GL_LESS); glError(); } else { bCheckMask=FALSE; if(iDepthFunc==1) return; - glDepthFunc(GL_ALWAYS); + glDepthFunc(GL_ALWAYS); glError(); iDepthFunc=1; } } @@ -1778,7 +1708,7 @@ void cmdSTP(u8 * baseAddr) // cmd: Set texture page infos //////////////////////////////////////////////////////////////////////// -void cmdTexturePage(u8 * baseAddr) +void cmdTexturePage(unsigned char * baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; UpdateGlobalTP((unsigned short)gdata); @@ -1789,7 +1719,7 @@ void cmdTexturePage(u8 * baseAddr) // cmd: turn on/off texture window //////////////////////////////////////////////////////////////////////// -void cmdTextureWindow(u8 *baseAddr) +void cmdTextureWindow(unsigned char *baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; @@ -1998,7 +1928,7 @@ void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1) // cmd: start of drawing area... primitives will be clipped inside //////////////////////////////////////////////////////////////////////// -void cmdDrawAreaStart(u8 * baseAddr) +void cmdDrawAreaStart(unsigned char * baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; @@ -2029,7 +1959,7 @@ void cmdDrawAreaStart(u8 * baseAddr) // cmd: end of drawing area... primitives will be clipped inside //////////////////////////////////////////////////////////////////////// -void cmdDrawAreaEnd(u8 * baseAddr) +void cmdDrawAreaEnd(unsigned char * baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; @@ -2064,7 +1994,7 @@ void cmdDrawAreaEnd(u8 * baseAddr) // cmd: draw offset... will be added to prim coords //////////////////////////////////////////////////////////////////////// -void cmdDrawOffset(u8 * baseAddr) +void cmdDrawOffset(unsigned char * baseAddr) { unsigned long gdata = ((unsigned long*)baseAddr)[0]; @@ -2095,7 +2025,7 @@ void cmdDrawOffset(u8 * baseAddr) // cmd: load image to vram //////////////////////////////////////////////////////////////////////// -void primLoadImage(u8 * baseAddr) +void primLoadImage(unsigned char * baseAddr) { unsigned short *sgpuData = ((unsigned short *) baseAddr); @@ -2252,7 +2182,7 @@ void CheckWriteUpdate() // cmd: vram -> psx mem //////////////////////////////////////////////////////////////////////// -void primStoreImage(u8 * baseAddr) +void primStoreImage(unsigned char * baseAddr) { unsigned short *sgpuData = ((unsigned short *) baseAddr); @@ -2274,7 +2204,7 @@ void primStoreImage(u8 * baseAddr) // cmd: blkfill - NO primitive! Doesn't care about draw areas... //////////////////////////////////////////////////////////////////////// -void primBlkFill(u8 * baseAddr) +void primBlkFill(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -2316,9 +2246,9 @@ void primBlkFill(u8 * baseAddr) b=((GLclampf)BLUE(gpuData[0]))/255.0f; r=((GLclampf)RED(gpuData[0]))/255.0f; - glDisable(GL_SCISSOR_TEST); - glClearColor(r,g,b,1.0f); - glClear(uiBufferBits); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(r,g,b,1.0f); glError(); + glClear(uiBufferBits); glError(); gl_z=0.0f; if(gpuData[0]!=0x02000000 && @@ -2349,7 +2279,7 @@ void primBlkFill(u8 * baseAddr) } } - glEnable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); glError(); } else { @@ -2359,9 +2289,9 @@ void primBlkFill(u8 * baseAddr) SetRenderMode((unsigned long)0x01000000, FALSE); vertex[0].c.lcol=gpuData[0]|0xff000000; SETCOL(vertex[0]); - glDisable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]); - glEnable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); glError(); } } @@ -2471,7 +2401,7 @@ void MoveImageWrapped(short imageX0,short imageY0, //////////////////////////////////////////////////////////////////////// -void primMoveImage(u8 * baseAddr) +void primMoveImage(unsigned char * baseAddr) { short *sgpuData = ((short *) baseAddr); short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j; @@ -2630,7 +2560,7 @@ void primMoveImage(u8 * baseAddr) // cmd: draw free-size Tile //////////////////////////////////////////////////////////////////////// -void primTileS(u8 * baseAddr) +void primTileS(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long*)baseAddr); short *sgpuData = ((short *) baseAddr); @@ -2695,7 +2625,7 @@ void primTileS(u8 * baseAddr) // cmd: draw 1 dot Tile (point) //////////////////////////////////////////////////////////////////////// -void primTile1(u8 * baseAddr) +void primTile1(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long*)baseAddr); short *sgpuData = ((short *) baseAddr); @@ -2742,7 +2672,7 @@ void primTile1(u8 * baseAddr) // cmd: draw 8 dot Tile (small rect) //////////////////////////////////////////////////////////////////////// -void primTile8(u8 * baseAddr) +void primTile8(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long*)baseAddr); short *sgpuData = ((short *) baseAddr); @@ -2789,7 +2719,7 @@ void primTile8(u8 * baseAddr) // cmd: draw 16 dot Tile (medium rect) //////////////////////////////////////////////////////////////////////// -void primTile16(u8 * baseAddr) +void primTile16(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long*)baseAddr); short *sgpuData = ((short *) baseAddr); @@ -2900,7 +2830,7 @@ void DrawMultiFilterSprite(void) // cmd: small sprite (textured rect) //////////////////////////////////////////////////////////////////////// -void primSprt8(u8 * baseAddr) +void primSprt8(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -3021,7 +2951,7 @@ void primSprt8(u8 * baseAddr) // cmd: medium sprite (textured rect) //////////////////////////////////////////////////////////////////////// -void primSprt16(u8 * baseAddr) +void primSprt16(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -3141,7 +3071,7 @@ void primSprt16(u8 * baseAddr) // cmd: free-size sprite (textured rect) //////////////////////////////////////////////////////////////////////// -void primSprtSRest(u8 * baseAddr,unsigned short type) +void primSprtSRest(unsigned char * baseAddr,unsigned short type) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -3312,7 +3242,7 @@ void primSprtSRest(u8 * baseAddr,unsigned short type) } } -void primSprtS(u8 * baseAddr) +void primSprtS(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -3451,7 +3381,7 @@ void primSprtS(u8 * baseAddr) // cmd: flat shaded Poly4 //////////////////////////////////////////////////////////////////////// -void primPolyF4(u8 *baseAddr) +void primPolyF4(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -3496,7 +3426,7 @@ void primPolyF4(u8 *baseAddr) // cmd: smooth shaded Poly4 //////////////////////////////////////////////////////////////////////// -void primPolyG4(u8 * baseAddr); +void primPolyG4(unsigned char * baseAddr); BOOL bDrawOffscreenFrontFF9G4(void) { @@ -3519,9 +3449,9 @@ BOOL bDrawOffscreenFrontFF9G4(void) return TRUE; } -BOOL bCheckFF9G4(u8 * baseAddr) +BOOL bCheckFF9G4(unsigned char * baseAddr) { - static u8 pFF9G4Cache[32]; + static unsigned char pFF9G4Cache[32]; static int iFF9Fix=0; if(baseAddr) @@ -3560,7 +3490,7 @@ BOOL bCheckFF9G4(u8 * baseAddr) //////////////////////////////////////////////////////////////////////// -void primPolyG4(u8 * baseAddr) +void primPolyG4(unsigned char * baseAddr) { unsigned long *gpuData = (unsigned long *)baseAddr; short *sgpuData = ((short *) baseAddr); @@ -3778,7 +3708,7 @@ BOOL DoLineCheck(unsigned long * gpuData) //////////////////////////////////////////////////////////////////////// -void primPolyFT3(u8 * baseAddr) +void primPolyFT3(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4214,7 +4144,7 @@ void RectTexAlign(void) } -void primPolyFT4(u8 * baseAddr) +void primPolyFT4(unsigned char * baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4302,7 +4232,7 @@ void primPolyFT4(u8 * baseAddr) // cmd: smooth shaded Texture3 //////////////////////////////////////////////////////////////////////// -void primPolyGT3(u8 *baseAddr) +void primPolyGT3(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4411,7 +4341,7 @@ void primPolyGT3(u8 *baseAddr) // cmd: smooth shaded Poly3 //////////////////////////////////////////////////////////////////////// -void primPolyG3(u8 *baseAddr) +void primPolyG3(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4456,7 +4386,7 @@ void primPolyG3(u8 *baseAddr) // cmd: smooth shaded Texture4 //////////////////////////////////////////////////////////////////////// -void primPolyGT4(u8 *baseAddr) +void primPolyGT4(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4576,7 +4506,7 @@ void primPolyGT4(u8 *baseAddr) // cmd: smooth shaded Poly3 //////////////////////////////////////////////////////////////////////// -void primPolyF3(u8 *baseAddr) +void primPolyF3(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4620,7 +4550,7 @@ void primPolyF3(u8 *baseAddr) // cmd: skipping shaded polylines //////////////////////////////////////////////////////////////////////// -void primLineGSkip(u8 *baseAddr) +void primLineGSkip(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4645,7 +4575,7 @@ void primLineGSkip(u8 *baseAddr) // cmd: shaded polylines //////////////////////////////////////////////////////////////////////// -void primLineGEx(u8 *baseAddr) +void primLineGEx(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); int iMax=255; @@ -4709,7 +4639,7 @@ void primLineGEx(u8 *baseAddr) // cmd: shaded polyline2 //////////////////////////////////////////////////////////////////////// -void primLineG2(u8 *baseAddr) +void primLineG2(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4754,7 +4684,7 @@ void primLineG2(u8 *baseAddr) // cmd: skipping flat polylines //////////////////////////////////////////////////////////////////////// -void primLineFSkip(u8 *baseAddr) +void primLineFSkip(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); int i=2,iMax=255; @@ -4774,7 +4704,7 @@ void primLineFSkip(u8 *baseAddr) // cmd: drawing flat polylines //////////////////////////////////////////////////////////////////////// -void primLineFEx(u8 *baseAddr) +void primLineFEx(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); int iMax; @@ -4832,7 +4762,7 @@ void primLineFEx(u8 *baseAddr) // cmd: drawing flat polyline2 //////////////////////////////////////////////////////////////////////// -void primLineF2(u8 *baseAddr) +void primLineF2(unsigned char *baseAddr) { unsigned long *gpuData = ((unsigned long *) baseAddr); short *sgpuData = ((short *) baseAddr); @@ -4873,7 +4803,7 @@ void primLineF2(u8 *baseAddr) // cmd: well, easiest command... not implemented //////////////////////////////////////////////////////////////////////// -void primNI(u8 *bA) +void primNI(unsigned char *bA) { } @@ -4881,7 +4811,7 @@ void primNI(u8 *bA) // cmd func ptr table //////////////////////////////////////////////////////////////////////// -void (*primTableJ[256])(u8 *) = +void (*primTableJ[256])(unsigned char *) = { // 00 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI, @@ -4953,7 +4883,7 @@ void (*primTableJ[256])(u8 *) = // cmd func ptr table for skipping //////////////////////////////////////////////////////////////////////// -void (*primTableSkip[256])(u8 *) = +void (*primTableSkip[256])(unsigned char *) = { // 00 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,