GregMiscellaneous: zzogl-pg: Use some of the routines in the Utilities library instead of the copies in ZZOgl. (Which were basically older versions of the same code.)

git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@4006 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-11-07 05:51:54 +00:00
parent 5c4512c5a9
commit 38c229a350
17 changed files with 52 additions and 83 deletions

View File

@ -546,15 +546,15 @@ typedef struct
GSClut clut_buffer; GSClut clut_buffer;
int primNext(int inc = 1) int primNext(int inc = 1)
{ {
// Note: ARRAY_SIZE(gsvertex) == 2^n => modulo is replaced by an and instruction // Note: ArraySize(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + inc) % ARRAY_SIZE(gsvertex)); return ((primIndex + inc) % ArraySize(gsvertex));
} }
int primPrev(int dec = 1) int primPrev(int dec = 1)
{ {
// Note: assert( dec <= ARRAY_SIZE(gsvertex) ); // Note: assert( dec <= ArraySize(gsvertex) );
// Note: ARRAY_SIZE(gsvertex) == 2^n => modulo is replaced by an and instruction // Note: ArraySize(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + (ARRAY_SIZE(gsvertex) - dec)) % ARRAY_SIZE(gsvertex)); return ((primIndex + (ArraySize(gsvertex) - dec)) % ArraySize(gsvertex));
} }
void setRGBA(u32 r, u32 g, u32 b, u32 a) void setRGBA(u32 r, u32 g, u32 b, u32 a)

View File

