/[pcsx2_0.9.7]/trunk/plugins/zerogs/opengl/GS.h
ViewVC logotype

Contents of /trunk/plugins/zerogs/opengl/GS.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 16040 byte(s)
re-commit (had local access denied errors when committing)
1 /* ZeroGS KOSMOS
2 * Copyright (C) 2005-2006 zerofrog@gmail.com
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef __GS_H__
20 #define __GS_H__
21
22 #ifdef _WIN32
23
24 #include <windows.h>
25 #include <windowsx.h>
26
27 extern HWND GShwnd;
28
29 #else // linux basic definitions
30
31 #include <GL/glew.h>
32 #include <GL/gl.h>
33 #include <GL/glx.h>
34 #include <X11/Xlib.h>
35 #include <X11/Xutil.h>
36 #include <X11/keysym.h>
37 #include <X11/extensions/xf86vmode.h>
38 #include <gtk/gtk.h>
39 #include <sys/stat.h>
40 #include <sys/types.h>
41
42 #endif
43
44 #include <stdio.h>
45 #include <malloc.h>
46 #include <assert.h>
47
48 // need C definitions
49 extern "C" {
50 #define GSdefs
51 #include "PS2Edefs.h"
52
53 extern "C" u32 CALLBACK PS2EgetLibType(void);
54 extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
55 extern "C" char* CALLBACK PS2EgetLibName(void);
56 }
57
58 #include "zerogsmath.h"
59
60 #ifndef _WIN32
61 #include <assert.h>
62
63 #include <vector>
64 #include <string>
65 using namespace std;
66
67 extern std::string s_strIniPath;
68
69 extern u32 THR_KeyEvent; // value for passing out key events beetwen threads
70 extern bool THR_bShift;
71
72 #if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
73
74 // declare linux equivalents
75 static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
76 {
77 assert( align < 0x10000 );
78 char* p = (char*)malloc(size+align);
79 int off = 2+align - ((int)(uptr)(p+2) % align);
80
81 p += off;
82 *(u16*)(p-2) = off;
83
84 return p;
85 }
86
87 static __forceinline void pcsx2_aligned_free(void* pmem)
88 {
89 if( pmem != NULL ) {
90 char* p = (char*)pmem;
91 free(p - (int)*(u16*)(p-2));
92 }
93 }
94
95 #define _aligned_malloc pcsx2_aligned_malloc
96 #define _aligned_free pcsx2_aligned_free
97
98 #endif
99
100 #include <sys/timeb.h> // ftime(), struct timeb
101
102 inline unsigned long timeGetTime()
103 {
104 #ifdef _WIN32
105 _timeb t;
106 _ftime(&t);
107 #else
108 timeb t;
109 ftime(&t);
110 #endif
111
112 return (unsigned long)(t.time*1000+t.millitm);
113 }
114
115 #define max(a,b) (((a) > (b)) ? (a) : (b))
116 #define min(a,b) (((a) < (b)) ? (a) : (b))
117
118 struct RECT
119 {
120 int left, top;
121 int right, bottom;
122 };
123
124 #define GL_X11_WINDOW
125
126 class GLWindow
127 {
128 private:
129 #ifdef GL_X11_WINDOW
130 Display *glDisplay;
131 Window glWindow;
132 int glScreen;
133 GLXContext context;
134 XSetWindowAttributes attr;
135 XF86VidModeModeInfo deskMode;
136 #endif
137 bool fullScreen, doubleBuffered;
138 s32 x, y;
139 u32 width, height, depth;
140
141 public:
142 void SwapBuffers();
143 void SetTitle(char *strtitle);
144 bool CreateWindow(void *pDisplay);
145 bool DestroyWindow();
146 void CloseWindow();
147 void DisplayWindow(int _width, int _height);
148 void ResizeCheck();
149 };
150
151 extern GLWindow GLWin;
152
153 #endif // linux basic definitions
154
155 struct Vector_16F
156 {
157 u16 x, y, z, w;
158 };
159
160 /////////////////////
161
162 #ifdef ZEROGS_DEVBUILD
163 #define GS_LOG __Log
164 #else
165 #define GS_LOG 0&&
166 #endif
167
168 #define ERROR_LOG __LogToConsole
169 #define DEBUG_LOG printf
170
171 #ifndef ZEROGS_DEVBUILD
172 #define WARN_LOG 0&&
173 #define PRIM_LOG 0&&
174 #else
175 #define WARN_LOG printf
176 #define PRIM_LOG if (conf.log & 0x00000010) GS_LOG
177 #endif
178
179 #ifndef GREG_LOG
180 #define GREG_LOG 0&&
181 #endif
182 #ifndef PRIM_LOG
183 #define PRIM_LOG 0&&
184 #endif
185 #ifndef WARN_LOG
186 #define WARN_LOG 0&&
187 #endif
188
189 #define REG64(name) \
190 union name \
191 { \
192 u64 i64; \
193 u32 ai32[2]; \
194 struct { \
195
196 #define REG128(name)\
197 union name \
198 { \
199 u64 ai64[2]; \
200 u32 ai32[4]; \
201 struct { \
202
203 #define REG64_(prefix, name) REG64(prefix##name)
204 #define REG128_(prefix, name) REG128(prefix##name)
205
206 #define REG_END }; };
207 #define REG_END2 };
208
209 #define REG64_SET(name) \
210 union name \
211 { \
212 u64 i64; \
213 u32 ai32[2]; \
214
215 #define REG128_SET(name)\
216 union name \
217 { \
218 u64 ai64[2]; \
219 u32 ai32[4]; \
220
221 #define REG_SET_END };
222
223 REG64_(GSReg, BGCOLOR)
224 u32 R:8;
225 u32 G:8;
226 u32 B:8;
227 u32 _PAD1:8;
228 u32 _PAD2:32;
229 REG_END
230
231 REG64_(GSReg, BUSDIR)
232 u32 DIR:1;
233 u32 _PAD1:31;
234 u32 _PAD2:32;
235 REG_END
236
237 REG64_(GSReg, CSR)
238 u32 SIGNAL:1;
239 u32 FINISH:1;
240 u32 HSINT:1;
241 u32 VSINT:1;
242 u32 EDWINT:1;
243 u32 ZERO1:1;
244 u32 ZERO2:1;
245 u32 _PAD1:1;
246 u32 FLUSH:1;
247 u32 RESET:1;
248 u32 _PAD2:2;
249 u32 NFIELD:1;
250 u32 FIELD:1;
251 u32 FIFO:2;
252 u32 REV:8;
253 u32 ID:8;
254 u32 _PAD3:32;
255 REG_END
256
257 REG64_(GSReg, DISPFB) // (-1/2)
258 u32 FBP:9;
259 u32 FBW:6;
260 u32 PSM:5;
261 u32 _PAD:12;
262 u32 DBX:11;
263 u32 DBY:11;
264 u32 _PAD2:10;
265 REG_END
266
267 REG64_(GSReg, DISPLAY) // (-1/2)
268 u32 DX:12;
269 u32 DY:11;
270 u32 MAGH:4;
271 u32 MAGV:2;
272 u32 _PAD:3;
273 u32 DW:12;
274 u32 DH:11;
275 u32 _PAD2:9;
276 REG_END
277
278 REG64_(GSReg, EXTBUF)
279 u32 EXBP:14;
280 u32 EXBW:6;
281 u32 FBIN:2;
282 u32 WFFMD:1;
283 u32 EMODA:2;
284 u32 EMODC:2;
285 u32 _PAD1:5;
286 u32 WDX:11;
287 u32 WDY:11;
288 u32 _PAD2:10;
289 REG_END
290
291 REG64_(GSReg, EXTDATA)
292 u32 SX:12;
293 u32 SY:11;
294 u32 SMPH:4;
295 u32 SMPV:2;
296 u32 _PAD1:3;
297 u32 WW:12;
298 u32 WH:11;
299 u32 _PAD2:9;
300 REG_END
301
302 REG64_(GSReg, EXTWRITE)
303 u32 WRITE;
304 u32 _PAD2:32;
305 REG_END
306
307 REG64_(GSReg, IMR)
308 u32 _PAD1:8;
309 u32 SIGMSK:1;
310 u32 FINISHMSK:1;
311 u32 HSMSK:1;
312 u32 VSMSK:1;
313 u32 EDWMSK:1;
314 u32 _PAD2:19;
315 u32 _PAD3:32;
316 REG_END
317
318 REG64_(GSReg, PMODE)
319 u32 EN1:1;
320 u32 EN2:1;
321 u32 CRTMD:3;
322 u32 MMOD:1;
323 u32 AMOD:1;
324 u32 SLBG:1;
325 u32 ALP:8;
326 u32 _PAD:16;
327 u32 _PAD1:32;
328 REG_END
329
330 REG64_(GSReg, SIGLBLID)
331 u32 SIGID:32;
332 u32 LBLID:32;
333 REG_END
334
335 REG64_(GSReg, SMODE1)
336 u32 RC:3;
337 u32 LC:7;
338 u32 T1248:2;
339 u32 SLCK:1;
340 u32 CMOD:2;
341 u32 EX:1;
342 u32 PRST:1;
343 u32 SINT:1;
344 u32 XPCK:1;
345 u32 PCK2:2;
346 u32 SPML:4;
347 u32 GCONT:1;
348 u32 PHS:1;
349 u32 PVS:1;
350 u32 PEHS:1;
351 u32 PEVS:1;
352 u32 CLKSEL:2;
353 u32 NVCK:1;
354 u32 SLCK2:1;
355 u32 VCKSEL:2;
356 u32 VHP:1;
357 u32 _PAD1:27;
358 REG_END
359
360 REG64_(GSReg, SMODE2)
361 u32 INT:1;
362 u32 FFMD:1;
363 u32 DPMS:2;
364 u32 _PAD2:28;
365 u32 _PAD3:32;
366 REG_END
367
368 REG64_(GSReg, SIGBLID)
369 u32 SIGID;
370 u32 LBLID;
371 REG_END
372
373 extern int g_LastCRC;
374 extern u8* g_pBasePS2Mem;
375
376 #define PMODE ((GSRegPMODE*)(g_pBasePS2Mem+0x0000))
377 #define SMODE1 ((GSRegSMODE1*)(g_pBasePS2Mem+0x0010))
378 #define SMODE2 ((GSRegSMODE2*)(g_pBasePS2Mem+0x0020))
379 // SRFSH
380 #define SYNCH1 ((GSRegSYNCH1*)(g_pBasePS2Mem+0x0040))
381 #define SYNCH2 ((GSRegSYNCH2*)(g_pBasePS2Mem+0x0050))
382 #define SYNCV ((GSRegSYNCV*)(g_pBasePS2Mem+0x0060))
383 #define DISPFB1 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0070))
384 #define DISPLAY1 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x0080))
385 #define DISPFB2 ((GSRegDISPFB*)(g_pBasePS2Mem+0x0090))
386 #define DISPLAY2 ((GSRegDISPLAY*)(g_pBasePS2Mem+0x00a0))
387 #define EXTBUF ((GSRegEXTBUF*)(g_pBasePS2Mem+0x00b0))
388 #define EXTDATA ((GSRegEXTDATA*)(g_pBasePS2Mem+0x00c0))
389 #define EXTWRITE ((GSRegEXTWRITE*)(g_pBasePS2Mem+0x00d0))
390 #define BGCOLOR ((GSRegBGCOLOR*)(g_pBasePS2Mem+0x00e0))
391 #define CSR ((GSRegCSR*)(g_pBasePS2Mem+0x1000))
392 #define IMR ((GSRegIMR*)(g_pBasePS2Mem+0x1010))
393 #define BUSDIR ((GSRegBUSDIR*)(g_pBasePS2Mem+0x1040))
394 #define SIGLBLID ((GSRegSIGBLID*)(g_pBasePS2Mem+0x1080))
395
396 #define GET_GSFPS (((SMODE1->CMOD&1) ? 50 : 60) / (SMODE2->INT ? 1 : 2))
397
398 //
399 // sps2tags.h
400 //
401 #ifdef _M_AMD64
402 #define GET_GIF_REG(tag, reg) \
403 (((tag).ai64[1] >> ((reg) << 2)) & 0xf)
404 #else
405 #define GET_GIF_REG(tag, reg) \
406 (((tag).ai32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf)
407 #endif
408
409 //
410 // GIFTag
411 REG128(GIFTag)
412 u32 NLOOP:15;
413 u32 EOP:1;
414 u32 _PAD1:16;
415 u32 _PAD2:14;
416 u32 PRE:1;
417 u32 PRIM:11;
418 u32 FLG:2; // enum GIF_FLG
419 u32 NREG:4;
420 u64 REGS:64;
421 REG_END
422
423 typedef struct {
424 int x, y, w, h;
425 } Rect;
426
427 typedef struct {
428 int x, y;
429 } Point;
430
431 typedef struct {
432 int x0, y0;
433 int x1, y1;
434 } Rect2;
435
436 typedef struct {
437 int x, y, c;
438 } PointC;
439
440 #define GSOPTION_FULLSCREEN 0x2
441 #define GSOPTION_TGASNAP 0x4
442 #define GSOPTION_CAPTUREAVI 0x8
443
444 #define GSOPTION_WINDIMS 0x30
445 #define GSOPTION_WIN640 0x00
446 #define GSOPTION_WIN800 0x10
447 #define GSOPTION_WIN1024 0x20
448 #define GSOPTION_WIN1280 0x30
449
450 #define GSOPTION_WIREFRAME 0x100
451 #define GSOPTION_LOADED 0x8000
452
453 typedef struct {
454 u8 mrtdepth; // write color in render target
455 u8 interlace;
456 u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x
457 u8 bilinear; // set to enable bilinear support
458 u32 options;
459 u32 gamesettings; // default game settings
460 int width, height;
461 int winstyle; // window style before full screen
462 #ifdef GS_LOG
463 u32 log;
464 #endif
465 } GSconf;
466
467 struct VertexGPU
468 {
469 s16 x, y, f, resv0; // note: xy is 12d3
470 u32 rgba;
471 u32 z;
472 float s, t, q;
473 };
474
475 struct Vertex
476 {
477 u16 x, y, f, resv0; // note: xy is 12d3
478 u32 rgba;
479 u32 z;
480 float s, t, q;
481 u16 u, v;
482 };
483
484 extern int g_GameSettings;
485 extern GSconf conf;
486 extern int ppf;
487
488 // PSM values
489 // PSM types == Texture Storage Format
490 enum PSM_value{
491 PSMCT32 = 0, // 000000
492 PSMCT24 = 1, // 000001
493 PSMCT16 = 2, // 000010
494 PSMCT16S = 10, // 001010
495 PSMT8 = 19, // 010011
496 PSMT4 = 20, // 010100
497 PSMT8H = 27, // 011011
498 PSMT4HL = 36, // 100100
499 PSMT4HH = 44, // 101100
500 PSMT32Z = 48, // 110000
501 PSMT24Z = 49, // 110001
502 PSMT16Z = 50, // 110010
503 PSMT16SZ = 58, // 111010
504 };
505
506 static __forceinline bool PSMT_ISCLUT(u32 psm) { return ((psm & 0x7) > 2);}
507 static __forceinline bool PSMT_IS16BIT(u32 psm) { return ((psm & 0x7) == 2);}
508
509 typedef struct {
510 int nloop;
511 int eop;
512 int nreg;
513 } tagInfo;
514
515 typedef union {
516 s64 SD;
517 u64 UD;
518 s32 SL[2];
519 u32 UL[2];
520 s16 SS[4];
521 u16 US[4];
522 s8 SC[8];
523 u8 UC[8];
524 } reg64;
525
526 /* general purpose regs structs */
527 typedef struct {
528 int fbp;
529 int fbw;
530 int fbh;
531 int psm;
532 u32 fbm;
533 } frameInfo;
534
535 typedef struct {
536 u16 prim;
537
538 union {
539 struct {
540 u16 iip : 1;
541 u16 tme : 1;
542 u16 fge : 1;
543 u16 abe : 1;
544 u16 aa1 : 1;
545 u16 fst : 1;
546 u16 ctxt : 1;
547 u16 fix : 1;
548 u16 resv : 8;
549 };
550 u16 _val;
551 };
552 } primInfo;
553
554 extern primInfo *prim;
555
556 typedef union {
557 struct {
558 u32 ate : 1;
559 u32 atst : 3;
560 u32 aref : 8;
561 u32 afail : 2;
562 u32 date : 1;
563 u32 datm : 1;
564 u32 zte : 1;
565 u32 ztst : 2;
566 u32 resv : 13;
567 };
568 u32 _val;
569 } pixTest;
570
571 typedef struct {
572 int bp;
573 int bw;
574 int psm;
575 } bufInfo;
576
577 typedef struct {
578 int tbp0;
579 int tbw;
580 int cbp;
581 u16 tw, th;
582 u8 psm;
583 u8 tcc;
584 u8 tfx;
585 u8 cpsm;
586 u8 csm;
587 u8 csa;
588 u8 cld;
589 } tex0Info;
590
591 #define TEX_MODULATE 0
592 #define TEX_DECAL 1
593 #define TEX_HIGHLIGHT 2
594 #define TEX_HIGHLIGHT2 3
595
596 typedef struct {
597 int lcm;
598 int mxl;
599 int mmag;
600 int mmin;
601 int mtba;
602 int l;
603 int k;
604 } tex1Info;
605
606 typedef struct {
607 int wms;
608 int wmt;
609 int minu;
610 int maxu;
611 int minv;
612 int maxv;
613 } clampInfo;
614
615 typedef struct {
616 int cbw;
617 int cou;
618 int cov;
619 } clutInfo;
620
621 typedef struct {
622 int tbp[3];
623 int tbw[3];
624 } miptbpInfo;
625
626 typedef struct {
627 u16 aem;
628 u8 ta[2];
629 float fta[2];
630 } texaInfo;
631
632 typedef struct {
633 int sx;
634 int sy;
635 int dx;
636 int dy;
637 int dir;
638 } trxposInfo;
639
640 typedef struct {
641 union {
642 struct {
643 u8 a : 2;
644 u8 b : 2;
645 u8 c : 2;
646 u8 d : 2;
647 };
648 u8 abcd;
649 };
650
651 u8 fix : 8;
652 } alphaInfo;
653
654 typedef struct {
655 u16 zbp; // u16 address / 64
656 u8 psm;
657 u8 zmsk;
658 } zbufInfo;
659
660 typedef struct {
661 int fba;
662 } fbaInfo;
663
664 typedef struct {
665 int mode;
666 int regn;
667 u64 regs;
668 tagInfo tag;
669 } pathInfo;
670
671 typedef struct {
672 Vertex gsvertex[3];
673 u32 rgba;
674 float q;
675 Vertex vertexregs;
676
677 int primC; // number of verts current storing
678 int primIndex; // current prim index
679 int nTriFanVert;
680
681 int prac;
682 int dthe;
683 int colclamp;
684 int fogcol;
685 int smask;
686 int pabe;
687 u64 buff[2];
688 int buffsize;
689 int cbp[2]; // internal cbp registers
690
691 u32 CSRw;
692
693 primInfo _prim[2];
694 bufInfo srcbuf, srcbufnew;
695 bufInfo dstbuf, dstbufnew;
696
697 clutInfo clut;
698
699 texaInfo texa;
700 trxposInfo trxpos, trxposnew;
701
702 int imageWtemp, imageHtemp;
703
704 int imageTransfer;
705 int imageWnew, imageHnew, imageX, imageY, imageEndX, imageEndY;
706
707 pathInfo path1;
708 pathInfo path2;
709 pathInfo path3;
710
711 } GSinternal;
712
713 extern GSinternal gs;
714
715 extern FILE *gsLog;
716
717 void __Log(const char *fmt, ...);
718 void __LogToConsole(const char *fmt, ...);
719
720 void LoadConfig();
721 void SaveConfig();
722
723 extern void (*GSirq)();
724
725 void *SysLoadLibrary(char *lib); // Loads Library
726 void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library
727 char *SysLibError(); // Gets previous error loading sysbols
728 void SysCloseLibrary(void *lib); // Closes Library
729 void SysMessage(char *fmt, ...);
730
731 extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
732 extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
733
734 template <typename T>
735 class CInterfacePtr
736 {
737 public:
738 inline CInterfacePtr() : ptr(NULL) {}
739 inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if ( ptr != NULL ) ptr->AddRef(); }
740 inline ~CInterfacePtr() { if( ptr != NULL ) ptr->Release(); }
741
742 inline T* operator* () { assert( ptr != NULL); return *ptr; }
743 inline T* operator->() { return ptr; }
744 inline T* get() { return ptr; }
745
746 inline void release() {
747 if( ptr != NULL ) { ptr->Release(); ptr = NULL; }
748 }
749
750 inline operator T*() { return ptr; }
751
752 inline bool operator==(T* rhs) { return ptr == rhs; }
753 inline bool operator!=(T* rhs) { return ptr != rhs; }
754
755 inline CInterfacePtr& operator= (T* newptr) {
756 if( ptr != NULL ) ptr->Release();
757 ptr = newptr;
758
759 if( ptr != NULL ) ptr->AddRef();
760 return *this;
761 }
762
763 private:
764 T* ptr;
765 };
766
767 #define RGBA32to16(c) \
768 (u16)((((c) & 0x000000f8) >> 3) | \
769 (((c) & 0x0000f800) >> 6) | \
770 (((c) & 0x00f80000) >> 9) | \
771 (((c) & 0x80000000) >> 16)) \
772
773 #define RGBA16to32(c) \
774 (((c) & 0x001f) << 3) | \
775 (((c) & 0x03e0) << 6) | \
776 (((c) & 0x7c00) << 9) | \
777 (((c) & 0x8000) ? 0xff000000 : 0) \
778
779 // converts float16 [0,1] to BYTE [0,255] (assumes value is in range, otherwise will take lower 8bits)
780 // f is a u16
781 static __forceinline u16 Float16ToBYTE(u16 f) {
782 //assert( !(f & 0x8000) );
783 if( f & 0x8000 ) return 0;
784
785 u16 d = ((((f&0x3ff)|0x400)*255)>>(10-((f>>10)&0x1f)+15));
786 return d > 255 ? 255 : d;
787 }
788
789 static __forceinline u16 Float16ToALPHA(u16 f) {
790 //assert( !(f & 0x8000) );
791 if( f & 0x8000 ) return 0;
792
793 // round up instead of down (crash and burn), too much and charlie breaks
794 u16 d = (((((f&0x3ff)|0x400))*255)>>(10-((f>>10)&0x1f)+15));
795 d = (d)>>1;
796 return d > 255 ? 255 : d;
797 }
798
799 #ifndef COLOR_ARGB
800 #define COLOR_ARGB(a,r,g,b) \
801 ((u32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
802 #endif
803
804 // assumes that positive in [1,2] (then extracts fraction by just looking at the specified bits)
805 #define Float16ToBYTE_2(f) ((u8)(*(u16*)&f>>2))
806 #define Float16To5BIT(f) (Float16ToBYTE(f)>>3)
807
808 #define Float16Alpha(f) (((*(u16*)&f&0x7c00)>=0x3900)?0x8000:0) // alpha is >= 1
809
810 // converts an array of 4 u16s to a u32 color
811 // f is a pointer to a u16
812 #define Float16ToARGB(f) COLOR_ARGB(Float16ToALPHA(f.w), Float16ToBYTE(f.x), Float16ToBYTE(f.y), Float16ToBYTE(f.z));
813
814 #define Float16ToARGB16(f) (Float16Alpha(f.w)|(Float16To5BIT(f.x)<<10)|(Float16To5BIT(f.y)<<5)|Float16To5BIT(f.z))
815
816 // used for Z values
817 #define Float16ToARGB_Z(f) COLOR_ARGB((u32)Float16ToBYTE_2(f.w), Float16ToBYTE_2(f.x), Float16ToBYTE_2(f.y), Float16ToBYTE_2(f.z))
818 #define Float16ToARGB16_Z(f) ((Float16ToBYTE_2(f.y)<<8)|Float16ToBYTE_2(f.z))
819
820
821 inline float Clamp(float fx, float fmin, float fmax)
822 {
823 if( fx < fmin ) return fmin;
824 return fx > fmax ? fmax : fx;
825 }
826
827 // IMPORTANT: For every Register there must be an End
828 void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
829 void DVProfEnd(u32 dwUserData);
830 void DVProfWrite(char* pfilename, u32 frames = 0);
831 void DVProfClear(); // clears all the profilers
832
833 #define DVPROFILE
834 #ifdef DVPROFILE
835
836 class DVProfileFunc
837 {
838 public:
839 u32 dwUserData;
840 DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
841 DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
842 ~DVProfileFunc() { DVProfEnd(dwUserData); }
843 };
844
845 #else
846
847 class DVProfileFunc
848 {
849 public:
850 u32 dwUserData;
851 static __forceinline DVProfileFunc(char* pname) {}
852 static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
853 ~DVProfileFunc() {}
854 };
855
856 #endif
857
858
859 #endif

  ViewVC Help
Powered by ViewVC 1.1.22