zzogl-pg: Start reworking the way logging works.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2899 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-04-25 07:21:29 +00:00
parent 92a8baab56
commit 0ccd832efe
12 changed files with 266 additions and 93 deletions

View File

@ -134,35 +134,165 @@ bool THR_bShift = false;
#endif
void __Log(const char *fmt, ...)
namespace ZZLog
{
va_list list;
bool IsLogging()
{
// gsLog can be null if the config dialog is used prior to Pcsx2 starting an emulation session.
// (GSinit won't have been called then)
return (gsLog != NULL && conf.log);
}
void _Message(const char *str)
{
SysMessage(str);
}
// gsLog can be null if the config dialog is used prior to Pcsx2 an emulation session.
// (GSinit won't have been called then)
void _Log(const char *str)
{
if (IsLogging()) fprintf(gsLog, str);
}
if (gsLog == NULL || !conf.log) return;
void _WriteToConsole(const char *str)
{
printf("ZZogl-PG: %s", str);
}
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
va_end(list);
}
void _Print(const char *str)
{
printf("ZZogl-PG: %s", str);
if (IsLogging()) fprintf(gsLog, str);
}
void Message(const char *fmt, ...)
{
va_list list;
char tmp[512];
void __LogToConsole(const char *fmt, ...) {
va_list list;
va_start(list, fmt);
vsprintf(tmp, fmt, list);
va_end(list);
SysMessage(tmp);
}
va_start(list, 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.
// (GSinit won't have been called then)
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
}
if( gsLog != NULL )
vfprintf(gsLog, fmt, list);
void WriteToConsole(const char *fmt, ...)
{
va_list list;
printf("ZZogl: ");
vprintf(fmt, list);
va_end(list);
}
va_start(list, fmt);
printf("ZZogl-PG: ");
vprintf(fmt, list);
va_end(list);
}
void Print(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG: ");
vprintf(fmt, list);
va_end(list);
}
void Greg_Log(const char *fmt, ...)
{
// Not currently used
#if 0
va_list list;
char tmp[512];
va_start(list, fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
va_end(list);
#endif
}
void Prim_Log(const char *fmt, ...)
{
#if ZEROGS_DEVBUILD
va_list list;
char tmp[512];
va_start(list, fmt);
if (conf.log /*& 0x00000010*/)
{
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG(PRIM): ");
vprintf(fmt, list);
}
va_end(list);
#endif
}
void GS_Log(const char *fmt, ...)
{
#if ZEROGS_DEVBUILD
va_list list;
va_start(list,fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG(GS): ");
vprintf(fmt,list);
va_end(list);
#endif
}
void Warn_Log(const char *fmt, ...)
{
#if ZEROGS_DEVBUILD
va_list list;
va_start(list,fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG(Warning): ");
vprintf(fmt, list);
va_end(list);
#endif
}
void Debug_Log(const char *fmt, ...)
{
#if _DEBUG
va_list list;
va_start(list,fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG(Debug): ");
vprintf(fmt, list);
va_end(list);
#endif
}
void Error_Log(const char *fmt, ...)
{
va_list list;
va_start(list,fmt);
if (IsLogging()) vfprintf(gsLog, fmt, list);
printf("ZZogl-PG(Error): ");
vprintf(fmt,list);
va_end(list);
}
};
void CALLBACK GSsetBaseMem(void* pmem) {
g_pBasePS2Mem = (u8*)pmem;
@ -688,7 +818,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
GLWin.CreateWindow(pDsp);
ERROR_LOG("Using %s:%d.%d.%d\n", libraryName, zgsrevision, zgsbuild, zgsminor);
ERROR_LOG("creating zerogs\n");
ERROR_LOG("Creating zerogs\n");
//if (conf.record) recOpen();
if (!ZeroGS::Create(conf.width, conf.height)) return -1;
@ -834,7 +964,7 @@ void CALLBACK GSvsync(int interlace)
{
FUNCLOG
GS_LOG("\nGSvsync\n\n");
//GS_LOG("GSvsync\n");
static u32 dwTime = timeGetTime();
static int nToNextUpdate = 1;

View File

@ -74,7 +74,7 @@ extern HANDLE g_hCurrentThread;
__forceinline void gifTransferLog(int index, u32 *pMem, u32 size)
{
#ifdef _DEBUG
if( conf.log & 0x20 )
if( conf.log /*& 0x20*/ )
{
static int nSaveIndex = 0;
GS_LOG("%d: p:%d %x\n", nSaveIndex++, index + 1, size);

View File

@ -41,6 +41,9 @@ void SaveConfig()
fprintf(f, "bilinear = %hhx\n", conf.bilinear);
fprintf(f, "aliasing = %hhx\n", conf.aa);
fprintf(f, "gamesettings = %x\n", conf.gamesettings); //u32
fprintf(f, "width = %x\n", conf.width); //u32
fprintf(f, "height = %x\n", conf.height); //u32
fprintf(f, "log = %x\n", conf.log); //u32
fclose(f);
}
@ -55,6 +58,7 @@ void LoadConfig()
conf.width = 640;
conf.height = 480;
conf.aa = 0;
conf.log = 1;
const std::string iniFile( s_strIniPath + "zzogl-pg.ini" );
FILE* f = fopen(iniFile.c_str(), "r");
@ -70,6 +74,9 @@ void LoadConfig()
err = fscanf(f, "bilinear = %hhx\n", &conf.bilinear);
err = fscanf(f, "aliasing = %hhx\n", &conf.aa);
err = fscanf(f, "gamesettings = %x\n", &conf.gamesettings);//u32
err = fscanf(f, "width = %x\n", &conf.width);//u32
err = fscanf(f, "height = %x\n", &conf.height);//u32
err = fscanf(f, "log = %x\n", &conf.log);//u32
fclose(f);
// filter bad files

View File

@ -199,6 +199,7 @@ void DisplayDialog()
GtkWidget *main_frame, *main_box;
GtkWidget *option_frame, *option_box;
GtkWidget *log_check;
GtkWidget *int_label, *int_box;
GtkWidget *bilinear_check, *bilinear_label;
GtkWidget *aa_label, *aa_box;
@ -224,6 +225,7 @@ void DisplayDialog()
GTK_RESPONSE_ACCEPT,
NULL);
log_check = gtk_check_button_new_with_label("Logging (For Debugging):");
int_label = gtk_label_new ("Interlacing: (F5 to toggle)");
int_box = gtk_combo_box_new_text ();
gtk_combo_box_append_text(GTK_COMBO_BOX(int_box), "No Interlacing");
@ -281,6 +283,7 @@ void DisplayDialog()
advanced_scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(advanced_scroll), tree);
gtk_box_pack_start(GTK_BOX(option_box), log_check, false, false, 2);
gtk_box_pack_start(GTK_BOX(option_box), int_label, false, false, 2);
gtk_box_pack_start(GTK_BOX(option_box), int_box, false, false, 2);
gtk_box_pack_start(GTK_BOX(option_box), bilinear_check, false, false, 2);
@ -301,6 +304,7 @@ void DisplayDialog()
gtk_box_pack_start(GTK_BOX(main_box), option_frame, false, false, 2);
gtk_box_pack_start(GTK_BOX(main_box), advanced_frame, true, true, 2);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(log_check), conf.log);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bilinear_check), conf.bilinear);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wireframe_check), (conf.options & GSOPTION_WIREFRAME));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(avi_check), (conf.options & GSOPTION_CAPTUREAVI));
@ -316,7 +320,7 @@ void DisplayDialog()
{
int fake_options = 0;
SaveGameHackTable(tree);
if (gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)) != -1)
conf.interlace = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box));
@ -333,6 +337,7 @@ void DisplayDialog()
case 3: fake_options |= GSOPTION_WIN1280; break;
}
conf.log = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(log_check));
conf.bilinear = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bilinear_check));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wireframe_check)))

