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;
int primNext(int inc = 1)
{
// Note: ARRAY_SIZE(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + inc) % ARRAY_SIZE(gsvertex));
// Note: ArraySize(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + inc) % ArraySize(gsvertex));
}
int primPrev(int dec = 1)
{
// Note: assert( dec <= ARRAY_SIZE(gsvertex) );
// Note: ARRAY_SIZE(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + (ARRAY_SIZE(gsvertex) - dec)) % ARRAY_SIZE(gsvertex));
// Note: assert( dec <= ArraySize(gsvertex) );
// Note: ArraySize(gsvertex) == 2^n => modulo is replaced by an and instruction
return ((primIndex + (ArraySize(gsvertex) - dec)) % ArraySize(gsvertex));
}
void setRGBA(u32 r, u32 g, u32 b, u32 a)

View File

@ -536,7 +536,7 @@ void CALLBACK GSvsync(int interlace)
if (--nToNextUpdate <= 0)
{
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;
g_nFrame += UPDATE_FRAMES;
SetGSTitle();

View File

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

View File

@ -62,6 +62,7 @@
</Build>
<Compiler>
<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-unused-parameter" />
<Add option="-Wno-unused-value" />

View File

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

View File

@ -43,7 +43,10 @@ extern HWND GShwnd;
#define GSdefs
#include "PS2Edefs.h"
//Pcsx2Defs is included in Dependencies.h.
#include "Utilities/Dependencies.h"
#include "CRC.h"
#include "ZZLog.h"
@ -55,47 +58,10 @@ extern "C" char* CALLBACK PS2EgetLibName(void);
#include "ZZoglMath.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"
#define memcpy_amd memcpy_fast
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
typedef struct
{
@ -273,21 +239,7 @@ union name \
#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))
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
extern void LoadConfig();
extern void SaveConfig();

View File

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

View File

@ -21,6 +21,7 @@
// It draw picture direct on screen, so here we have interlacing and frame skipping.
//------------------ Includes
#include "Util.h"
#include "ZZoglCRTC.h"
#include "GLWin.h"
#include "ZZoglShaders.h"
@ -814,13 +815,13 @@ inline void AfterRendererAutoresetTargets()
if (conf.settings().auto_reset)
{
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;
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))
{

View File

@ -329,7 +329,7 @@ inline bool CreateOpenShadersFile()
// test if ps2hw.fx exists
char tempstr[255];
char curwd[255];
getcwd(curwd, ARRAY_SIZE(curwd));
getcwd(curwd, ArraySize(curwd));
strcpy(tempstr, "/plugins/");
sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr);
@ -798,7 +798,7 @@ void ZZDestroy()
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]);
}
@ -806,7 +806,7 @@ void ZZDestroy()
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);
}
@ -814,7 +814,7 @@ void ZZDestroy()
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);
}
@ -833,7 +833,7 @@ void ZZDestroy()
SAFE_RELEASE_PROG(ppsCRTC24[1].prog);
SAFE_RELEASE_PROG(ppsOne.prog);
SAFE_DELETE(font_p);
safe_delete(font_p);
GLWin.ReleaseContext();

View File

@ -304,7 +304,7 @@ void ReloadEffects()
{
#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);
}
@ -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, }}}};
void SetTexVariables(int context, FRAGMENTSHADER* pfragment)
{

View File

@ -195,6 +195,15 @@ class Vector4
y = ((color >> 8) & 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;
@ -444,6 +453,14 @@ class float4
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...
template<int i> float4 shuffle() const

View File

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

View File

@ -21,6 +21,7 @@
// ZZogl Shader manipulation functions.
//------------------- Includes
#include "Util.h"
#include "ZZoglShaders.h"
#include "zpipe.h"
#include <math.h>
@ -227,7 +228,7 @@ bool ZZshCreateOpenShadersFile() {
// test if ps2hw.fx exists
char tempstr[255];
char curwd[255];
getcwd(curwd, ARRAY_SIZE(curwd));
getcwd(curwd, ArraySize(curwd));
strcpy(tempstr, "/plugins/");
sprintf(EFFECT_NAME, "%sps2hw.fx", tempstr);
@ -538,7 +539,7 @@ inline bool LoadEffects()
}
// 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);
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);
assert( index < ARRAY_SIZE(ppsTexture) );
assert( index < ArraySize(ppsTexture) );
FRAGMENTSHADER* pf = ppsTexture+index;
if( pbFailed != NULL ) *pbFailed = false;
@ -722,7 +723,7 @@ FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testae
inline bool LoadEffects()
{
// 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);
}

View File

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

View File

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

View File

@ -1992,6 +1992,7 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc
else {
// In case it could occured
// 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);
targ->clut = (u8*)_aligned_malloc(clutsize, 16);
}

View File

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