zzogl-pg: Split off some of GS.h. Keep working on the tranfer code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2805 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-04-02 05:53:14 +00:00
parent a8841d6e77
commit 5f032dad64
7 changed files with 443 additions and 405 deletions

View File

@ -19,113 +19,17 @@
#ifndef __GS_H__
#define __GS_H__
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
extern HWND GShwnd;
#else // linux basic definitions
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/extensions/xf86vmode.h>
#include <gtk/gtk.h>
#include <sys/types.h>
#endif
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include "Util.h"
extern float fFPS;
#define GSdefs
#include "PS2Edefs.h"
// need C definitions -- no mangling please!
extern "C" u32 CALLBACK PS2EgetLibType(void);
extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
extern "C" char* CALLBACK PS2EgetLibName(void);
#include "zerogsmath.h"
#include <assert.h>
#include <vector>
#include <string>
using namespace std;
extern u32 THR_KeyEvent; // value for passing out key events beetwen threads
extern bool THR_bShift;
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
#ifndef _WIN32
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
// declare linux equivalents
static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
{
assert( align < 0x10000 );
char* p = (char*)malloc(size+align);
int off = 2+align - ((int)(uptr)(p+2) % align);
p += off;
*(u16*)(p-2) = off;
return p;
}
static __forceinline void pcsx2_aligned_free(void* pmem)
{
if( pmem != NULL ) {
char* p = (char*)pmem;
free(p - (int)*(u16*)(p-2));
}
}
#define _aligned_malloc pcsx2_aligned_malloc
#define _aligned_free pcsx2_aligned_free
#endif
#include <sys/timeb.h> // ftime(), struct timeb
inline unsigned long timeGetTime()
{
#ifdef _WIN32
_timeb t;
_ftime(&t);
#else
timeb t;
ftime(&t);
#endif
return (unsigned long)(t.time*1000+t.millitm);
}
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
struct RECT
{
int left, top;
int right, bottom;
};
#define GL_X11_WINDOW
#else
#define GL_WIN32_WINDOW
#endif // linux basic definitions
#else
#define GL_X11_WINDOW
#endif
#undef CreateWindow // Undo Windows.h global namespace pollution
@ -161,139 +65,6 @@ struct Vector_16F
u16 x, y, z, w;
};
/////////////////////
// define when releasing
// The only code that uses it is commented out!
//#define ZEROGS_CACHEDCLEAR // much better performance
//#define RELEASE_TO_PUBLIC
// fixme - We should use ZEROGS_DEVBUILD to determine devel/debug builds from "public release" builds.
// Means a lot of search-and-replace though. (air)
#ifdef ZEROGS_DEVBUILD
#define GS_LOG __Log
#else
#define GS_LOG 0&&
#endif
#define ERROR_LOG __LogToConsole
//Logging for errors that are called often should have a time counter.
#ifdef __LINUX__
static u32 __attribute__((unused)) lasttime = 0;
static u32 __attribute__((unused)) BigTime = 5000;
static bool __attribute__((unused)) SPAM_PASS;
#else
static u32 lasttime = 0;
static u32 BigTime = 5000;
static bool SPAM_PASS;
#endif
#define ERROR_LOG_SPAM(text) { \
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(text); \
lasttime = timeGetTime(); \
} \
}
// The same macro with one-argument substitution.
#define ERROR_LOG_SPAMA(fmt, value) { \
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(fmt, value); \
lasttime = timeGetTime(); \
} \
}
#define ERROR_LOG_SPAM_TEST(text) {\
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(text); \
lasttime = timeGetTime(); \
SPAM_PASS = true; \
} \
else \
SPAM_PASS = false; \
}
#if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0))
#define FUNCLOG {\
static bool Was_Here = false; \
static unsigned long int waslasttime = 0; \
if (!Was_Here && FILE_IS_IN_CHECK) { \
Was_Here = true;\
ERROR_LOG("%s:%d %s\n", __FILE__, __LINE__, __func__); \
waslasttime = timeGetTime(); \
} \
if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \
Was_Here = false; \
} \
}
#else
#define FUNCLOG
#endif
#define DEBUG_LOG printf
#ifdef RELEASE_TO_PUBLIC
#define WARN_LOG 0&&
#define PRIM_LOG 0&&
#else
#define WARN_LOG printf
#define PRIM_LOG if (conf.log & 0x00000010) GS_LOG
#endif
#ifndef GREG_LOG
#define GREG_LOG 0&&
#endif
#ifndef PRIM_LOG
#define PRIM_LOG 0&&
#endif
#ifndef WARN_LOG
#define WARN_LOG 0&&
#endif
enum GIF_FLG
{
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
};
#define REG64(name) \
union name \
{ \
u64 i64; \
u32 ai32[2]; \
struct { \
#define REG128(name)\
union name \
{ \
u64 ai64[2]; \
u32 ai32[4]; \
struct { \
#define REG64_(prefix, name) REG64(prefix##name)
#define REG128_(prefix, name) REG128(prefix##name)
#define REG_END }; };
#define REG_END2 };
#define REG64_SET(name) \
union name \
{ \
u64 i64; \
u32 ai32[2]; \
#define REG128_SET(name)\
union name \
{ \
u64 ai64[2]; \
u32 ai32[4]; \
#define REG_SET_END };
REG64_(GSReg, BGCOLOR)
u32 R:8;
u32 G:8;
@ -475,68 +246,6 @@ extern u8* g_pBasePS2Mem;
#define GET_GIF_REG(tag, reg) \
(((tag).ai32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf)
//
// GIFTag
REG128(GIFTag)
u32 NLOOP:15;
u32 EOP:1;
u32 _PAD1:16;
u32 _PAD2:14;
u32 PRE:1;
u32 PRIM:11;
u32 FLG:2; // enum GIF_FLG
u32 NREG:4;
u64 REGS:64;
REG_END
typedef struct {
int x, y, w, h;
} Rect;
typedef struct {
int x, y;
} Point;
typedef struct {
int x0, y0;
int x1, y1;
} Rect2;
typedef struct {
int x, y, c;
} PointC;
#define GSOPTION_FULLSCREEN 0x2
#define GSOPTION_TGASNAP 0x4
#define GSOPTION_CAPTUREAVI 0x8
#define GSOPTION_WINDIMS 0x30
#define GSOPTION_WIN640 0x00
#define GSOPTION_WIN800 0x10
#define GSOPTION_WIN1024 0x20
#define GSOPTION_WIN1280 0x30
#define GSOPTION_WIDESCREEN 0x40
#define GSOPTION_WIREFRAME 0x100
#define GSOPTION_LOADED 0x8000
//Configuration values.
typedef struct
{
u8 mrtdepth; // write color in render target
u8 interlace; // intelacing mode 0, 1, 3-off
u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x, 3 - 8x, 4 - 16x
u8 negaa; // negative aliasing
u8 bilinear; // set to enable bilinear support. 0 - off, 1 -- on, 2 -- force (use for textures that usually need it)
u32 options; // game options -- different hacks.
u32 gamesettings;// default game settings
int width, height; // View target size, has no impact towards speed
bool isWideScreen; // Widescreen support
#ifdef GS_LOG
u32 log;
#endif
} GSconf;
// PS2 vertex
struct VertexGPU
{
@ -829,63 +538,6 @@ typedef struct {
extern GSinternal gs;
extern FILE *gsLog;
extern void __Log(const char *fmt, ...);
extern void __LogToConsole(const char *fmt, ...);
extern void LoadConfig();
extern void SaveConfig();
extern void (*GSirq)();
extern void *SysLoadLibrary(char *lib); // Loads Library
extern void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library
extern char *SysLibError(); // Gets previous error loading sysbols
extern void SysCloseLibrary(void *lib); // Closes Library
extern void SysMessage(const char *fmt, ...);
#ifdef __LINUX__
#include "Utilities/MemcpyFast.h"
#define memcpy_amd memcpy_fast
#else
extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
#endif
template <typename T>
class CInterfacePtr
{
public:
inline CInterfacePtr() : ptr(NULL) {}
inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if ( ptr != NULL ) ptr->AddRef(); }
inline ~CInterfacePtr() { if( ptr != NULL ) ptr->Release(); }
inline T* operator* () { assert( ptr != NULL); return *ptr; }
inline T* operator->() { return ptr; }
inline T* get() { return ptr; }
inline void release() {
if( ptr != NULL ) { ptr->Release(); ptr = NULL; }
}
inline operator T*() { return ptr; }
inline bool operator==(T* rhs) { return ptr == rhs; }
inline bool operator!=(T* rhs) { return ptr != rhs; }
inline CInterfacePtr& operator= (T* newptr) {
if( ptr != NULL ) ptr->Release();
ptr = newptr;
if( ptr != NULL ) ptr->AddRef();
return *this;
}
private:
T* ptr;
};
static __forceinline u16 RGBA32to16(u32 c)
{
return (u16)((((c) & 0x000000f8) >> 3) |
@ -950,37 +602,6 @@ inline float Clamp(float fx, float fmin, float fmax)
return fx > fmax ? fmax : fx;
}
// IMPORTANT: For every Register there must be an End
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
void DVProfEnd(u32 dwUserData);
void DVProfWrite(char* pfilename, u32 frames = 0);
void DVProfClear(); // clears all the profilers
#define DVPROFILE
#ifdef DVPROFILE
class DVProfileFunc
{
public:
u32 dwUserData;
DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
~DVProfileFunc() { DVProfEnd(dwUserData); }
};
#else
class DVProfileFunc
{
public:
u32 dwUserData;
static __forceinline DVProfileFunc(char* pname) {}
static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
~DVProfileFunc() {}
};
#endif
// PSMT16, 16S have shorter color per pixel, also cluted textures with half storage.
inline bool PSMT_ISHALF_STORAGE(const tex0Info& tex0) {
if (PSMT_IS16BIT(tex0.psm) || (PSMT_ISCLUT(tex0.psm) && tex0.cpsm > 1))

View File

@ -134,7 +134,8 @@ bool THR_bShift = false;
#endif
void __Log(const char *fmt, ...) {
void __Log(const char *fmt, ...)
{
va_list list;
// gsLog can be null if the config dialog is used prior to Pcsx2 an emulation session.

View File

@ -30,15 +30,14 @@ void GIFtag(pathInfo *path, u32 *data) {
if (path->tag.nreg == 0) path->tag.nreg = 64;
gs.q = 1;
// GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n",
// data[3], data[2], data[1], data[0],
// path->tag.eop, path->tag.nloop, tagflg, path->tag.nreg, tagpre);
path->mode = tagflg+1;
path->mode = tagflg;
switch (tagflg) {
switch (tagflg)
{
case 0x0:
path->regs = *(u64 *)(data+2);
path->regn = 0;
@ -135,15 +134,15 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
if (path->tag.nloop == 0)
{
GIFtag(path, pMem);
pMem+= 4;
gs.q = 1;
pMem += 4;
size--;
if ((g_GameSettings & GAME_PATH3HACK) && (index == 2) && gs.path[2].tag.eop)
nPath3Hack = 1;
if ((g_GameSettings & GAME_PATH3HACK) && (index == 2) && path->tag.eop) nPath3Hack = 1;
if (index == 0)
{
if (path->mode == 1)
if (path->mode == GIF_FLG_PACKED)
{
// check if 0xb is in any reg, if yes, exit (kh2)
for(int i = 0; i < path->tag.nreg; i += 4)
@ -167,11 +166,11 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
continue;
}
if( !path->tag.eop )
/*if( !path->tag.eop )
{
//DEBUG_LOG("continuing from eop\n");
continue;
}
}*/
// Issue 174 fix!
continue;
@ -180,7 +179,7 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
switch(path->mode)
{
case 1: // PACKED
case GIF_FLG_PACKED:
{
assert( path->tag.nloop > 0 );
for(; size > 0; size--, pMem += 4)
@ -190,6 +189,7 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
g_GIFPackedRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn)
{
path->regn = 0;
@ -203,16 +203,20 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
}
break;
}
case 2: // REGLIST
case GIF_FLG_REGLIST:
{
//GS_LOG("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
assert( path->tag.nloop > 0 );
size *= 2;
for(; size > 0; pMem+= 2, size--)
{
int reg = (int)((path->regs >> path->regn) & 0xf);
g_GIFRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn)
{
path->regn = 0;
@ -229,8 +233,8 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
size /= 2;
break;
}
case 3: // GIF_IMAGE (FROM_VFRAM)
case 4: // Used in the DirectX version, so we'll use it here too.
case GIF_FLG_IMAGE: // FROM_VFRAM
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
{
if(gs.imageTransfer >= 0 && gs.imageTransfer <= 1)
{
@ -254,8 +258,10 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
{
// simulate
int process = min((int)size, path->tag.nloop);
path->tag.nloop -= process;
pMem += process*4; size -= process;
pMem += process*4;
size -= process;
}
break;
@ -284,7 +290,7 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
{
FUNCLOG
//pathInfo *path = &gs.path[0];
pathInfo *path = &gs.path[0];
//GS_LOG("GSgifTransfer1 0x%x (mode %d)\n", addr, path->mode);
@ -295,14 +301,14 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
count++;
#endif
gs.path[0].tag.nloop = 0;
gs.path[0].tag.eop = 0;
path->tag.nloop = 0;
path->tag.eop = 0;
_GSgifTransfer<0>((u32*)((u8*)pMem+addr), (0x4000 - addr)/16);
if (!gs.path[0].tag.eop && (gs.path[0].tag.nloop > 0))
if (!path->tag.eop && (path->tag.nloop > 0))
{
assert( (addr&0xf) == 0 ); //BUG
gs.path[0].tag.nloop = 0;
path->tag.nloop = 0;
ERROR_LOG("Transfer1 - 2\n");
return;
}

View File

@ -23,6 +23,29 @@
#include "Mem.h"
#include "Regs.h"
#include "zerogs.h"
#include "Util.h"
enum GIF_FLG
{
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
};
//
// GIFTag
REG128(GIFTag)
u32 NLOOP:15;
u32 EOP:1;
u32 _PAD1:16;
u32 _PAD2:14;
u32 PRE:1;
u32 PRIM:11;
u32 FLG:2; // enum GIF_FLG
u32 NREG:4;
u64 REGS:64;
REG_END
void GIFtag(pathInfo *path, u32 *data);
void _GSgifPacket(pathInfo *path, u32 *pMem);

View File

@ -365,7 +365,7 @@ void CALLBACK GSconfigure()
DisplayDialog();
}
void __forceinline SysMessage(const char *fmt, ...)
void SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];

View File

@ -0,0 +1,383 @@
/* ZeroGS KOSMOS
* Copyright (C) 2005-2006 zerofrog@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef UTIL_H_INCLUDED
#define UTIL_H_INCLUDED
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
extern HWND GShwnd;
#else // linux basic definitions
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/extensions/xf86vmode.h>
#include <gtk/gtk.h>
#include <sys/types.h>
#endif
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#define GSdefs
#include "PS2Edefs.h"
// need C definitions -- no mangling please!
extern "C" u32 CALLBACK PS2EgetLibType(void);
extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
extern "C" char* CALLBACK PS2EgetLibName(void);
#include "zerogsmath.h"
#include <assert.h>
#include <vector>
#include <string>
extern u32 THR_KeyEvent; // value for passing out key events beetwen threads
extern bool THR_bShift;
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
/////////////////////
// define when releasing
// The only code that uses it is commented out!
//#define ZEROGS_CACHEDCLEAR // much better performance
//#define RELEASE_TO_PUBLIC
// fixme - We should use ZEROGS_DEVBUILD to determine devel/debug builds from "public release" builds.
// Means a lot of search-and-replace though. (air)
#ifdef ZEROGS_DEVBUILD
#define GS_LOG __Log
#else
#define GS_LOG 0&&
#endif
#define ERROR_LOG __LogToConsole
//Logging for errors that are called often should have a time counter.
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
// declare linux equivalents
static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
{
assert( align < 0x10000 );
char* p = (char*)malloc(size+align);
int off = 2+align - ((int)(uptr)(p+2) % align);
p += off;
*(u16*)(p-2) = off;
return p;
}
static __forceinline void pcsx2_aligned_free(void* pmem)
{
if( pmem != NULL ) {
char* p = (char*)pmem;
free(p - (int)*(u16*)(p-2));
}
}
#define _aligned_malloc pcsx2_aligned_malloc
#define _aligned_free pcsx2_aligned_free
#endif
#include <sys/timeb.h> // ftime(), struct timeb
inline unsigned long timeGetTime()
{
#ifdef _WIN32
_timeb t;
_ftime(&t);
#else
timeb t;
ftime(&t);
#endif
return (unsigned long)(t.time*1000+t.millitm);
}
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
struct RECT
{
int left, top;
int right, bottom;
};
typedef struct {
int x, y, w, h;
} Rect;
typedef struct {
int x, y;
} Point;
typedef struct {
int x0, y0;
int x1, y1;
} Rect2;
typedef struct {
int x, y, c;
} PointC;
#define GSOPTION_FULLSCREEN 0x2
#define GSOPTION_TGASNAP 0x4
#define GSOPTION_CAPTUREAVI 0x8
#define GSOPTION_WINDIMS 0x30
#define GSOPTION_WIN640 0x00
#define GSOPTION_WIN800 0x10
#define GSOPTION_WIN1024 0x20
#define GSOPTION_WIN1280 0x30
#define GSOPTION_WIDESCREEN 0x40
#define GSOPTION_WIREFRAME 0x100
#define GSOPTION_LOADED 0x8000
//Configuration values.
typedef struct
{
u8 mrtdepth; // write color in render target
u8 interlace; // intelacing mode 0, 1, 3-off
u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x, 3 - 8x, 4 - 16x
u8 negaa; // negative aliasing
u8 bilinear; // set to enable bilinear support. 0 - off, 1 -- on, 2 -- force (use for textures that usually need it)
u32 options; // game options -- different hacks.
u32 gamesettings;// default game settings
int width, height; // View target size, has no impact towards speed
bool isWideScreen; // Widescreen support
#ifdef GS_LOG
u32 log;
#endif
} GSconf;
#ifdef __LINUX__
static u32 __attribute__((unused)) lasttime = 0;
static u32 __attribute__((unused)) BigTime = 5000;
static bool __attribute__((unused)) SPAM_PASS;
#else
static u32 lasttime = 0;
static u32 BigTime = 5000;
static bool SPAM_PASS;
#endif
#define ERROR_LOG_SPAM(text) { \
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(text); \
lasttime = timeGetTime(); \
} \
}
// The same macro with one-argument substitution.
#define ERROR_LOG_SPAMA(fmt, value) { \
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(fmt, value); \
lasttime = timeGetTime(); \
} \
}
#define ERROR_LOG_SPAM_TEST(text) {\
if( timeGetTime() - lasttime > BigTime ) { \
ERROR_LOG(text); \
lasttime = timeGetTime(); \
SPAM_PASS = true; \
} \
else \
SPAM_PASS = false; \
}
#if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0))
#define FUNCLOG {\
static bool Was_Here = false; \
static unsigned long int waslasttime = 0; \
if (!Was_Here && FILE_IS_IN_CHECK) { \
Was_Here = true;\
ERROR_LOG("%s:%d %s\n", __FILE__, __LINE__, __func__); \
waslasttime = timeGetTime(); \
} \
if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \
Was_Here = false; \
} \
}
#else
#define FUNCLOG
#endif
#define DEBUG_LOG printf
#ifdef RELEASE_TO_PUBLIC
#define WARN_LOG 0&&
#define PRIM_LOG 0&&
#else
#define WARN_LOG printf
#define PRIM_LOG if (conf.log & 0x00000010) GS_LOG
#endif
#ifndef GREG_LOG
#define GREG_LOG 0&&
#endif
#ifndef PRIM_LOG
#define PRIM_LOG 0&&
#endif
#ifndef WARN_LOG
#define WARN_LOG 0&&
#endif
#define REG64(name) \
union name \
{ \
u64 i64; \
u32 ai32[2]; \
struct { \
#define REG128(name)\
union name \
{ \
u64 ai64[2]; \
u32 ai32[4]; \
struct { \
#define REG64_(prefix, name) REG64(prefix##name)
#define REG128_(prefix, name) REG128(prefix##name)
#define REG_END }; };
#define REG_END2 };
#define REG64_SET(name) \
union name \
{ \
u64 i64; \
u32 ai32[2]; \
#define REG128_SET(name)\
union name \
{ \
u64 ai64[2]; \
u32 ai32[4]; \
#define REG_SET_END };
extern FILE *gsLog;
extern void __Log(const char *fmt, ...);
extern void __LogToConsole(const char *fmt, ...);
extern void LoadConfig();
extern void SaveConfig();
extern void (*GSirq)();
extern void *SysLoadLibrary(char *lib); // Loads Library
extern void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library
extern char *SysLibError(); // Gets previous error loading sysbols
extern void SysCloseLibrary(void *lib); // Closes Library
extern void SysMessage(const char *fmt, ...);
#ifdef __LINUX__
#include "Utilities/MemcpyFast.h"
#define memcpy_amd memcpy_fast
#else
extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
#endif
template <typename T>
class CInterfacePtr
{
public:
inline CInterfacePtr() : ptr(NULL) {}
inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if ( ptr != NULL ) ptr->AddRef(); }
inline ~CInterfacePtr() { if( ptr != NULL ) ptr->Release(); }
inline T* operator* () { assert( ptr != NULL); return *ptr; }
inline T* operator->() { return ptr; }
inline T* get() { return ptr; }
inline void release() {
if( ptr != NULL ) { ptr->Release(); ptr = NULL; }
}
inline operator T*() { return ptr; }
inline bool operator==(T* rhs) { return ptr == rhs; }
inline bool operator!=(T* rhs) { return ptr != rhs; }
inline CInterfacePtr& operator= (T* newptr) {
if( ptr != NULL ) ptr->Release();
ptr = newptr;
if( ptr != NULL ) ptr->AddRef();
return *this;
}
private:
T* ptr;
};
// IMPORTANT: For every Register there must be an End
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
void DVProfEnd(u32 dwUserData);
void DVProfWrite(char* pfilename, u32 frames = 0);
void DVProfClear(); // clears all the profilers
#define DVPROFILE
#ifdef DVPROFILE
class DVProfileFunc
{
public:
u32 dwUserData;
DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
~DVProfileFunc() { DVProfEnd(dwUserData); }
};
#else
class DVProfileFunc
{
public:
u32 dwUserData;
static __forceinline DVProfileFunc(char* pname) {}
static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
~DVProfileFunc() {}
};
#endif
#endif // UTIL_H_INCLUDED

View File

@ -393,6 +393,10 @@
RelativePath="..\GS.h"
>
</File>
<File
RelativePath="..\Util.h"
>
</File>
<File
RelativePath="..\Mem.h"
>