X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpu-gles%2FgpuTexture.c;h=2f96482ae8435e87073f7d48ee3cb3b6c7b772e2;hp=c5fa2bec6c47aae3c1909d8367c55c92f1d7d4d0;hb=HEAD;hpb=9f58cabba9806e2c365c64f7a3701efa6282aa72 diff --git a/plugins/gpu-gles/gpuTexture.c b/plugins/gpu-gles/gpuTexture.c index c5fa2bec..5136682b 100644 --- a/plugins/gpu-gles/gpuTexture.c +++ b/plugins/gpu-gles/gpuTexture.c @@ -88,12 +88,12 @@ GLuint gTexMovieName=0; GLuint gTexBlurName=0; GLuint gTexFrameName=0; int iTexGarbageCollection=1; -unsigned long dwTexPageComp=0; +unsigned int dwTexPageComp=0; int iVRamSize=0; int iClampType=GL_CLAMP_TO_EDGE; int iFilter = GL_LINEAR; void (*LoadSubTexFn) (int,int,short,short); -unsigned long (*PalTexturedColourFn) (unsigned long); +unsigned int (*PalTexturedColourFn) (unsigned int); //////////////////////////////////////////////////////////////////////// // defines @@ -127,7 +127,7 @@ unsigned long (*PalTexturedColourFn) (unsigned long); //////////////////////////////////////////////////////////////////////// -unsigned char * CheckTextureInSubSCache(long TextureMode,unsigned long GivenClutId,unsigned short * pCache); +unsigned char * CheckTextureInSubSCache(int TextureMode,unsigned int GivenClutId,unsigned short * pCache); void LoadSubTexturePageSort(int pageid, int mode, short cx, short cy); void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy); void DefineSubTextureSort(void); @@ -136,7 +136,7 @@ void DefineSubTextureSort(void); // some globals //////////////////////////////////////////////////////////////////////// -long GlobalTexturePage; +int GlobalTexturePage; GLint XTexS; GLint YTexS; GLint DXTexS; @@ -147,7 +147,7 @@ BOOL bUse15bitMdec=FALSE; int iFrameTexType=0; int iFrameReadType=0; -unsigned long (*TCF[2]) (unsigned long); +unsigned int (*TCF[2]) (unsigned int); unsigned short (*PTCF[2]) (unsigned short); //////////////////////////////////////////////////////////////////////// @@ -158,7 +158,7 @@ unsigned short (*PTCF[2]) (unsigned short); typedef struct textureWndCacheEntryTag { - unsigned long ClutID; + unsigned int ClutID; short pageid; short textureMode; short Opaque; @@ -171,7 +171,7 @@ typedef struct textureWndCacheEntryTag typedef struct textureSubCacheEntryTagS { - unsigned long ClutID; + unsigned int ClutID; EXLong pos; unsigned char posTX; unsigned char posTY; @@ -200,7 +200,7 @@ int iTexWndLimit=MAXWNDTEXCACHE/2; GLubyte * texturepart=NULL; GLubyte * texturebuffer=NULL; -unsigned long g_x1,g_y1,g_x2,g_y2; +unsigned int g_x1,g_y1,g_x2,g_y2; unsigned char ubOpaqueDraw=0; unsigned short MAXTPAGES = 32; @@ -213,7 +213,7 @@ unsigned short MAXSORTTEX = 196; // porting... and honestly: nowadays the speed gain would be pointless //////////////////////////////////////////////////////////////////////// -unsigned long XP8RGBA(unsigned long BGR) +unsigned int XP8RGBA(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(DrawSemiTrans && !(BGR&0x8000)) @@ -221,7 +221,7 @@ unsigned long XP8RGBA(unsigned long BGR) return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx(unsigned long BGR) +unsigned int XP8RGBAEx(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(DrawSemiTrans && !(BGR&0x8000)) @@ -229,9 +229,9 @@ unsigned long XP8RGBAEx(unsigned long BGR) return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long CP8RGBA(unsigned long BGR) +unsigned int CP8RGBA(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; if(DrawSemiTrans && !(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} @@ -240,9 +240,9 @@ unsigned long CP8RGBA(unsigned long BGR) return l; } -unsigned long CP8RGBAEx(unsigned long BGR) +unsigned int CP8RGBAEx(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; if(DrawSemiTrans && !(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} @@ -251,33 +251,33 @@ unsigned long CP8RGBAEx(unsigned long BGR) return l; } -unsigned long XP8RGBA_0(unsigned long BGR) +unsigned int XP8RGBA_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx_0(unsigned long BGR) +unsigned int XP8RGBAEx_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRA_0(unsigned long BGR) +unsigned int XP8BGRA_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRAEx_0(unsigned long BGR) +unsigned int XP8BGRAEx_0(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long CP8RGBA_0(unsigned long BGR) +unsigned int CP8RGBA_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; l=((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; @@ -285,9 +285,9 @@ unsigned long CP8RGBA_0(unsigned long BGR) return l; } -unsigned long CP8RGBAEx_0(unsigned long BGR) +unsigned int CP8RGBAEx_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; l=((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; @@ -295,9 +295,9 @@ unsigned long CP8RGBAEx_0(unsigned long BGR) return l; } -unsigned long CP8BGRA_0(unsigned long BGR) +unsigned int CP8BGRA_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x50000000; l=((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -305,9 +305,9 @@ unsigned long CP8BGRA_0(unsigned long BGR) return l; } -unsigned long CP8BGRAEx_0(unsigned long BGR) +unsigned int CP8BGRAEx_0(unsigned int BGR) { - unsigned long l; + unsigned int l; if(!(BGR&0xffff)) return 0x03000000; l=((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -315,41 +315,41 @@ unsigned long CP8BGRAEx_0(unsigned long BGR) return l; } -unsigned long XP8RGBA_1(unsigned long BGR) +unsigned int XP8RGBA_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8RGBAEx_1(unsigned long BGR) +unsigned int XP8RGBAEx_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff);} return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRA_1(unsigned long BGR) +unsigned int XP8BGRA_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x50000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff);} return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long XP8BGRAEx_1(unsigned long BGR) +unsigned int XP8BGRAEx_1(unsigned int BGR) { if(!(BGR&0xffff)) return 0x03000000; if(!(BGR&0x8000)) {ubOpaqueDraw=1;return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff);} return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; } -unsigned long P8RGBA(unsigned long BGR) +unsigned int P8RGBA(unsigned int BGR) { if(!(BGR&0xffff)) return 0; return ((((BGR<<3)&0xf8)|((BGR<<6)&0xf800)|((BGR<<9)&0xf80000))&0xffffff)|0xff000000; } -unsigned long P8BGRA(unsigned long BGR) +unsigned int P8BGRA(unsigned int BGR) { if(!(BGR&0xffff)) return 0; return ((((BGR>>7)&0xf8)|((BGR<<6)&0xf800)|((BGR<<19)&0xf80000))&0xffffff)|0xff000000; @@ -472,6 +472,9 @@ void CheckTextureMemory(void) return; } +#if 1 + iSortTexCnt=MAXSORTTEX; +#else // below vram detector supposedly crashes some drivers iTSize=256; p=(char *)malloc(iTSize*iTSize*4); @@ -508,6 +511,7 @@ void CheckTextureMemory(void) else iSortTexCnt=iCnt-3+min(1,0); // place for menu&texwnd if(iSortTexCnt<8) iSortTexCnt=8; +#endif } //////////////////////////////////////////////////////////////////////// @@ -608,6 +612,7 @@ void CleanupTextureStore() for(j=0;j clean mem + pscSubtexStore[i][j]=0; } for(i=0;i delete it } free(pxSsubtexLeft[i]); // -> clean mem + pxSsubtexLeft[i]=0; } //----------------------------------------------------// } @@ -674,7 +680,7 @@ void ResetTextureArea(BOOL bDelTex) // Invalidate tex windows //////////////////////////////////////////////////////////////////////// -void InvalidateWndTextureArea(long X,long Y,long W, long H) +void InvalidateWndTextureArea(int X,int Y,int W, int H) { int i,px1,px2,py1,py2,iYM=1; textureWndCacheEntry * tsw=wcWndtexStore; @@ -765,11 +771,11 @@ void MarkFree(textureSubCacheEntryS * tsx) } } -void InvalidateSubSTextureArea(long X,long Y,long W, long H) +void InvalidateSubSTextureArea(int X,int Y,int W, int H) { int i,j,k,iMax,px,py,px1,px2,py1,py2,iYM=1; EXLong npos;textureSubCacheEntryS * tsb; - long x1,x2,y1,y2,xa,sw; + int x1,x2,y1,y2,xa,sw; W+=X-1; H+=Y-1; @@ -869,7 +875,7 @@ void InvalidateTextureAreaEx(void) //////////////////////////////////////////////////////////////////////// -void InvalidateTextureArea(long X,long Y,long W, long H) +void InvalidateTextureArea(int X,int Y,int W, int H) { if(W==0 && H==0) return; @@ -914,12 +920,12 @@ void DefineTextureWnd(void) void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo; unsigned int palstart; unsigned short *px,*pa,*ta; unsigned char *cSRCPtr,*cOSRCPtr; unsigned short *wSRCPtr,*wOSRCPtr; - unsigned long LineOffset;unsigned short s; + unsigned int LineOffset;unsigned short s; int pmult=pageid/16; unsigned short (*LPTCOL)(unsigned short); @@ -1106,22 +1112,22 @@ void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo,s; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo,s; unsigned int palstart; - unsigned long *px,*pa,*ta; + unsigned int *px,*pa,*ta; unsigned char *cSRCPtr,*cOSRCPtr; unsigned short *wSRCPtr,*wOSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; - unsigned long (*LTCOL)(unsigned long); + unsigned int (*LTCOL)(unsigned int); LTCOL=TCF[DrawSemiTrans]; ldxo=TWin.Position.x1-TWin.OPosition.x1; ldy =TWin.Position.y1-TWin.OPosition.y1; - pa=px=(unsigned long *)ubPaletteBuffer; - ta=(unsigned long *)texturepart; + pa=px=(unsigned int *)ubPaletteBuffer; + ta=(unsigned int *)texturepart; palstart=cx+(cy*1024); ubOpaqueDraw=0; @@ -1317,12 +1323,12 @@ void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned int palstart; unsigned short *px,*pa,*ta; unsigned char *cSRCPtr; unsigned short *wSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; unsigned short (*LPTCOL)(unsigned short); @@ -1459,19 +1465,19 @@ void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) void LoadWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned int palstart; - unsigned long *px,*pa,*ta; + unsigned int *px,*pa,*ta; unsigned char *cSRCPtr; unsigned short *wSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; - unsigned long (*LTCOL)(unsigned long); + unsigned int (*LTCOL)(unsigned int); LTCOL=TCF[DrawSemiTrans]; - pa=px=(unsigned long *)ubPaletteBuffer; - ta=(unsigned long *)texturepart; + pa=px=(unsigned int *)ubPaletteBuffer; + ta=(unsigned int *)texturepart; palstart=cx+(cy*1024); ubOpaqueDraw=0; @@ -1621,7 +1627,7 @@ void UploadTexWndPal(int mode,short cx,short cy) { unsigned int i,iSize; unsigned short * wSrcPtr; - unsigned long * ta=(unsigned long *)texturepart; + unsigned int * ta=(unsigned int *)texturepart; wSrcPtr=psxVuw+cx+(cy*1024); if(mode==0) i=4; else i=64; @@ -1671,10 +1677,10 @@ void DefinePalTextureWnd(void) void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm; + unsigned int start,row,column,j,sxh,sxm; unsigned char *ta; unsigned char *cSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; ta=(unsigned char *)texturepart; @@ -1731,10 +1737,10 @@ void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) { - unsigned long start,row,column,j,sxh,sxm,ldx,ldy,ldxo; + unsigned int start,row,column,j,sxh,sxm,ldx,ldy,ldxo; unsigned char *ta,s; unsigned char *cSRCPtr,*cOSRCPtr; - unsigned long LineOffset; + unsigned int LineOffset; int pmult=pageid/16; ldxo=TWin.Position.x1-TWin.OPosition.x1; @@ -1809,7 +1815,7 @@ void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) // tex window: main selecting, cache handler included //////////////////////////////////////////////////////////////////////// -GLuint LoadTextureWnd(long pageid,long TextureMode,unsigned long GivenClutId) +GLuint LoadTextureWnd(int pageid,int TextureMode,unsigned int GivenClutId) { textureWndCacheEntry * ts, * tsx=NULL; int i;short cx,cy; @@ -1831,8 +1837,8 @@ GLuint LoadTextureWnd(long pageid,long TextureMode,unsigned long GivenClutId) // palette check sum { - unsigned long l=0,row; - unsigned long * lSRCPtr=(unsigned long *)(psxVuw+cx+(cy*1024)); + unsigned int l=0,row; + unsigned int * lSRCPtr=(unsigned int *)(psxVuw+cx+(cy*1024)); if(TextureMode==1) for(row=1;row<129;row++) l+=((*lSRCPtr++)-1)*row; else for(row=1;row<9;row++) l+=((*lSRCPtr++)-1)<ClutID&(1<<30)) DrawSemiTrans=1; else DrawSemiTrans=0; - *((unsigned long *)&gl_ux[4])=r.l; + *((unsigned int *)&gl_ux[4])=r.l; gTexName=uiStexturePage[tsx->cTexID]; LoadSubTexFn(k,j,cx,cy); @@ -4111,7 +4117,7 @@ void CompressTextureSpace(void) if(dwTexPageComp==0xffffffff) dwTexPageComp=0; - *((unsigned long *)&gl_ux[4])=opos.l; + *((unsigned int *)&gl_ux[4])=opos.l; GlobalTexturePage=lOGTP; DrawSemiTrans=sOldDST; } @@ -4126,7 +4132,7 @@ void CompressTextureSpace(void) ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -GLuint SelectSubTextureS(long TextureMode, unsigned long GivenClutId) +GLuint SelectSubTextureS(int TextureMode, unsigned int GivenClutId) { unsigned char * OPtr;unsigned short iCache;short cx,cy; @@ -4168,9 +4174,9 @@ GLuint SelectSubTextureS(long TextureMode, unsigned long GivenClutId) // palette check sum.. removed MMX asm, this easy func works as well { - unsigned long l=0,row; + unsigned int l=0,row; - unsigned long * lSRCPtr=(unsigned long *)(psxVuw+cx+(cy*1024)); + unsigned int * lSRCPtr=(unsigned int *)(psxVuw+cx+(cy*1024)); if(TextureMode==1) for(row=1;row<129;row++) l+=((*lSRCPtr++)-1)*row; else for(row=1;row<9;row++) l+=((*lSRCPtr++)-1)<