View File

@ -7,7 +7,7 @@
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="../../../../../bin/plugins/ZZOgl-PG-d.so" prefix_auto="0" extension_auto="0" />
<Option output="../../../../../bin/plugins/ZZOgl-PG-dbg.so" prefix_auto="0" extension_auto="0" />
<Option object_output="obj/Debug/" />
<Option type="3" />
<Option compiler="gcc" />
@ -16,11 +16,28 @@
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-D_DEBUG" />
</Compiler>
<Linker>
<Add library="../../../../../deps/debug/libUtilities.a" />
</Linker>
</Target>
<Target title="Devel">
<Option output="../../../../../bin/plugins/ZZOgl-PG-dev" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-W" />
<Add option="-g" />
<Add option="-DZEROGS_DEVBUILD" />
</Compiler>
<Linker>
<Add library="../../../../../deps/release/libUtilities.a" />
</Linker>
</Target>
<Target title="Release">
<Option output="../../../../../bin/plugins/ZZOgl-PG" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
@ -31,6 +48,7 @@
<Compiler>
<Add option="-O2" />
<Add option="-W" />
<Add option="-DRELEASE_TO_PUBLIC" />
</Compiler>
<Linker>
<Add option="-s" />

View File

@ -73,15 +73,6 @@ extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file
// 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
@ -178,11 +169,10 @@ typedef struct
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;
//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;
@ -236,25 +226,31 @@ static bool SPAM_PASS;
#define FUNCLOG
#endif
#define DEBUG_LOG printf
extern void __LogToConsole(const char *fmt, ...);
#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
namespace ZZLog
{
extern void Message(const char *fmt, ...);
extern void Log(const char *fmt, ...);
extern void WriteToConsole(const char *fmt, ...);
extern void Print(const char *fmt, ...);
extern void Greg_Log(const char *fmt, ...);
extern void Prim_Log(const char *fmt, ...);
extern void GS_Log(const char *fmt, ...);
extern void Debug_Log(const char *fmt, ...);
extern void Warn_Log(const char *fmt, ...);
extern void Error_Log(const char *fmt, ...);
};
#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 GREG_LOG ZZLog::Greg_Log
#define PRIM_LOG ZZLog::Prim_Log
#define WARN_LOG ZZLog::Warn_Log
#define GS_LOG ZZLog::GS_Log
#define DEBUG_LOG ZZLog::Debug_Log
#define ERROR_LOG ZZLog::Error_Log
//ZZLog::Error_Log
#define REG64(name) \
@ -291,12 +287,6 @@ union name \
#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();