@ -536,7 +536,7 @@ void CALLBACK GSvsync(int interlace)
if (--nToNextUpdate <= 0) if (--nToNextUpdate <= 0)
{ {
u32 d = timeGetTime(); u32 d = timeGetTime();
fFPS = UPDATE_FRAMES * 1000.0f / (float)max(d - dwTime, 1); fFPS = UPDATE_FRAMES * 1000.0f / (float)max(d - dwTime, (u32)1);
dwTime = d; dwTime = d;
g_nFrame += UPDATE_FRAMES; g_nFrame += UPDATE_FRAMES;
SetGSTitle(); SetGSTitle();

View File

@ -20,9 +20,9 @@
#ifndef GIFTRANSFER_H_INCLUDED #ifndef GIFTRANSFER_H_INCLUDED
#define GIFTRANSFER_H_INCLUDED #define GIFTRANSFER_H_INCLUDED
#include "Util.h"
#include "GS.h" #include "GS.h"
#include "Regs.h" #include "Regs.h"
#include "Util.h"
enum GIF_FLG enum GIF_FLG
{ {

View File

@ -62,6 +62,7 @@
</Build> </Build>
<Compiler> <Compiler>
<Add option="`pkg-config gtk+-2.0 --cflags`" /> <Add option="`pkg-config gtk+-2.0 --cflags`" />
<Add option="`wx-config --version=2.8 --static=no --unicode=yes --cflags`" />
<Add option="-Wno-format" /> <Add option="-Wno-format" />
<Add option="-Wno-unused-parameter" /> <Add option="-Wno-unused-parameter" />
<Add option="-Wno-unused-value" /> <Add option="-Wno-unused-value" />

View File

@ -60,7 +60,7 @@ struct DVPROFSTRUCT
while (it != listpChild.end()) while (it != listpChild.end())
{ {
SAFE_DELETE(*it); safe_delete(*it);
++it; ++it;
} }
} }

View File

@ -43,7 +43,10 @@ extern HWND GShwnd;
#define GSdefs #define GSdefs
#include "PS2Edefs.h"
//Pcsx2Defs is included in Dependencies.h.
#include "Utilities/Dependencies.h"
#include "CRC.h" #include "CRC.h"
#include "ZZLog.h" #include "ZZLog.h"
@ -55,47 +58,10 @@ extern "C" char* CALLBACK PS2EgetLibName(void);
#include "ZZoglMath.h" #include "ZZoglMath.h"
#include "Profile.h" #include "Profile.h"
#include <vector>
#include <string>
#include <cstring>
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
#include <malloc.h>
// 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 "Utilities/MemcpyFast.h" #include "Utilities/MemcpyFast.h"
#define memcpy_amd memcpy_fast #define memcpy_amd memcpy_fast
#define max(a,b) (((a) > (b)) ? (a) : (b)) extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
#define min(a,b) (((a) < (b)) ? (a) : (b))
typedef struct typedef struct
{ {
@ -273,21 +239,7 @@ union name \
#define REG_SET_END }; #define REG_SET_END };
#ifndef SAFE_DELETE
# define SAFE_DELETE(x) if( (x) != NULL ) { delete (x); (x) = NULL; }
#endif
#ifndef SAFE_DELETE_ARRAY
# define SAFE_DELETE_ARRAY(x) if( (x) != NULL ) { delete[] (x); (x) = NULL; }
#endif
#ifndef SAFE_RELEASE
# define SAFE_RELEASE(x) if( (x) != NULL ) { (x)->Release(); (x) = NULL; }
#endif
#define FORIT(it, v) for(it = (v).begin(); it != (v).end(); ++(it)) #define FORIT(it, v) for(it = (v).begin(); it != (v).end(); ++(it))
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
extern void LoadConfig(); extern void LoadConfig();
extern void SaveConfig(); extern void SaveConfig();

View File

@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "Util.h"
#include "ZZHacks.h" #include "ZZHacks.h"
#include "ZZLog.h" #include "ZZLog.h"

View File

@ -21,6 +21,7 @@
// It draw picture direct on screen, so here we have interlacing and frame skipping. // It draw picture direct on screen, so here we have interlacing and frame skipping.
//------------------ Includes //------------------ Includes
#include "Util.h"
#include "ZZoglCRTC.h" #include "ZZoglCRTC.h"
#include "GLWin.h" #include "GLWin.h"
#include "ZZoglShaders.h" #include "ZZoglShaders.h"
@ -814,13 +815,13 @@ inline void AfterRendererAutoresetTargets()
if (conf.settings().auto_reset) if (conf.settings().auto_reset)
{ {
s_nResolveCounts[s_nCurResolveIndex] = s_nResolved; s_nResolveCounts[s_nCurResolveIndex] = s_nResolved;
s_nCurResolveIndex = (s_nCurResolveIndex + 1) % ARRAY_SIZE(s_nResolveCounts); s_nCurResolveIndex = (s_nCurResolveIndex + 1) % ArraySize(s_nResolveCounts);
int total = 0; int total = 0;
for (int i = 0; i < ARRAY_SIZE(s_nResolveCounts); ++i) total += s_nResolveCounts[i]; for (int i = 0; i < ArraySize(s_nResolveCounts); ++i) total += s_nResolveCounts[i];
if (total / ARRAY_SIZE(s_nResolveCounts) > 3) if (total / ArraySize(s_nResolveCounts) > 3)
{ {
if (s_nLastResolveReset > (int)(fFPS * 8)) if (s_nLastResolveReset > (int)(fFPS * 8))
{ {

View File

@ -329,7 +329,7 @@ inline bool CreateOpenShadersFile()
// test if ps2hw.fx exists // test if ps2hw.fx exists
char tempstr[255]; char tempstr[255];
char curwd[255]; char curwd[255];
getcwd(curwd, ARRAY_SIZE(curwd)); getcwd(curwd, ArraySize(curwd));
strcpy(tempstr, "/plugins/"); strcpy(tempstr, "/plugins/");
sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr); sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr);
@ -798,7 +798,7 @@ void ZZDestroy()
if (pvs != NULL) if (pvs != NULL)
{ {
for (int i = 0; i < ARRAY_SIZE(pvs); ++i) for (int i = 0; i < ArraySize(pvs); ++i)
{ {
SAFE_RELEASE_PROG(pvs[i]); SAFE_RELEASE_PROG(pvs[i]);
} }
@ -806,7 +806,7 @@ void ZZDestroy()
if (ppsRegular != NULL) if (ppsRegular != NULL)
{ {
for (int i = 0; i < ARRAY_SIZE(ppsRegular); ++i) for (int i = 0; i < ArraySize(ppsRegular); ++i)
{ {
SAFE_RELEASE_PROG(ppsRegular[i].prog); SAFE_RELEASE_PROG(ppsRegular[i].prog);
} }
@ -814,7 +814,7 @@ void ZZDestroy()
if (ppsTexture != NULL) if (ppsTexture != NULL)
{ {
for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) for (int i = 0; i < ArraySize(ppsTexture); ++i)
{ {
SAFE_RELEASE_PROG(ppsTexture[i].prog); SAFE_RELEASE_PROG(ppsTexture[i].prog);
} }
@ -833,7 +833,7 @@ void ZZDestroy()
SAFE_RELEASE_PROG(ppsCRTC24[1].prog); SAFE_RELEASE_PROG(ppsCRTC24[1].prog);
SAFE_RELEASE_PROG(ppsOne.prog); SAFE_RELEASE_PROG(ppsOne.prog);
SAFE_DELETE(font_p); safe_delete(font_p);
GLWin.ReleaseContext(); GLWin.ReleaseContext();

View File

@ -304,7 +304,7 @@ void ReloadEffects()
{ {
#ifdef ZEROGS_DEVBUILD #ifdef ZEROGS_DEVBUILD
for (int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) for (int i = 0; i < ArraySize(ppsTexture); ++i)
{ {
SAFE_RELEASE_PROG(ppsTexture[i].prog); SAFE_RELEASE_PROG(ppsTexture[i].prog);
} }
@ -2015,15 +2015,6 @@ void SetTexClamping(int context, FRAGMENTSHADER* pfragment)
} }
// Fixme should be in float4 lib
inline bool equal_vectors(float4 a, float4 b)
{
if (abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z) + abs(a.w - b.w) < 0.01)
return true;
else
return false;
}
int CheckTexArray[4][2][2][2] = {{{{0, }}}}; int CheckTexArray[4][2][2][2] = {{{{0, }}}};
void SetTexVariables(int context, FRAGMENTSHADER* pfragment) void SetTexVariables(int context, FRAGMENTSHADER* pfragment)
{ {

View File

@ -195,6 +195,15 @@ class Vector4
y = ((color >> 8) & 0xff) / 255.0f; y = ((color >> 8) & 0xff) / 255.0f;
z = ((color >> 16) & 0xff) / 255.0f; z = ((color >> 16) & 0xff) / 255.0f;
} }
bool equal_vectors(const Vector4<T>& v)
{
if (abs(x - v.x) + abs(y - v.y) + abs(z - v.z) + abs(w - v.w) < 0.01)
return true;
else
return false;
}
}; };
typedef Vector4<float> float4; typedef Vector4<float> float4;
@ -444,6 +453,14 @@ class float4
return float4(_mm_cmple_ps(v1.m, v2.m)); return float4(_mm_cmple_ps(v1.m, v2.m));
} }
bool equal_vectors(const float4& v)
{
if (abs(x - v.x) + abs(y - v.y) + abs(z - v.z) + abs(w - v.w) < 0.01)
return true;
else
return false;
}
// This looked interesting, so I thought I'd include it... // This looked interesting, so I thought I'd include it...
template<int i> float4 shuffle() const template<int i> float4 shuffle() const

View File

@ -20,6 +20,7 @@
// Save and Load. // Save and Load.
//------------------ Includes //------------------ Includes
#include "Util.h"
#include "ZZoglVB.h" #include "ZZoglVB.h"
extern void ZZGSStateReset(); extern void ZZGSStateReset();

View File

@ -21,6 +21,7 @@
// ZZogl Shader manipulation functions. // ZZogl Shader manipulation functions.
//------------------- Includes //------------------- Includes
#include "Util.h"
#include "ZZoglShaders.h" #include "ZZoglShaders.h"
#include "zpipe.h" #include "zpipe.h"
#include <math.h> #include <math.h>
@ -227,7 +228,7 @@ bool ZZshCreateOpenShadersFile() {
// test if ps2hw.fx exists // test if ps2hw.fx exists
char tempstr[255]; char tempstr[255];
char curwd[255]; char curwd[255];
getcwd(curwd, ARRAY_SIZE(curwd)); getcwd(curwd, ArraySize(curwd));
strcpy(tempstr, "/plugins/"); strcpy(tempstr, "/plugins/");
sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr); sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr);
@ -538,7 +539,7 @@ inline bool LoadEffects()
} }
// clear the textures // clear the textures
for(u16 i = 0; i < ARRAY_SIZE(ppsTexture); ++i) { for(u16 i = 0; i < ArraySize(ppsTexture); ++i) {
SAFE_RELEASE_PROG(ppsTexture[i].prog); SAFE_RELEASE_PROG(ppsTexture[i].prog);
ppsTexture[i].prog = NULL; ppsTexture[i].prog = NULL;
} }
@ -645,7 +646,7 @@ FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testae
int index = GET_SHADER_INDEX(type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, context, 0); int index = GET_SHADER_INDEX(type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, context, 0);
assert( index < ARRAY_SIZE(ppsTexture) ); assert( index < ArraySize(ppsTexture) );
FRAGMENTSHADER* pf = ppsTexture+index; FRAGMENTSHADER* pf = ppsTexture+index;
if( pbFailed != NULL ) *pbFailed = false; if( pbFailed != NULL ) *pbFailed = false;
@ -722,7 +723,7 @@ FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testae
inline bool LoadEffects() inline bool LoadEffects()
{ {
// clear the textures // clear the textures
for(int i = 0; i < ARRAY_SIZE(ppsTexture); ++i) { for(int i = 0; i < ArraySize(ppsTexture); ++i) {
SAFE_RELEASE_PROG(ppsTexture[i].prog); SAFE_RELEASE_PROG(ppsTexture[i].prog);
} }

View File

@ -20,6 +20,7 @@
// Texture and avi saving to file functions // Texture and avi saving to file functions
//------------------ Includes //------------------ Includes
#include "Util.h"
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
# include <aviUtil.h> # include <aviUtil.h>

View File

@ -21,6 +21,7 @@
// VB stands for Visual Buffer, as I think // VB stands for Visual Buffer, as I think
//------------------- Includes //------------------- Includes
#include "Util.h"
#include "targets.h" #include "targets.h"
#include "ZZoglVB.h" #include "ZZoglVB.h"
#include "GS.h" #include "GS.h"

View File

@ -1992,6 +1992,7 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc
else { else {
// In case it could occured // In case it could occured
// realloc would be better but you need to get it from libutilies first // realloc would be better but you need to get it from libutilies first
// _aligned_realloc is brought in from ScopedAlloc.h now. --arcum42
_aligned_free(targ->clut); _aligned_free(targ->clut);
targ->clut = (u8*)_aligned_malloc(clutsize, 16); targ->clut = (u8*)_aligned_malloc(clutsize, 16);
} }

View File

@ -18,6 +18,7 @@
*/ */
//-------------------------- Includes //-------------------------- Includes
#include "Util.h"
#include "zerogs.h" #include "zerogs.h"
#include "ZZoglVB.h" #include "ZZoglVB.h"