From 9f58cabba9806e2c365c64f7a3701efa6282aa72 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 17 Jan 2012 00:38:32 +0200 Subject: [PATCH] gpu-gles: schtruck/fpse merge: gl error checks useful debugging tool, yeah --- plugins/gpu-gles/gpuDraw.c | 72 ++++++++------- plugins/gpu-gles/gpuPlugin.c | 95 +++++++++---------- plugins/gpu-gles/gpuPrim.c | 51 ++++++----- plugins/gpu-gles/gpuStdafx.h | 12 +++ plugins/gpu-gles/gpuTexture.c | 167 +++++++++++++++++++--------------- 5 files changed, 217 insertions(+), 180 deletions(-) diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index 3842503f..69d2d7be 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -175,8 +175,7 @@ void SetExtGLFuncs(void) if(bAdvancedBlend) bUseMultiPass=TRUE; // -> pseudo-advanced with 2 passes else bUseMultiPass=FALSE; // -> or simple 'bright color' mode // bGLBlend=FALSE; // -> no ext blending! - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glError(); } if(bOpaquePass) // opaque mode? @@ -193,13 +192,15 @@ void SetExtGLFuncs(void) } TCF[1]=XP8RGBA_1; - glAlphaFuncx(GL_GREATER,0.49f); + glAlphaFuncx(GL_GREATER,0.49f); glError(); + } else // no opaque mode? { TCF[0]=TCF[1]=P8RGBA; PalTexturedColourFn=P8RGBA; // -> init col func - glAlphaFuncx(GL_NOTEQUAL,0); // --> set alpha func + glAlphaFuncx(GL_NOTEQUAL,0); glError(); // --> set alpha func + } //----------------------------------------------------// @@ -207,7 +208,8 @@ void SetExtGLFuncs(void) LoadSubTexFn=LoadSubTexturePageSort; // init load tex ptr bBlendEnable=FALSE; // init blending: off - glDisable(GL_BLEND); + glDisable(GL_BLEND); glError(); + SetScanTrans(); // init scan lines (if wanted) } @@ -430,10 +432,10 @@ int GLinitialize() glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, - rRatioRect.bottom); + rRatioRect.bottom); glError(); - glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) - glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, iResX, iResY); glError(); // init clipping (fullscreen) + glEnable(GL_SCISSOR_TEST); glError(); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" @@ -441,35 +443,35 @@ int GLinitialize() glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif - glMatrixMode(GL_PROJECTION); // init projection with psx resolution - glLoadIdentity(); + glMatrixMode(GL_PROJECTION); glError(); // init projection with psx resolution + glLoadIdentity(); glError(); glOrtho(0,PSXDisplay.DisplayMode.x, - PSXDisplay.DisplayMode.y, 0, -1, 1); + PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); if(iZBufferDepth) // zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT; - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); + glEnable(GL_DEPTH_TEST); glError(); + glDepthFunc(GL_ALWAYS); glError(); iDepthFunc=1; } else // no zbuffer? { uiBufferBits=GL_COLOR_BUFFER_BIT; - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); glError(); } - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // first buffer clear - glClear(uiBufferBits); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glError(); // first buffer clear + glClear(uiBufferBits); glError(); GetExtInfos(); // get ext infos SetExtGLFuncs(); // init all kind of stuff (tex function pointers) - glEnable(GL_ALPHA_TEST); // wanna alpha test + glEnable(GL_ALPHA_TEST); glError(); // wanna alpha test { - glDisable(GL_LINE_SMOOTH); - glDisable(GL_POINT_SMOOTH); + glDisable(GL_LINE_SMOOTH); glError(); + glDisable(GL_POINT_SMOOTH); glError(); } ubGloAlpha=127; // init some drawing vars @@ -482,15 +484,15 @@ int GLinitialize() if(bDrawDither) glEnable(GL_DITHER); // dither mode else glDisable(GL_DITHER); - - glDisable(GL_FOG); // turn all (currently) unused modes off - glDisable(GL_LIGHTING); - glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_2D); + glError(); + glDisable(GL_FOG); glError(); // turn all (currently) unused modes off + glDisable(GL_LIGHTING); glError(); + glDisable(GL_STENCIL_TEST); glError(); + glDisable(GL_TEXTURE_2D); glError(); glDisable(GL_CULL_FACE); - glFlush(); // we are done... - glFinish(); + glFlush(); glError(); // we are done... + glFinish(); glError(); CreateScanLines(); // setup scanline stuff (if wanted) @@ -1055,8 +1057,8 @@ void assignTextureSprite(void) { if(gLastTex!=gTexName || gLastFMode!=0) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=0; } } @@ -1115,8 +1117,8 @@ void assignTexture3(void) { if(gLastTex!=gTexName || gLastFMode!=1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=1; } } @@ -1185,8 +1187,8 @@ void assignTexture4(void) { if(gLastTex!=gTexName || gLastFMode!=1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); gLastTex=gTexName;gLastFMode=1; } } @@ -1257,7 +1259,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet) if(bSetClip || !EqualRect(&rC,&rX)) { rC=rX; - glScissor(rC.left,rC.top,rC.right,rC.bottom); + glScissor(rC.left,rC.top,rC.right,rC.bottom); glError(); + //LOGE("glscissor:%d %d %d %d",rC.left,rC.top,rC.right,rC.bottom); bSetClip=FALSE; } return; @@ -1348,7 +1351,8 @@ void SetOGLDisplaySettings(BOOL DisplaySet) if(bSetClip || !EqualRect(&r,&rC)) { - glScissor(r.left,r.top,r.right,r.bottom); + glScissor(r.left,r.top,r.right,r.bottom); glError(); + rC=r; bSetClip=FALSE; } diff --git a/plugins/gpu-gles/gpuPlugin.c b/plugins/gpu-gles/gpuPlugin.c index fcc8f8bb..45a0b92e 100644 --- a/plugins/gpu-gles/gpuPlugin.c +++ b/plugins/gpu-gles/gpuPlugin.c @@ -149,10 +149,10 @@ void ResizeWindow() glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, - rRatioRect.bottom); + rRatioRect.bottom); glError(); - glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) - glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, iResX, iResY); glError(); // init clipping (fullscreen) + glEnable(GL_SCISSOR_TEST); glError(); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" @@ -160,10 +160,10 @@ void ResizeWindow() glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif - glMatrixMode(GL_PROJECTION); // init projection with psx resolution - glLoadIdentity(); + glMatrixMode(GL_PROJECTION); glError(); // init projection with psx resolution + glLoadIdentity(); glError(); glOrtho(0,PSXDisplay.DisplayMode.x, - PSXDisplay.DisplayMode.y, 0, -1, 1); + PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); if (bKeepRatio) SetAspectRatio(); } @@ -550,15 +550,15 @@ long CALLBACK GPUshutdown() void PaintBlackBorders(void) { short s; + glDisable(GL_SCISSOR_TEST); glError(); + if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} glError(); + if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} glError(); + if(bBlendEnable) {glDisable(GL_BLEND);bBlendEnable=FALSE;} glError(); + glDisable(GL_ALPHA_TEST); glError(); - glDisable(GL_SCISSOR_TEST); - if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} - if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} - if(bBlendEnable) {glDisable(GL_BLEND);bBlendEnable=FALSE;} - glDisable(GL_ALPHA_TEST); + glEnable(GL_ALPHA_TEST); glError(); + glEnable(GL_SCISSOR_TEST); glError(); - glEnable(GL_ALPHA_TEST); - glEnable(GL_SCISSOR_TEST); } //////////////////////////////////////////////////////////////////////// @@ -640,11 +640,13 @@ if(PreviousPSXDisplay.Range.x0|| // paint black borders aro if(PSXDisplay.Disabled) // display disabled? { + //LOGE("PSXDisplay.Disabled"); + // moved here - glDisable(GL_SCISSOR_TEST); - glClearColor(0,0,0,128); // -> clear whole backbuffer - glClear(uiBufferBits); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(0,0,0,128); glError(); // -> clear whole backbuffer + glClear(uiBufferBits); glError(); + glEnable(GL_SCISSOR_TEST); glError(); gl_z=0.0f; bDisplayNotSet = TRUE; } @@ -712,11 +714,10 @@ if(lClearOnSwap) // clear buffer after swap g=((GLclampf)GREEN(lClearOnSwapColor))/255.0f; // -> get col b=((GLclampf)BLUE(lClearOnSwapColor))/255.0f; r=((GLclampf)RED(lClearOnSwapColor))/255.0f; - - glDisable(GL_SCISSOR_TEST); - glClearColor(r,g,b,128); // -> clear - glClear(uiBufferBits); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(r,g,b,128); glError(); // -> clear + glClear(uiBufferBits); glError(); + glEnable(GL_SCISSOR_TEST); glError(); lClearOnSwap=0; // -> done } else @@ -725,11 +726,12 @@ else if(iZBufferDepth) // clear zbuffer as well (if activated) { - glDisable(GL_SCISSOR_TEST); - glClear(GL_DEPTH_BUFFER_BIT); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClear(GL_DEPTH_BUFFER_BIT); glError(); + glEnable(GL_SCISSOR_TEST); glError(); } } + gl_z=0.0f; //----------------------------------------------------// @@ -776,7 +778,7 @@ if(iRumbleTime) // shake screen by modifyi glViewport(rRatioRect.left+i1, iResY-(rRatioRect.top+rRatioRect.bottom)+i2, rRatioRect.right+i3, - rRatioRect.bottom+i4); + rRatioRect.bottom+i4); glError(); } //----------------------------------------------------// @@ -915,12 +917,11 @@ if(r.bottom < 1) r.bottom = 1; r.left = (iResX-r.right)/2; r.top = (iResY-r.bottom)/2; - if(r.bottom new psx resolution - PSXDisplay.DisplayModeNew.y, 0, -1, 1); + PSXDisplay.DisplayModeNew.y, 0, -1, 1); glError(); if(bKeepRatio) SetAspectRatio(); } @@ -1581,7 +1584,7 @@ void CheckVRamReadEx(int x, int y, int dx, int dy) if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } @@ -1589,8 +1592,7 @@ void CheckVRamReadEx(int x, int y, int dx, int dy) //if(!sArea) glReadBuffer(GL_FRONT); - glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); - + glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); //if(!sArea) glReadBuffer(GL_BACK); s=0; @@ -1729,7 +1731,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront) if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } @@ -1737,8 +1739,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront) // if(bFront) glReadBuffer(GL_FRONT); - glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); - + glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); glError(); // if(bFront) glReadBuffer(GL_BACK); XS=(float)dx/(float)(udx); @@ -2532,7 +2533,7 @@ long CALLBACK GPUgetScreenPic(unsigned char * pMem) if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } @@ -2540,7 +2541,7 @@ long CALLBACK GPUgetScreenPic(unsigned char * pMem) // glReadBuffer(GL_FRONT); - glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps); + glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); // glReadBuffer(GL_BACK); diff --git a/plugins/gpu-gles/gpuPrim.c b/plugins/gpu-gles/gpuPrim.c index 37db0521..5d17f2de 100644 --- a/plugins/gpu-gles/gpuPrim.c +++ b/plugins/gpu-gles/gpuPrim.c @@ -661,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 } @@ -669,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) @@ -678,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) @@ -709,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 @@ -722,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 } //////////////////////////////////////////////////////////////////////// @@ -802,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; } } @@ -947,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 ? { @@ -980,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; } } @@ -1452,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))); @@ -1523,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(); } //////////////////////////////////////////////////////////////////////// @@ -1692,13 +1693,13 @@ void cmdSTP(unsigned char * 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; } } @@ -2245,9 +2246,9 @@ void primBlkFill(unsigned char * 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 && @@ -2278,7 +2279,7 @@ void primBlkFill(unsigned char * baseAddr) } } - glEnable(GL_SCISSOR_TEST); + glEnable(GL_SCISSOR_TEST); glError(); } else { @@ -2288,9 +2289,9 @@ void primBlkFill(unsigned char * 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(); } } diff --git a/plugins/gpu-gles/gpuStdafx.h b/plugins/gpu-gles/gpuStdafx.h index 3a6a1c52..69050b30 100644 --- a/plugins/gpu-gles/gpuStdafx.h +++ b/plugins/gpu-gles/gpuStdafx.h @@ -88,6 +88,18 @@ extern "C" { #endif #endif +#if 0 +#define glError() { \ + GLenum err = glGetError(); \ + while (err != GL_NO_ERROR) { \ + printf("glError: %d caught at %s:%u\n", err, __FILE__, __LINE__); \ + err = glGetError(); \ + } \ +} +#else +#define glError() +#endif + #ifdef __cplusplus } #endif diff --git a/plugins/gpu-gles/gpuTexture.c b/plugins/gpu-gles/gpuTexture.c index c3d88f90..c5fa2bec 100644 --- a/plugins/gpu-gles/gpuTexture.c +++ b/plugins/gpu-gles/gpuTexture.c @@ -570,6 +570,7 @@ void CleanupTextureStore() int i,j;textureWndCacheEntry * tsx; //----------------------------------------------------// glBindTexture(GL_TEXTURE_2D,0); + glError(); //----------------------------------------------------// free(texturepart); // free tex part texturepart=0; @@ -584,19 +585,23 @@ void CleanupTextureStore() { if(tsx->texname) // -> some tex? glDeleteTextures(1,&tsx->texname); // --> delete it + glError(); } iMaxTexWnds=0; // no more tex wnds //----------------------------------------------------// if(gTexMovieName!=0) // some movie tex? glDeleteTextures(1, &gTexMovieName); // -> delete it + glError(); gTexMovieName=0; // no more movie tex //----------------------------------------------------// if(gTexFrameName!=0) // some 15bit framebuffer tex? glDeleteTextures(1, &gTexFrameName); // -> delete it + glError(); gTexFrameName=0; // no more movie tex //----------------------------------------------------// if(gTexBlurName!=0) // some 15bit framebuffer tex? glDeleteTextures(1, &gTexBlurName); // -> delete it + glError(); gTexBlurName=0; // no more movie tex //----------------------------------------------------// for(i=0;i<3;i++) // -> loop @@ -609,6 +614,7 @@ void CleanupTextureStore() if(uiStexturePage[i]) // --> tex used ? { glDeleteTextures(1,&uiStexturePage[i]); + glError(); uiStexturePage[i]=0; // --> delete it } free(pxSsubtexLeft[i]); // -> clean mem @@ -629,7 +635,7 @@ void ResetTextureArea(BOOL bDelTex) dwTexPageComp=0; //----------------------------------------------------// - if(bDelTex) {glBindTexture(GL_TEXTURE_2D,0);gTexName=0;} + if(bDelTex) {glBindTexture(GL_TEXTURE_2D,0); glError();gTexName=0;} //----------------------------------------------------// tsx=wcWndtexStore; for(i=0;iused=0; if(bDelTex && tsx->texname) { - glDeleteTextures(1,&tsx->texname); + glDeleteTextures(1,&tsx->texname); glError(); tsx->texname=0; } } @@ -659,7 +665,7 @@ void ResetTextureArea(BOOL bDelTex) lu=pxSsubtexLeft[i]; lu->l=0; if(bDelTex && uiStexturePage[i]) - {glDeleteTextures(1,&uiStexturePage[i]);uiStexturePage[i]=0;} + {glDeleteTextures(1,&uiStexturePage[i]); glError();uiStexturePage[i]=0;} } } @@ -881,21 +887,25 @@ void DefineTextureWnd(void) { if(gTexName==0) glGenTextures(1, &gTexName); - + glError(); glBindTexture(GL_TEXTURE_2D, gTexName); - + glError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - + glError(); { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glError(); } glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TWin.Position.x1, TWin.Position.y1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + glError(); + //LOGE("DefineTextureWnd x:%d y:%d",TWin.Position.x1,TWin.Position.y1); + } //////////////////////////////////////////////////////////////////////// @@ -1638,21 +1648,23 @@ void DefinePalTextureWnd(void) { if(gTexName==0) glGenTextures(1, &gTexName); - + glError(); glBindTexture(GL_TEXTURE_2D, gTexName); - + glError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - + glError(); { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); } - + glError(); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TWin.Position.x1, TWin.Position.y1, 0, GL_RGBA, GL_UNSIGNED_BYTE,texturepart); + glError(); + //LOGE("DefinePalTextureWnd x:%d y:%d",TWin.Position.x1,TWin.Position.y1); } /////////////////////////////////////////////////////// @@ -1899,31 +1911,32 @@ void DefinePackedTextureMovie(void) { if(gTexMovieName==0) { - glGenTextures(1, &gTexMovieName); + glEnable(GL_TEXTURE_2D); + glGenTextures(1, &gTexMovieName); glError(); gTexName=gTexMovieName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); if(!bUseFastMdec) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); } glTexImage2D(GL_TEXTURE_2D, 0, //giWantedRGBA, GL_RGBA, - 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); } else { - gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); + gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); glError(); } glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, @@ -1931,7 +1944,9 @@ void DefinePackedTextureMovie(void) (xrMovieArea.y1-xrMovieArea.y0), GL_RGBA, GL_UNSIGNED_SHORT, - texturepart); + texturepart); glError(); + //LOGE("DefinePackedTextureMovie x:%d y:%d",(xrMovieArea.x1-xrMovieArea.x0),(xrMovieArea.y1-xrMovieArea.y0)); + } //////////////////////////////////////////////////////////////////////// @@ -1940,35 +1955,36 @@ void DefineTextureMovie(void) { if(gTexMovieName==0) { - glGenTextures(1, &gTexMovieName); + glGenTextures(1, &gTexMovieName); glError(); gTexName=gTexMovieName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); if(!bUseFastMdec) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); } else { - gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); + gTexName=gTexMovieName;glBindTexture(GL_TEXTURE_2D, gTexName); glError(); } glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (xrMovieArea.x1-xrMovieArea.x0), (xrMovieArea.y1-xrMovieArea.y0), - GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); + //LOGE("DefineTextureMovie x:%d y:%d",(xrMovieArea.x1-xrMovieArea.x0),(xrMovieArea.y1-xrMovieArea.y0)); } //////////////////////////////////////////////////////////////////////// @@ -2222,14 +2238,14 @@ GLuint BlackFake15BitTexture(void) { if(!gTexFrameName) { - glGenTextures(1, &gTexFrameName); + glGenTextures(1, &gTexFrameName); glError(); gTexName=gTexFrameName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); { unsigned long * ta=(unsigned long *)texturepart; @@ -2237,14 +2253,15 @@ GLuint BlackFake15BitTexture(void) for(x1=0;x1<=4;x1++) *ta++=0xff000000; } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); + } else { gTexName=gTexFrameName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); } - + //LOGE("BlackFake15BitTexture x:%d y:%d",4,4); ubOpaqueDraw=0; return (GLuint)gTexName; @@ -2315,18 +2332,18 @@ GLuint Fake15BitTexture(void) if(iResX>640 || iResY>480) iFTex=1024; else iFTex=512; - glGenTextures(1, &gTexFrameName); + glGenTextures(1, &gTexFrameName); glError(); gTexName=gTexFrameName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); p=(char *)malloc(iFTex*iFTex*4); memset(p,0,iFTex*iFTex*4); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iFTex, iFTex, 0, GL_RGBA, GL_UNSIGNED_BYTE, p); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iFTex, iFTex, 0, GL_RGBA, GL_UNSIGNED_BYTE, p); glError(); free(p); glGetError(); @@ -2334,9 +2351,9 @@ GLuint Fake15BitTexture(void) else { gTexName=gTexFrameName; - glBindTexture(GL_TEXTURE_2D, gTexName); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); } - + //LOGE("Fake15BitTexture x:%d y:%d",iFTex,iFTex); x1+=PreviousPSXDisplay.Range.x0; y1+=PreviousPSXDisplay.Range.y0; @@ -2408,14 +2425,14 @@ GLuint Fake15BitTexture(void) iYAdjust, rSrc.left+rRatioRect.left, iResY-rSrc.bottom-rRatioRect.top, - x1,y1); + x1,y1); glError(); if(glGetError()) { char * p=(char *)malloc(iFTex*iFTex*4); memset(p,0,iFTex*iFTex*4); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, iFTex, iFTex, - GL_RGBA, GL_UNSIGNED_BYTE, p); + GL_RGBA, GL_UNSIGNED_BYTE, p); glError(); free(p); } @@ -3414,29 +3431,30 @@ void DefineSubTextureSortHiRes(void) if(!gTexName) { - glGenTextures(1, &gTexName); - glBindTexture(GL_TEXTURE_2D, gTexName); + glGenTextures(1, &gTexName); glError(); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); if(iFilterType) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); glError(); } - else glBindTexture(GL_TEXTURE_2D, gTexName); + else glBindTexture(GL_TEXTURE_2D, gTexName); glError(); glTexSubImage2D(GL_TEXTURE_2D, 0, XTexS<<1, YTexS<<1, DXTexS<<1, DYTexS<<1, - GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); + GL_RGBA, GL_UNSIGNED_BYTE, texturebuffer); glError(); + //LOGE("DefineSubTextureSortHiRes x:%d y:%d",XTexS<<1,YTexS<<1); } ///////////////////////////////////////////////////////////////////////////// @@ -3446,29 +3464,30 @@ void DefineSubTextureSort(void) if(!gTexName) { - glGenTextures(1, &gTexName); - glBindTexture(GL_TEXTURE_2D, gTexName); + glGenTextures(1, &gTexName); glError(); + glBindTexture(GL_TEXTURE_2D, gTexName); glError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, iClampType); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, iClampType); glError(); if(iFilterType) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glError(); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iFilter); glError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, iFilter); glError(); } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0,GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0,GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); } - else glBindTexture(GL_TEXTURE_2D, gTexName); + else glBindTexture(GL_TEXTURE_2D, gTexName); glError(); glTexSubImage2D(GL_TEXTURE_2D, 0, XTexS, YTexS, DXTexS, DYTexS, - GL_RGBA, GL_UNSIGNED_BYTE, texturepart); + GL_RGBA, GL_UNSIGNED_BYTE, texturepart); glError(); + //LOGE("DefineSubTextureSort x:%d y:%d w:%d h:%d",XTexS,YTexS,DXTexS,DYTexS); } ///////////////////////////////////////////////////////////////////////////// -- 2.39.5