GregMiscellaneous: zzogl-pg: Shuffle more stuff around from zerogs.h.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3927 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-10-17 08:47:31 +00:00
parent 74113b1eeb
commit bce1dfbade
15 changed files with 143 additions and 166 deletions

View File

@ -912,6 +912,21 @@ inline bool ZZOglClutStorageUnchanged(const u32* oldtex, const u32* newtex)
return ((oldtex[1] & 0x1ff10000) == (newtex[1] & 0x1ff10000));
}
// call to load CLUT data (depending on CLD)
void texClutWrite(int ctx);
// Perform clutting for flushed texture. Better check if it needs a prior call.
inline void CluttingForFlushedTex(tex0Info* tex0, u32 Data, int ictx)
{
tex0->cbp = ZZOglGet_cbp_TexBits(Data);
tex0->cpsm = ZZOglGet_cpsm_TexBits(Data);
tex0->csm = ZZOglGet_csm_TexBits(Data);
tex0->csa = ZZOglGet_csa_TexBits(Data);
tex0->cld = ZZOglGet_cld_TexBits(Data);
texClutWrite(ictx);
};
// CSA and CPSM bitmask 0001 1111 0111 1000 ...
// 60 56 52
#define CPSM_CSA_BITMASK 0x1f780000

View File

@ -38,7 +38,6 @@ using namespace std;
#include "targets.h"
#include "ZZoglShaders.h"
#include "ZZoglFlushHack.h"
#include "ZZoglFlushHack.h"
#ifdef _MSC_VER
#pragma warning(disable:4244)

View File

@ -19,9 +19,44 @@
#include <stdio.h>
#include "ZZLog.h"
#include <list>
#include <cstring>
extern GSconf conf;
using namespace std;
static list<MESSAGE> listMsgs;
void ProcessMessages()
{
FUNCLOG
if (listMsgs.size() > 0)
{
int left = 25, top = 15;
list<MESSAGE>::iterator it = listMsgs.begin();
while (it != listMsgs.end())
{
DrawText(it->str, left + 1, top + 1, 0xff000000);
DrawText(it->str, left, top, 0xffffff30);
top += 15;
if ((int)(it->dwTimeStamp - timeGetTime()) < 0)
it = listMsgs.erase(it);
else ++it;
}
}
}
void ZZAddMessage(const char* pstr, u32 ms)
{
FUNCLOG
listMsgs.push_back(MESSAGE(pstr, timeGetTime() + ms));
ZZLog::Log("%s\n", pstr);
}
namespace ZZLog
{
std::string s_strLogPath("logs/");

View File

@ -21,7 +21,7 @@
#define ZZLOG_H_INCLUDED
#include "Util.h"
#include <cstring>
//Logging for errors that are called often should have a time counter.
#ifdef __LINUX__
@ -154,9 +154,20 @@ inline const char *error_name(int err)
}
}
struct MESSAGE
{
MESSAGE() {}
MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; }
char str[255];
u32 dwTimeStamp;
};
extern void DrawText(const char* pstr, int left, int top, u32 color);
extern void __LogToConsole(const char *fmt, ...);
extern void ZZAddMessage(const char* pstr, u32 ms);
extern void ZZAddMessage(const char* pstr, u32 ms = 5000);
extern void SetAA(int mode);
extern bool ZZCreate(int width, int height);
extern void ZZDestroy(bool bD3D);

View File