View File

@ -47,8 +47,9 @@ BOOL CALLBACK LoggingDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOG))
conf.log = 1;
else conf.log = 0;
conf.log = 1;
else
conf.log = 0;
SaveConfig();
EndDialog(hW, FALSE);

View File

@ -148,20 +148,29 @@ void ZeroGS::AdjustTransToAspect(Vector& v)
}
// Helper for skip frames.
int TimeLastSkip=0;
inline bool FrameSkippingHelper() {
int TimeLastSkip = 0;
inline bool FrameSkippingHelper()
{
bool ShouldSkip = false;
if( g_nFrameRender > 0 ) {
if( g_nFrameRender < 8 ) {
if (g_nFrameRender > 0)
{
if (g_nFrameRender < 8)
{
g_nFrameRender++;
if( g_nFrameRender <= 3 ) {
if (g_nFrameRender <= 3)
{
g_nFramesSkipped++;
ShouldSkip = true;
}
}
}
else {
if( g_nFrameRender < -1 ) {
else
{
if (g_nFrameRender < -1)
{
g_nFramesSkipped++;
ShouldSkip = true;
}
@ -446,10 +455,11 @@ inline Vector RenderSetTargetBitTex(float th, float tw, float dh, float dw, bool
Vector v;
v = Vector(th, tw, dh, dw);
// Incorrect Asect ration on interlaced frames
if (isInterlace) {
v.y -= 1.0f/480 ;
v.w += 1.0f/480 ;
// Incorrect Aspect ratio on interlaced frames
if (isInterlace)
{
v.y -= 1.0f/conf.height;
v.w += 1.0f/conf.height;
}
ZZcgSetParameter4fv(pvsBitBlt.sBitBltTex, v, "g_fBitBltTex");

View File

@ -142,7 +142,7 @@ float fiRendWidth, fiRendHeight;
u8* s_lpShaderResources = NULL;
CGprogram pvs[16] = {NULL};
// String's for shader file in developer's mode
// String's for shader file in developer mode
#ifdef DEVBUILD
char* EFFECT_NAME="";
char* EFFECT_DIR="";
@ -203,7 +203,7 @@ ZeroGS::Create_Window(int _width, int _height) {
return true;
}
// Function ask about differnt OGL extensions, that are required to setup accordingly. Return false if cheks failed
// Function asks about different OGL extensions, that are required to setup accordingly. Return false if checks failed
inline bool ZeroGS::CreateImportantCheck() {
bool bSuccess = true;
#ifndef _WIN32
@ -224,7 +224,7 @@ inline bool ZeroGS::CreateImportantCheck() {
bSuccess = false;
}
// load the effect, find the best profiles (if any)
// load the effect & find the best profiles (if any)
if( cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE ) {
ERROR_LOG("arbvp1 not supported\n");
bSuccess = false;
@ -237,7 +237,7 @@ inline bool ZeroGS::CreateImportantCheck() {
return bSuccess;
}
// This is check for less important open gl extensions.
// This is a check for less important open gl extensions.
inline void ZeroGS::CreateOtherCheck() {
if( !IsGLExt("GL_EXT_blend_equation_separate") || glBlendEquationSeparateEXT == NULL ) {
ERROR_LOG("*********\nZZogl: OGL WARNING: Need GL_EXT_blend_equation_separate\nZZogl: *********\n");
@ -274,9 +274,9 @@ inline void ZeroGS::CreateOtherCheck() {
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &Max_Texture_Size_NV);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &Max_Texture_Size_2d);
ERROR_LOG("Maximun texture size is %d for Tex_2d and %d for Tex_NV\n", Max_Texture_Size_2d, Max_Texture_Size_NV);
ERROR_LOG("Maximum texture size is %d for Tex_2d and %d for Tex_NV\n", Max_Texture_Size_2d, Max_Texture_Size_NV);
if (Max_Texture_Size_NV < 1024)
ERROR_LOG("Could not properly made bitmasks, so some textures should be missed\n");
ERROR_LOG("Could not properly make bitmasks, so some textures will be missed\n");
/* Zeydlitz: we don't support 128-bit targets yet. they are slow and weirdo
if( g_GameSettings & GAME_32BITTARGS ) {
@ -374,7 +374,18 @@ inline bool CreateFillExtensionsMap(){
int prevlog = conf.log;
conf.log = 1;
GS_LOG("Supported OpenGL Extensions:\n%s\n", ptoken); // write to the log file
ZZLog::GS_Log("Supported OpenGL Extensions:\n%s\n", ptoken); // write to the log file
// Probably a better way to do it, but seems to crash.
/*int n;
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
ZZLog::GS_Log("Supported OpenGL Extensions:\n");
for (int i = 0; i < n; i++)
{
ZZLog::GS_Log("%s/n", (const char*)glGetStringi(GL_EXTENSIONS, i));
}*/
conf.log = prevlog;
// insert all exts into mapGLExtensions
@ -413,14 +424,10 @@ bool ZeroGS::Create(int _width, int _height)
cgSetErrorHandler(HandleCgError, NULL);
g_RenderFormatType = RFT_float16;
if (!Create_Window(_width, _height))
return false;
if (!CreateFillExtensionsMap())
return false;
if (!CreateImportantCheck())
return false;
if (!Create_Window(_width, _height)) return false;
if (!CreateFillExtensionsMap()) return false;
if (!CreateImportantCheck()) return false;
ZeroGS::CreateOtherCheck();
// check the max texture width and height
@ -462,7 +469,7 @@ bool ZeroGS::Create(int _width, int _height)
glGenFramebuffersEXT( 1, &s_uFramebuffer);
if( s_uFramebuffer == 0 ) {
ERROR_LOG("failed to create the renderbuffer\n");
ERROR_LOG("Failed to create the renderbuffer\n");
}
assert( glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT );

View File

@ -2286,7 +2286,7 @@ u32 ZeroGS::CBitwiseTextureMngr::GetTexInt(u32 bitvalue, u32 ptexDoNotDelete)
return ptex;
}
static __forceinline void RangeSanityCheck()
void ZeroGS::CRangeManager::RangeSanityCheck()
{
#ifdef _DEBUG
// sanity check

View File

@ -122,7 +122,7 @@ namespace ZeroGS {
void ClearRange(int starty, int endy); // set all targets to cleared
void DestroyCleared(); // flush all cleared targes
void DestroyOldest();
list<CMemoryTarget> listTargets, listClearedTargets;
u32 curstamp;
@ -168,6 +168,7 @@ namespace ZeroGS {
// works in semi logN
void Insert(int start, int end);
void RangeSanityCheck();
inline void Clear() {
ranges.resize(0);
}

View File

@ -780,13 +780,17 @@ void ZeroGS::KickDummy()
void ZeroGS::SetFogColor(u32 fog)
{
FUNCLOG
if( 1||gs.fogcol != fog ) {
// Always set the fog color, even if it was already set.
// if (gs.fogcol != fog)
// {
gs.fogcol = fog;
ZeroGS::Flush(0);
ZeroGS::Flush(1);
if( !g_bIsLost ) {
if (!g_bIsLost)
{
SetShaderCaller("SetFogColor");
Vector v;
@ -796,7 +800,7 @@ void ZeroGS::SetFogColor(u32 fog)
v.z = ((gs.fogcol>>16)&0xff)/255.0f;
ZZcgSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
}
}
// }
}
void ZeroGS::ExtWrite()