try to emulate GPU busy
[pcsx_rearmed.git] / plugins / gpu-gles / gpuExternals.h
CommitLineData
ce879073 1/***************************************************************************\r
2 external.h - description\r
3 -------------------\r
4 begin : Sun Mar 08 2009\r
5 copyright : (C) 1999-2009 by Pete Bernert\r
6 web : www.pbernert.com \r
7 ***************************************************************************/\r
8\r
9/***************************************************************************\r
10 * *\r
11 * This program is free software; you can redistribute it and/or modify *\r
12 * it under the terms of the GNU General Public License as published by *\r
13 * the Free Software Foundation; either version 2 of the License, or *\r
14 * (at your option) any later version. See also the license.txt file for *\r
15 * additional informations. *\r
16 * *\r
17 ***************************************************************************/\r
18\r
19//*************************************************************************// \r
20// History of changes:\r
21//\r
22// 2009/03/08 - Pete \r
23// - generic cleanup for the Peops release\r
24//\r
25//*************************************************************************// \r
26\r
27/////////////////////////////////////////////////////////////////////////////\r
28\r
29#ifndef __GPU_EX__\r
30#define __GPU_EX__\r
31\r
32#ifdef __cplusplus\r
33extern "C" {\r
34#endif\r
7eadbf88 35\r
36typedef unsigned char u8;\r
37typedef signed char s8;\r
38typedef unsigned short int u16;\r
39typedef signed short int s16;\r
40typedef unsigned long u32;\r
41typedef signed long s32;\r
42typedef unsigned long long int u64;\r
43typedef signed long long int s64;\r
44\r
ce879073 45#ifndef _WINDOWS\r
46#ifdef __NANOGL__\r
47#include <gl/gl.h>\r
48#include <gl/egl.h>\r
49#else\r
50#ifdef SOFT_LINKAGE\r
51#pragma softfp_linkage\r
52#endif\r
7eadbf88 53#include <GLES/gl.h> // for opengl es types\r
ce879073 54#ifdef SOFT_LINKAGE\r
55#pragma no_softfp_linkage\r
56#endif\r
57#endif\r
58#endif\r
59\r
ce879073 60#ifdef __NANOGL__\r
61#define glTexParameteri(x,y,z) glTexParameterf(x,y,z) \r
62#define glAlphaFuncx(x,y) glAlphaFunc(x,y) \r
63#ifndef APIENTRY\r
64#define APIENTRY\r
65#endif\r
66extern void ( APIENTRY * glPixelStorei )(GLenum pname, GLint param);\r
67#endif\r
68\r
69\r
70#define MIRROR_TEST 1\r
71\r
72/////////////////////////////////////////////////////////////////////////////\r
73\r
74#define SCISSOR_TEST 1\r
75 \r
76/////////////////////////////////////////////////////////////////////////////\r
77\r
78// for own sow/tow scaling\r
79#define OWNSCALE 1\r
80\r
81/////////////////////////////////////////////////////////////////////////////\r
82\r
83#define CLUTUSED 0x80000000\r
84//glColor4ubv(x.c.col)\r
85#define SETCOL(x) if(x.c.lcol!=ulOLDCOL) {ulOLDCOL=x.c.lcol;glColor4ub(x.c.col[0],x.c.col[1],x.c.col[2],x.c.col[3]);} \r
86//#define SETPCOL(x) if(x->c.lcol!=ulOLDCOL) {ulOLDCOL=x->c.lcol;glColor4ub(x->c.col[0],x->c.col[1],x->c.col[2],x->c.col[3]);}\r
87\r
88#define INFO_TW 0\r
89#define INFO_DRAWSTART 1\r
90#define INFO_DRAWEND 2\r
91#define INFO_DRAWOFF 3\r
92\r
93#define SIGNSHIFT 21\r
94#define CHKMAX_X 1024\r
95#define CHKMAX_Y 512\r
96\r
97/////////////////////////////////////////////////////////////////////////////\r
98\r
99// GPU STATUS REGISTER bit values (c) Lewpy\r
100\r
101#define DR_NORMAL 0\r
102#define DR_VRAMTRANSFER 1\r
103\r
104#define GPUSTATUS_ODDLINES 0x80000000\r
105#define GPUSTATUS_DMABITS 0x60000000 // Two bits\r
106#define GPUSTATUS_READYFORCOMMANDS 0x10000000\r
107#define GPUSTATUS_READYFORVRAM 0x08000000\r
108#define GPUSTATUS_IDLE 0x04000000\r
109#define GPUSTATUS_DISPLAYDISABLED 0x00800000\r
110#define GPUSTATUS_INTERLACED 0x00400000\r
111#define GPUSTATUS_RGB24 0x00200000\r
112#define GPUSTATUS_PAL 0x00100000\r
113#define GPUSTATUS_DOUBLEHEIGHT 0x00080000\r
114#define GPUSTATUS_WIDTHBITS 0x00070000 // Three bits\r
115#define GPUSTATUS_MASKENABLED 0x00001000\r
116#define GPUSTATUS_MASKDRAWN 0x00000800\r
117#define GPUSTATUS_DRAWINGALLOWED 0x00000400\r
118#define GPUSTATUS_DITHER 0x00000200\r
119\r
120#define STATUSREG lGPUstatusRet\r
121\r
122#define GPUIsBusy (STATUSREG &= ~GPUSTATUS_IDLE)\r
123#define GPUIsIdle (STATUSREG |= GPUSTATUS_IDLE)\r
124\r
125#define GPUIsNotReadyForCommands (STATUSREG &= ~GPUSTATUS_READYFORCOMMANDS)\r
126#define GPUIsReadyForCommands (STATUSREG |= GPUSTATUS_READYFORCOMMANDS)\r
127\r
128/////////////////////////////////////////////////////////////////////////////\r
129\r
130#define KEY_RESETTEXSTORE 1\r
131#define KEY_SHOWFPS 2\r
132#define KEY_RESETOPAQUE 4\r
133#define KEY_RESETDITHER 8\r
134#define KEY_RESETFILTER 16\r
135#define KEY_RESETADVBLEND 32\r
136#define KEY_BLACKWHITE 64\r
137#define KEY_TOGGLEFBTEXTURE 128\r
138#define KEY_STEPDOWN 256\r
139#define KEY_TOGGLEFBREAD 512\r
140\r
141/////////////////////////////////////////////////////////////////////////////\r
142// Linux is missing some stuff, eh? ;)\r
143\r
144#ifndef _WINDOWS\r
145#ifndef FALSE\r
146#define FALSE 0\r
147#endif\r
148#ifndef TRUE\r
149#define TRUE 1\r
150#endif\r
151#ifndef BOOL\r
152#define BOOL unsigned short\r
153#endif\r
154#ifndef bool\r
155#define bool unsigned short\r
156#endif\r
157#define LOWORD(l) ((unsigned short)(l))\r
158#define HIWORD(l) ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))\r
159#define max(a,b) (((a) > (b)) ? (a) : (b))\r
160#define min(a,b) (((a) < (b)) ? (a) : (b))\r
161#define DWORD unsigned long\r
162\r
163typedef struct RECTTAG\r
164{\r
165 int left;\r
166 int top;\r
167 int right;\r
168 int bottom;\r
169}RECT;\r
170\r
171#endif\r
172\r
173/////////////////////////////////////////////////////////////////////////////\r
174\r
175typedef struct VRAMLOADTAG\r
176{\r
177 short x;\r
178 short y;\r
179 short Width;\r
180 short Height;\r
181 short RowsRemaining;\r
182 short ColsRemaining;\r
183 unsigned short *ImagePtr;\r
184} VRAMLoad_t;\r
185\r
186typedef struct PSXPOINTTAG\r
187{\r
188 long x;\r
189 long y;\r
190} PSXPoint_t;\r
191\r
192typedef struct PSXSPOINTTAG\r
193{\r
194 short x;\r
195 short y;\r
196} PSXSPoint_t;\r
197\r
198typedef struct PSXRECTTAG\r
199{\r
200 short x0;\r
201 short x1;\r
202 short y0;\r
203 short y1;\r
204} PSXRect_t;\r
205\r
206/////////////////////////////////////////////////////////////////////////////\r
207\r
208typedef struct TWINTAG\r
209{\r
210 PSXRect_t Position;\r
211 PSXRect_t OPosition;\r
212 PSXPoint_t TextureSize;\r
213 float UScaleFactor;\r
214 float VScaleFactor;\r
215} TWin_t;\r
216\r
217/////////////////////////////////////////////////////////////////////////////\r
218\r
219typedef struct PSXDISPLAYTAG\r
220{\r
221 PSXPoint_t DisplayModeNew;\r
222 PSXPoint_t DisplayMode;\r
223 PSXPoint_t DisplayPosition;\r
224 PSXPoint_t DisplayEnd;\r
225 \r
226 long Double;\r
227 long Height;\r
228 long PAL;\r
229 long InterlacedNew;\r
230 long Interlaced;\r
231 long InterlacedTest;\r
232 long RGB24New;\r
233 long RGB24;\r
234 PSXSPoint_t DrawOffset;\r
235 PSXRect_t DrawArea;\r
236 PSXPoint_t GDrawOffset;\r
237 PSXPoint_t CumulOffset;\r
238 long Disabled;\r
239 PSXRect_t Range;\r
240} PSXDisplay_t;\r
241\r
242/////////////////////////////////////////////////////////////////////////////\r
243\r
244typedef struct OGLVertexTag \r
245{\r
246 GLfloat x;\r
247 GLfloat y;\r
248 GLfloat z;\r
249\r
250 GLfloat sow;\r
251 GLfloat tow;\r
252\r
253 union\r
254COLTAG\r
255 {\r
256 u8 col[4];\r
257 unsigned long lcol;\r
258 } c;\r
259\r
260} OGLVertex;\r
261\r
262typedef union EXShortTag\r
263{\r
264 u8 c[2];\r
265 unsigned short s;\r
266} EXShort;\r
267\r
268typedef union EXLongTag\r
269{\r
270 u8 c[4];\r
271 unsigned long l;\r
272 EXShort s[2];\r
273} EXLong;\r
274\r
275\r
276/////////////////////////////////////////////////////////////////////////////\r
277\r
278#ifdef _WINDOWS\r
279\r
280extern HINSTANCE hInst;\r
281\r
282#endif\r
283 \r
284//-----------------------------------------------------//\r
285\r
286#ifndef _IN_DRAW\r
287\r
288extern int iResX;\r
289extern int iResY;\r
290extern BOOL bKeepRatio;\r
291extern RECT rRatioRect;\r
292extern BOOL bOpaquePass;\r
293extern BOOL bAdvancedBlend;\r
294\r
295//extern PFNGLBLENDEQU glBlendEquationEXTEx;\r
296//extern PFNGLCOLORTABLEEXT glColorTableEXTEx;\r
297\r
298extern u8 gl_ux[8];\r
299extern u8 gl_vy[8];\r
300extern OGLVertex vertex[4];\r
301extern short sprtY,sprtX,sprtH,sprtW;\r
302#ifdef _WINDOWS\r
303extern HWND hWWindow;\r
304#endif\r
305extern BOOL bIsFirstFrame;\r
306extern int iWinSize;\r
307extern int iZBufferDepth;\r
308extern GLbitfield uiBufferBits;\r
309extern int iUseMask;\r
310extern int iSetMask;\r
311extern int iDepthFunc;\r
312extern BOOL bCheckMask;\r
313extern unsigned short sSetMask;\r
314extern unsigned long lSetMask;\r
315extern BOOL bSetClip;\r
316extern GLuint gTexScanName;\r
317\r
318#endif\r
319\r
320//-----------------------------------------------------//\r
321\r
322#ifndef _IN_SOFT\r
323\r
324extern long GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;\r
325extern long GlobalTextREST,GlobalTextABR,GlobalTextPAGE;\r
326extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;\r
327extern short g_m1;\r
328extern short g_m2;\r
329extern short g_m3;\r
330extern short DrawSemiTrans;\r
331\r
332#endif\r
333\r
334//-----------------------------------------------------//\r
335\r
336#ifndef _IN_PRIMDRAW\r
337\r
338extern BOOL bNeedUploadTest;\r
339extern BOOL bNeedUploadAfter;\r
340extern BOOL bTexEnabled;\r
341extern BOOL bBlendEnable;\r
342extern BOOL bDrawDither;\r
343extern int iFilterType; \r
344extern BOOL bFullVRam;\r
345extern BOOL bUseMultiPass;\r
346extern int iOffscreenDrawing;\r
347extern BOOL bOldSmoothShaded;\r
348extern BOOL bUsingTWin;\r
349extern BOOL bUsingMovie;\r
350extern PSXRect_t xrMovieArea;\r
351extern PSXRect_t xrUploadArea;\r
352extern PSXRect_t xrUploadAreaIL;\r
353extern PSXRect_t xrUploadAreaRGB24;\r
354extern GLuint gTexName;\r
355extern BOOL bDrawNonShaded;\r
356extern BOOL bDrawMultiPass;\r
357extern GLubyte ubGloColAlpha;\r
358extern GLubyte ubGloAlpha;\r
359extern short sSprite_ux2;\r
360extern short sSprite_vy2;\r
361extern BOOL bRenderFrontBuffer;\r
362extern unsigned long ulOLDCOL;\r
363extern unsigned long ulClutID;\r
364extern void (*primTableJ[256])(u8 *);\r
365extern void (*primTableSkip[256])(u8 *);\r
366extern unsigned short usMirror;\r
367extern unsigned long dwCfgFixes;\r
368extern unsigned long dwActFixes;\r
369extern unsigned long dwEmuFixes;\r
370extern BOOL bUseFixes;\r
371extern int iSpriteTex;\r
372extern int iDrawnSomething;\r
373\r
374extern long drawX;\r
375extern long drawY;\r
376extern long drawW;\r
377extern long drawH;\r
378extern short sxmin;\r
379extern short sxmax;\r
380extern short symin;\r
381extern short symax;\r
382\r
383#endif\r
384\r
385//-----------------------------------------------------//\r
386\r
387#ifndef _IN_TEXTURE\r
388\r
389extern u8 ubOpaqueDraw;\r
390extern GLint giWantedRGBA;\r
391extern GLint giWantedFMT;\r
392extern GLint giWantedTYPE;\r
393extern void (*LoadSubTexFn) (int,int,short,short);\r
394extern long GlobalTexturePage;\r
395extern unsigned long (*TCF[]) (unsigned long);\r
396extern unsigned short (*PTCF[]) (unsigned short);\r
397extern unsigned long (*PalTexturedColourFn) (unsigned long);\r
398extern BOOL bUseFastMdec;\r
399extern BOOL bUse15bitMdec;\r
400extern int iFrameTexType;\r
401extern int iFrameReadType;\r
402extern int iClampType;\r
403extern int iSortTexCnt;\r
404extern BOOL bFakeFrontBuffer; \r
405extern GLuint gTexFrameName;\r
406extern GLuint gTexBlurName;\r
407extern int iVRamSize;\r
408extern int iTexGarbageCollection;\r
409extern int iFTexA;\r
410extern int iFTexB;\r
411extern BOOL bIgnoreNextTile;\r
412\r
413\r
414#endif\r
415\r
416//-----------------------------------------------------//\r
417\r
418#ifndef _IN_GPU\r
419\r
420extern VRAMLoad_t VRAMWrite;\r
421extern VRAMLoad_t VRAMRead;\r
422extern int iDataWriteMode;\r
423extern int iDataReadMode;\r
424extern int iColDepth;\r
425extern BOOL bChangeRes;\r
426extern BOOL bWindowMode;\r
427extern s8 szDispBuf[];\r
428extern s8 szGPUKeys[];\r
429extern PSXDisplay_t PSXDisplay;\r
430extern PSXDisplay_t PreviousPSXDisplay;\r
431//extern unsigned long ulKeybits;\r
432extern TWin_t TWin;\r
433extern BOOL bDisplayNotSet;\r
434extern long lGPUstatusRet;\r
435extern short imageX0,imageX1;\r
436extern short imageY0,imageY1;\r
437extern long lClearOnSwap,lClearOnSwapColor;\r
438extern u8 * psxVub;\r
439extern s8 * psxVsb;\r
440extern unsigned short * psxVuw;\r
441extern signed short * psxVsw;\r
442extern unsigned long * psxVul;\r
443extern signed long * psxVsl;\r
444extern GLfloat gl_z;\r
445extern BOOL bNeedRGB24Update;\r
446extern BOOL bChangeWinMode;\r
447extern GLuint uiScanLine;\r
448extern int iUseScanLines;\r
449extern long lSelectedSlot;\r
450extern int iScanBlend;\r
451extern BOOL bInitCap;\r
452extern int iBlurBuffer;\r
453extern int iLastRGB24;\r
454extern int iRenderFVR;\r
455extern int iNoScreenSaver;\r
456extern unsigned long ulGPUInfoVals[];\r
457extern BOOL bNeedInterlaceUpdate;\r
458extern BOOL bNeedWriteUpload;\r
459extern BOOL bSkipNextFrame;\r
460\r
461\r
462#ifndef _WINDOWS\r
463extern int bFullScreen;\r
464#endif\r
465\r
466#endif\r
467\r
468//-----------------------------------------------------//\r
469\r
470#ifndef _IN_MENU\r
471\r
472//extern unsigned long dwCoreFlags;\r
473extern GLuint gTexPicName;\r
474//extern PSXPoint_t ptCursorPoint[];\r
475//extern unsigned short usCursorActive;\r
476\r
477#endif\r
478\r
479//-----------------------------------------------------//\r
480\r
481#ifndef _IN_CFG\r
482\r
483#ifndef _WINDOWS\r
484extern s8 * pConfigFile;\r
485#endif\r
486\r
487#endif\r
488\r
489//-----------------------------------------------------//\r
490\r
491#ifndef _IN_FPS\r
492\r
493extern BOOL bUseFrameLimit;\r
494extern BOOL bUseFrameSkip;\r
495extern float fFrameRate;\r
496extern float fFrameRateHz;\r
497extern int iFrameLimit;\r
498extern float fps_skip;\r
499extern float fps_cur;\r
500\r
501#endif\r
502\r
503//-----------------------------------------------------//\r
504\r
505typedef struct {\r
506u8 r;\r
507u8 g;\r
508u8 b;\r
509u8 a;\r
510} Vec4f;\r
511\r
512/**/\r
513typedef struct {\r
514float x;\r
515float y;\r
516float z;\r
517} Vec3f;\r
518\r
519typedef struct {\r
520float x;\r
521float y;\r
522} Vec2f;\r
523\r
524/*\r
525typedef struct {\r
526int x;\r
527int y;\r
528int z;\r
529} Vec3f;\r
530\r
531typedef struct {\r
532int x;\r
533int y;\r
534} Vec2f;\r
7eadbf88 535*/\r
ce879073 536\r
537typedef struct {\r
538 Vec3f xyz;\r
539 Vec2f st;\r
540} Vertex;\r
541\r
542typedef struct {\r
543 Vec3f xyz;\r
544 Vec2f st;\r
545 Vec4f rgba;\r
546} Vertex2;\r
547\r
548#ifndef _IN_KEY\r
549\r
550//extern unsigned long ulKeybits;\r
551\r
552#endif\r
553\r
554//-----------------------------------------------------//\r
555\r
556#ifndef _IN_ZN\r
557\r
558extern unsigned long dwGPUVersion;\r
559extern int iGPUHeight;\r
560extern int iGPUHeightMask;\r
561extern int GlobalTextIL;\r
562extern int iTileCheat;\r
563\r
564#endif\r
565\r
566#ifdef __cplusplus\r
567}\r
568#endif\r
569\r
570\r
571#endif\r
572\r
573//-----------------------------------------------------//\r