@ -24,6 +24,7 @@
#include "ZZoglCRTC.h"
#include "GLWin.h"
#include "ZZoglShaders.h"
#include "rasterfont.h" // simple font
//------------------ Defines
#if !defined(ZEROGS_DEVBUILD)
@ -137,9 +138,6 @@ inline void FrameSavingHelper()
}
#endif
}
// g_SaveFrameNum = 0;
// g_bSaveFlushedFrame = 1;
}
// Function populated tex0Info[2] array
@ -179,17 +177,6 @@ inline void FrameObtainDispinfo(u32 bInterlace, tex0Info* dispinfo)
// Something should be done before Renderering the picture.
inline void RenderStartHelper(u32 bInterlace)
{
// Crashes Final Fantasy X at startup if uncommented. --arcum42
//#ifdef !defined(ZEROGS_DEVBUILD)
// if(g_nRealFrame < 80 ) {
// RenderCustom( min(1.0f, 2.0f - (float)g_nRealFrame / 40.0f) );
//
// if( g_nRealFrame == 79 )
// SAFE_RELEASE_TEX(ptexLogo);
// return;
// }
//#endif
if (conf.mrtdepth && pvs[8] == NULL)
{
conf.mrtdepth = 0;
@ -632,6 +619,21 @@ inline void RenderCheckForMemory(tex0Info& texframe, list<CRenderTarget*>& listT
DrawTriangleArray();
}
extern RasterFont* font_p;
void DrawText(const char* pstr, int left, int top, u32 color)
{
FUNCLOG
ZZshGLDisableProfile();
float4 v;
v.SetColor(color);
glColor3f(v.z, v.y, v.x);
font_p->printString(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight, 0);
ZZshGLEnableProfile();
}
// Put FPS counter on screen (not in window title)
inline void AfterRenderDisplayFPS()
{
@ -741,6 +743,8 @@ inline void AfterRendererUnimportantJob()
maxmin = 608;
}
extern u32 s_uFramebuffer;
// Swich Framebuffers
inline void AfterRendererSwitchBackToTextures()
{

View File

@ -36,7 +36,6 @@ extern int s_frameskipping;
extern float fFPS;
extern unsigned char zgsrevision, zgsbuild, zgsminor;
//extern u32 g_SaveFrameNum;
extern int s_nWriteDepthCount;
extern int s_nWireframeCount;
extern int s_nWriteDestAlphaTest;

View File

@ -27,6 +27,9 @@
#include "ZZoglShaders.h"
#include "targets.h"
#include "rasterfont.h" // simple font
// This include for windows resource file with Shaders
#ifdef _WIN32
# include "Win32.h"
@ -159,7 +162,6 @@ u32 ptexBlocks = 0, ptexConv16to32 = 0; // holds information on block tiling
u32 ptexBilinearBlocks = 0;
u32 ptexConv32to16 = 0;
int g_nDepthBias = 0;
//u32 g_bSaveFlushedFrame = 0;
//------------------ Code
@ -773,8 +775,6 @@ bool ZZCreate(int _width, int _height)
vb[0].Init(VB_BUFFERSIZE);
vb[1].Init(VB_BUFFERSIZE);
// g_bSaveFlushedFrame = 1;
g_vsprog = g_psprog = 0;
if (glGetError() == GL_NO_ERROR)

View File

@ -120,7 +120,6 @@ void Draw(const VB& curvb)
extern int g_nDepthBias;
extern float g_fBlockMult; // used for old cards, that do not support Alpha-32float textures. We store block data in u16 and use it.
bool g_bUpdateStencil = 1;
//u32 g_SaveFrameNum = 0; // ZZ
extern ZZshProgram g_psprog; // 2 -- ZZ
@ -216,6 +215,8 @@ inline void ProcessStencil(const VB& curvb);
inline void RenderFBA(const VB& curvb, ZZshParameter sOneColor);
inline void ProcessFBA(const VB& curvb, ZZshParameter sOneColor); // zz
void SetContextTarget(int context);
//------------------ Code
inline float AlphaReferedValue(int aref)
@ -271,6 +272,8 @@ inline void SwitchWireframeOn()
}
}
extern u32 ptexBilinearBlocks;
int GetTexFilter(const tex1Info& tex1)
{
// always force
@ -336,7 +339,6 @@ inline void VisualBufferMessage(int context)
ZZLog::Error_Log("TGA name '%s'.", Name);
free(Name);
// }
// ZZLog::Debug_Log("frame: %d, buffer %ld.\n", g_SaveFrameNum, BufferNumber);
ZZLog::Debug_Log("buffer %ld.\n", BufferNumber);
#endif
}
@ -345,12 +347,10 @@ inline void SaveRendererTarget(VB& curvb)
{
#ifdef _DEBUG
// if (g_bSaveFlushedFrame & 0x80000000)
// {
// Needs a # after rndr to work...
// char str[255];
// sprintf(str, "rndr%d.tga", g_SaveFrameNum);
// sprintf(str, "rndr.tga");
// SaveRenderTarget(str, curvb.prndr->fbw, curvb.prndr->fbh, 0);
// }
#endif
}
@ -1439,7 +1439,6 @@ inline void AlphaSaveTarget(VB& curvb)
#ifdef _DEBUG
return; // Do nothing
// if( g_bSaveFlushedFrame & 0xf ) {
//#ifdef _WIN32
// CreateDirectory("frames", NULL);
//#else
@ -1448,13 +1447,14 @@ inline void AlphaSaveTarget(VB& curvb)
// system(strdir);
//#endif
// char str[255];
// sprintf(str, "frames/frame%.4d.tga", g_SaveFrameNum++);
// Needs a # after frame to work properly.
// sprintf(str, "frames/frame.tga");
// //glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
// //glFlush();
// //SaveTexture("tex.jpg", GL_TEXTURE_RECTANGLE_NV, curvb.prndr->ptex, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh));
// SaveRenderTarget(str, RW(curvb.prndr->fbw), RH(curvb.prndr->fbh), 0);
// }
#endif
}

View File

@ -85,6 +85,8 @@ int ZZSave(s8* pbydata)
return 0;
}
extern u32 s_uFramebuffer;
bool ZZLoad(s8* pbydata)
{
memset(s_uTex1Data, 0, sizeof(s_uTex1Data));

View File

@ -66,6 +66,9 @@ extern HINSTANCE hInst;
//------------------ Constants
// Used in a logarithmic Z-test, as (1-o(1))/log(MAX_U32).
const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
const static char* g_pTexTypes[] = { "32", "tex32", "clut32", "tex32to16", "tex16to8h" };
// ----------------- Global Variables
@ -85,14 +88,19 @@ char* EFFECT_DIR;
bool g_bCRTCBilinear = true;
float4 g_vdepth, vlogz;
FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne;
FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
FRAGMENTSHADER ppsCRTC[2], ppsCRTC24[2], ppsCRTCTarg[2];
VERTEXSHADER pvsBitBlt;
float4 g_vdepth, vlogz;
FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne;
FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
FRAGMENTSHADER ppsCRTC[2], ppsCRTC24[2], ppsCRTCTarg[2];
VERTEXSHADER pvsBitBlt;
inline bool LoadEffects();
extern u32 ptexBlocks; // holds information on block tiling. It's texture number in OpenGL -- if 0 than such texture
extern u32 ptexConv16to32; // does not exists. This textures should be created on start and released on finish.
extern u32 ptexBilinearBlocks;
extern u32 ptexConv32to16;
inline bool LoadEffects();
struct SHADERHEADER
{

View File

@ -354,6 +354,8 @@ inline void VB::CheckFrame16vs32Conversion()
}
}
void SetContextTarget(int context);
// A lot of times, the target is too big and overwrites the texture.
// If tbp != 0, use it to bound.
void VB::CheckFrame(int tbp)

View File

@ -30,6 +30,7 @@
#include <emmintrin.h>
#endif
const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
#define RHA
//#define RW

View File

@ -29,6 +29,12 @@
#define VB_BUFFERSIZE 0x400
// all textures have this width
extern int GPU_TEXWIDTH;
extern float g_fiGPU_TEXWIDTH;
#define MASKDIVISOR 0 // Used for decrement bitwise mask texture size if 1024 is too big
#define GPU_TEXMASKWIDTH (1024 >> MASKDIVISOR) // bitwise mask width for region repeat mode
// managers render-to-texture targets
class CRenderTarget
{
@ -694,4 +700,21 @@ static __forceinline void setRectWrap2(GLint type)
// VB variables
extern VB vb[2];
//------------------------ Inlines -------------------------
// Calculate maximum height for target
inline int get_maxheight(int fbp, int fbw, int psm)
{
int ret;
if (fbw == 0) return 0;
ret = (((0x00100000 - 64 * fbp) / fbw) & ~0x1f);
if (PSMT_ISHALF(psm)) ret *= 2;
return ret;
}
#endif

View File

@ -95,27 +95,12 @@ int nBackbufferWidth, nBackbufferHeight; // ZZ
extern CRangeManager s_RangeMngr; // manages overwritten memory
// returns the first and last addresses aligned to a page that cover
void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h, int bp, int bw);
int s_nNewWidth = -1, s_nNewHeight = -1;
void ChangeDeviceSize(int nNewWidth, int nNewHeight);
void ProcessMessages();
void RenderCustom(float fAlpha); // intro anim
struct MESSAGE
{
MESSAGE() {}
MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; }
char str[255];
u32 dwTimeStamp;
};
static list<MESSAGE> listMsgs;
///////////////////////
// Method Prototypes //
///////////////////////
@ -320,28 +305,6 @@ void ZZGSSoftReset(u32 mask)
gs.nTriFanVert = -1;
}
void ZZAddMessage(const char* pstr, u32 ms)
{
FUNCLOG
listMsgs.push_back(MESSAGE(pstr, timeGetTime() + ms));
ZZLog::Log("%s\n", pstr);
}
extern RasterFont* font_p;
void DrawText(const char* pstr, int left, int top, u32 color)
{
FUNCLOG
ZZshGLDisableProfile();
float4 v;
v.SetColor(color);
glColor3f(v.z, v.y, v.x);
//glColor3f(((color >> 16) & 0xff) / 255.0f, ((color >> 8) & 0xff)/ 255.0f, (color & 0xff) / 255.0f);
font_p->printString(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight, 0);
ZZshGLEnableProfile();
}
void ChangeWindowSize(int nNewWidth, int nNewHeight)
{
FUNCLOG
@ -443,27 +406,8 @@ void Prim()
curvb.curprim.prim = prim->prim;
}
void ProcessMessages()
{
FUNCLOG
if (listMsgs.size() > 0)
{
int left = 25, top = 15;
list<MESSAGE>::iterator it = listMsgs.begin();
while (it != listMsgs.end())
{
DrawText(it->str, left + 1, top + 1, 0xff000000);
DrawText(it->str, left, top, 0xffffff30);
top += 15;
if ((int)(it->dwTimeStamp - timeGetTime()) < 0)
it = listMsgs.erase(it);
else ++it;
}
}
}
extern u32 ptexLogo;
extern int nLogoWidth, nLogoHeight;
void RenderCustom(float fAlpha)
{

View File

@ -34,52 +34,13 @@
#include "ZZGl.h"
#include "GS.h"
#include "CRC.h"
#include "rasterfont.h" // simple font
#include "targets.h"
using namespace std;
//------------------------ Constants ----------------------
// Used in a logarithmic Z-test, as (1-o(1))/log(MAX_U32).
const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
//------------------------ Inlines -------------------------
// Calculate maximum height for target
inline int get_maxheight(int fbp, int fbw, int psm)
{
int ret;
if (fbw == 0) return 0;
ret = (((0x00100000 - 64 * fbp) / fbw) & ~0x1f);
if (PSMT_ISHALF(psm)) ret *= 2;
return ret;
}
// ------------------------ Variables -------------------------
// all textures have this width
extern int GPU_TEXWIDTH;
extern float g_fiGPU_TEXWIDTH;
#define MASKDIVISOR 0 // Used for decrement bitwise mask texture size if 1024 is too big
#define GPU_TEXMASKWIDTH (1024 >> MASKDIVISOR) // bitwise mask width for region repeat mode
extern u32 ptexBlocks; // holds information on block tiling. It's texture number in OpenGL -- if 0 than such texture
extern u32 ptexConv16to32; // does not exists. This textures should be created on start and released on finish.
extern u32 ptexBilinearBlocks;
extern u32 ptexConv32to16;
// this is currently *not* used as a bool, in spite of its moniker --air
// Actually, the only thing written to it is 1 or 0, which makes the (g_bSaveFlushedFrame & 0x80000000) check rather bizzare.
//extern u32 g_bSaveFlushedFrame;
//////////////////////////
// State parameters
#ifdef ZEROGS_DEVBUILD
extern char* EFFECT_NAME;
extern char* EFFECT_DIR;
@ -87,18 +48,14 @@ extern u32 g_nGenVars, g_nTexVars, g_nAlphaVars, g_nResolve;
extern bool g_bSaveTrans, g_bUpdateEffect, g_bSaveTex, g_bSaveResolved;
#endif
extern u32 s_uFramebuffer;
extern int g_nPixelShaderVer;
extern bool s_bWriteDepth;
extern u32 ptexLogo;
extern int nLogoWidth, nLogoHeight;
extern int nBackbufferWidth, nBackbufferHeight;
typedef void (*DrawFn)();
// visible members
typedef void (*DrawFn)();
extern DrawFn drawfn[8];
extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height
@ -106,8 +63,6 @@ extern vector<GLuint> g_vboBuffers; // VBOs for all drawing commands
extern GLuint vboRect;
extern int g_nCurVBOIndex;
void ZZAddMessage(const char* pstr, u32 ms = 5000);
void DrawText(const char* pstr, int left, int top, u32 color);
void ChangeWindowSize(int nNewWidth, int nNewHeight);
void SetChangeDeviceSize(int nNewWidth, int nNewHeight);
void ChangeDeviceSize(int nNewWidth, int nNewHeight);
@ -166,9 +121,6 @@ void ResetRenderTarget(int index);
bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op
// call to load CLUT data (depending on CLD)
void texClutWrite(int ctx);
int ZZSave(s8* pbydata);
bool ZZLoad(s8* pbydata);
@ -187,12 +139,6 @@ void _Resolve(const void* psrc, int fbp, int fbw, int fbh, int psm, u32 fbm, boo
// returns the first and last addresses aligned to a page that cover
void GetRectMemAddress(int& start, int& end, int psm, int x, int y, int w, int h, int bp, int bw);
// inits the smallest rectangle in ptexMem that covers this region in ptexMem
// returns the offset that needs to be added to the locked rect to get the beginning of the buffer
//void GetMemRect(RECT& rc, int psm, int x, int y, int w, int h, int bp, int bw);
void SetContextTarget(int context) ;
void NeedFactor(int w);
void ResetAlphaVariables();
@ -200,18 +146,6 @@ void StartCapture();
void StopCapture();
void CaptureFrame();
// Perform clutting for flushed texture. Better check if it needs a prior call.
inline void CluttingForFlushedTex(tex0Info* tex0, u32 Data, int ictx)
{
tex0->cbp = ZZOglGet_cbp_TexBits(Data);
tex0->cpsm = ZZOglGet_cpsm_TexBits(Data);
tex0->csm = ZZOglGet_csm_TexBits(Data);
tex0->csa = ZZOglGet_csa_TexBits(Data);
tex0->cld = ZZOglGet_cld_TexBits(Data);
texClutWrite(ictx);
};
// The size in bytes of x strings (of texture).
inline int MemorySize(int x)
{