From 68ceb3b8fbbbd0943ab0aa148c5c35f07396c74f Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 17 Feb 2009 01:38:02 +0000 Subject: [PATCH] Fixed a bug that caused MTGS to throw "pure virtual function called" errors on rare occasions, and cause crashes in Linux. (Issue 31) Improved the Win32 build scripts to solve some end case scenarios on some systems/configs, where they would fail due to missing path separators. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@514 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/GS.h | 1 + pcsx2/MTGS.cpp | 15 ++++---- pcsx2/ThreadTools.cpp | 8 +++-- pcsx2/Threading.h | 1 + .../windows/VCprojects/vsprops/postBuild.tmpl | 10 +++--- .../VCprojects/vsprops/postBuild.unknown | 6 ++-- pcsx2/windows/VCprojects/vsprops/preBuild.cmd | 8 ++--- .../CDVDiso/src/Win32/vsprops/postBuild.tmpl | 10 +++--- .../src/Win32/vsprops/postBuild.unknown | 6 ++-- .../CDVDiso/src/Win32/vsprops/preBuild.cmd | 8 ++--- plugins/CDVDolio/svnrev_template.h | 2 -- plugins/CDVDolio/vsprops/common.vsprops | 9 ++++- .../vsprops/pcsx2_plugin_common.vsprops | 34 +++++++++++++++++++ plugins/CDVDolio/vsprops/postBuild.tmpl | 24 +++++++++++++ plugins/CDVDolio/vsprops/postBuild.unknown | 21 ++++++++++++ plugins/CDVDolio/vsprops/preBuild.cmd | 20 +++++++++++ plugins/CDVDolio/vsprops/svnrev_template.h | 18 ++++++++++ plugins/CDVDolio/vsprops/svnrev_unknown.h | 23 +++++++++++++ plugins/GSdx/GSdx_vs2008.vcproj | 8 +++++ plugins/GSdx/vsprops/postBuild.tmpl | 10 +++--- plugins/GSdx/vsprops/postBuild.unknown | 6 ++-- plugins/GSdx/vsprops/preBuild.cmd | 8 ++--- .../spu2-x/src/Win32/vsprops/postBuild.tmpl | 10 +++--- .../src/Win32/vsprops/postBuild.unknown | 6 ++-- plugins/spu2-x/src/Win32/vsprops/preBuild.cmd | 8 ++--- .../spu2ghz/src/Win32/vsprops/postBuild.tmpl | 10 +++--- .../src/Win32/vsprops/postBuild.unknown | 6 ++-- .../spu2ghz/src/Win32/vsprops/preBuild.cmd | 8 ++--- plugins/xpad/vsprops/postBuild.tmpl | 10 +++--- plugins/xpad/vsprops/postBuild.unknown | 6 ++-- plugins/xpad/vsprops/preBuild.cmd | 8 ++--- .../zerogs/dx/Win32/vsprops/postBuild.tmpl | 10 +++--- .../zerogs/dx/Win32/vsprops/postBuild.unknown | 6 ++-- plugins/zerogs/dx/Win32/vsprops/preBuild.cmd | 8 ++--- .../opengl/Win32/vsprops/postBuild.tmpl | 10 +++--- .../opengl/Win32/vsprops/postBuild.unknown | 6 ++-- .../zerogs/opengl/Win32/vsprops/preBuild.cmd | 8 ++--- .../zeropad/Windows/vsprops/postBuild.tmpl | 10 +++--- .../zeropad/Windows/vsprops/postBuild.unknown | 6 ++-- plugins/zeropad/Windows/vsprops/preBuild.cmd | 8 ++--- plugins/zerospu2/Win32/vsprops/postBuild.tmpl | 10 +++--- .../zerospu2/Win32/vsprops/postBuild.unknown | 6 ++-- plugins/zerospu2/Win32/vsprops/preBuild.cmd | 8 ++--- 43 files changed, 293 insertions(+), 131 deletions(-) delete mode 100644 plugins/CDVDolio/svnrev_template.h create mode 100644 plugins/CDVDolio/vsprops/pcsx2_plugin_common.vsprops create mode 100644 plugins/CDVDolio/vsprops/postBuild.tmpl create mode 100644 plugins/CDVDolio/vsprops/postBuild.unknown create mode 100644 plugins/CDVDolio/vsprops/preBuild.cmd create mode 100644 plugins/CDVDolio/vsprops/svnrev_template.h create mode 100644 plugins/CDVDolio/vsprops/svnrev_unknown.h diff --git a/pcsx2/GS.h b/pcsx2/GS.h index 222812f98e..13406868e6 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -195,6 +195,7 @@ public: mtgsThreadObject(); virtual ~mtgsThreadObject(); + void Start(); void Close(); void Reset(); void GIFSoftReset( int mask ); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 8017ebd4c2..2c766be224 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -188,7 +188,8 @@ typedef void (*GIFRegHandler)(const u32* data); static GIFRegHandler s_GSHandlers[3] = { RegHandlerSIGNAL, RegHandlerFINISH, RegHandlerLABEL }; mtgsThreadObject::mtgsThreadObject() : - m_RingPos( 0 ) + Thread() +, m_RingPos( 0 ) , m_WritePos( 0 ) , m_post_InitDone() @@ -207,12 +208,16 @@ mtgsThreadObject::mtgsThreadObject() : , m_gsMem( (u8*)m_RingBuffer.GetPtr( m_RingBufferSize ) ) { memzero_obj( m_path ); +} + +void mtgsThreadObject::Start() +{ + Thread::Start(); // Wait for the thread to finish initialization (it runs GSinit, which can take // some time since it's creating a new window and all), and then check for errors. - m_post_event.Post(); // tell MTGS we're done here - m_post_InitDone.Wait(); // and wait for MTGS to be done there! + m_post_InitDone.Wait(); if( m_returncode != 0 ) // means the thread failed to init the GS plugin throw Exception::PluginFailure( "GS", "The GS plugin failed to open/initialize." ); @@ -441,9 +446,6 @@ int mtgsThreadObject::Callback() { Console::WriteLn("MTGS > Thread Started, Opening GS Plugin..."); - // Wait for the MTGS to initialize structures. - m_post_event.Wait(); - memcpy_aligned( m_gsMem, PS2MEM_GS, sizeof(m_gsMem) ); GSsetBaseMem( m_gsMem ); @@ -1018,6 +1020,7 @@ bool mtgsOpen() try { mtgsThread = new mtgsThreadObject(); + mtgsThread->Start(); } catch( Exception::ThreadCreationError& ) { diff --git a/pcsx2/ThreadTools.cpp b/pcsx2/ThreadTools.cpp index 313315cfe3..1b1c722627 100644 --- a/pcsx2/ThreadTools.cpp +++ b/pcsx2/ThreadTools.cpp @@ -29,8 +29,6 @@ namespace Threading , m_terminated( false ) , m_post_event() { - if( pthread_create( &m_thread, NULL, _internal_callback, this ) != 0 ) - throw Exception::ThreadCreationError(); } Thread::~Thread() @@ -38,6 +36,12 @@ namespace Threading Close(); } + void Thread::Start() + { + if( pthread_create( &m_thread, NULL, _internal_callback, this ) != 0 ) + throw Exception::ThreadCreationError(); + } + void Thread::Close() { pthread_cancel( m_thread ); diff --git a/pcsx2/Threading.h b/pcsx2/Threading.h index b4be51b242..5b1f624b86 100644 --- a/pcsx2/Threading.h +++ b/pcsx2/Threading.h @@ -89,6 +89,7 @@ namespace Threading virtual ~Thread(); Thread(); + virtual void Start(); virtual void Close(); // Gets the return code of the thread. diff --git a/pcsx2/windows/VCprojects/vsprops/postBuild.tmpl b/pcsx2/windows/VCprojects/vsprops/postBuild.tmpl index 75e9660d45..8423bad3f5 100644 --- a/pcsx2/windows/VCprojects/vsprops/postBuild.tmpl +++ b/pcsx2/windows/VCprojects/vsprops/postBuild.tmpl @@ -7,16 +7,16 @@ rem DestDir - $(SolutionDir) - Directory of the destination, usually the sam rem DestFile - Base filename of the target/dest, without extension! rem DestExt - Extension of the target/dest! -set pcsxoutdir=%2\bin -set pcsxoutname=%pcsxoutdir%\%3%4 -set pcsxnewname=%pcsxoutdir%\%3-r$WCREV$$WCMODS?m:$%4 +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%\%~3%4 +set pcsxnewname=%pcsxoutdir%\%~3-r$WCREV$$WCMODS?m:$%4 IF NOT EXIST %pcsxoutdir% ( md %pcsxoutdir% ) -copy /Y %1 %pcsxoutname% -copy /Y %1 %pcsxnewname% +copy /Y %~1 %pcsxoutname% +copy /Y %~1 %pcsxnewname% if ERRORLEVEL 0 ( echo Target copied to %pcsxnewname% diff --git a/pcsx2/windows/VCprojects/vsprops/postBuild.unknown b/pcsx2/windows/VCprojects/vsprops/postBuild.unknown index 199dce4e3c..d633aa67d3 100644 --- a/pcsx2/windows/VCprojects/vsprops/postBuild.unknown +++ b/pcsx2/windows/VCprojects/vsprops/postBuild.unknown @@ -7,14 +7,14 @@ rem DestDir - $(SolutionDir) - Directory of the destination, usually the sam rem DestFile - Base filename of the target/dest, without extension! rem DestExt - Extension of the target/dest! -set pcsxoutdir=%2\bin -set pcsxoutname=%pcsxoutdir%%3%4 +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%%~3%4 IF NOT EXIST %pcsxoutdir% ( md %pcsxoutdir% ) -copy /Y %1 %pcsxoutname% +copy /Y %~1 %pcsxoutname% if ERRORLEVEL 0 ( echo Target copied to %pcsxoutname% ) diff --git a/pcsx2/windows/VCprojects/vsprops/preBuild.cmd b/pcsx2/windows/VCprojects/vsprops/preBuild.cmd index 9047b6e29a..fc5f233aba 100644 --- a/pcsx2/windows/VCprojects/vsprops/preBuild.cmd +++ b/pcsx2/windows/VCprojects/vsprops/preBuild.cmd @@ -5,14 +5,14 @@ rem rem ProjectSrcDir - $(ProjectDir)\.. - Directory of project source code. rem VspropsDir - $(PrjectDir)\vsprops - Directory of this script and its counterparts. -SubWCRev.exe %1 %2\svnrev_template.h %1\svnrev.h +SubWCRev.exe %~1 %~2\svnrev_template.h %~1\svnrev.h if %ERRORLEVEL% NEQ 0 ( echo Automatic revision update unavailable, using generic template instead. echo You can safely ignore this message - see svnrev.h for details. - copy /Y %2\svnrev_unknown.h %1\svnrev.h - copy /Y %2\postBuild.unknown %2\postBuild.cmd + copy /Y %~2\svnrev_unknown.h %~1\svnrev.h + copy /Y %~2\postBuild.unknown %~2\postBuild.cmd ) else ( - SubWCRev.exe %1 %2\postBuild.tmpl %2\postBuild.cmd + SubWCRev.exe %~1 %~2\postBuild.tmpl %~2\postBuild.cmd ) rem Always return an errorlevel of 0 -- this allows compilation to continue if SubWCRev failed. diff --git a/plugins/CDVDiso/src/Win32/vsprops/postBuild.tmpl b/plugins/CDVDiso/src/Win32/vsprops/postBuild.tmpl index e5581989b0..8423bad3f5 100644 --- a/plugins/CDVDiso/src/Win32/vsprops/postBuild.tmpl +++ b/plugins/CDVDiso/src/Win32/vsprops/postBuild.tmpl @@ -7,16 +7,16 @@ rem DestDir - $(SolutionDir) - Directory of the destination, usually the sam rem DestFile - Base filename of the target/dest, without extension! rem DestExt - Extension of the target/dest! -set pcsxoutdir=%2\bin\plugins -set pcsxoutname=%pcsxoutdir%\%3%4 -set pcsxnewname=%pcsxoutdir%\%3-r$WCREV$$WCMODS?m:$%4 +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%\%~3%4 +set pcsxnewname=%pcsxoutdir%\%~3-r$WCREV$$WCMODS?m:$%4 IF NOT EXIST %pcsxoutdir% ( md %pcsxoutdir% ) -copy /Y %1 %pcsxoutname% -copy /Y %1 %pcsxnewname% +copy /Y %~1 %pcsxoutname% +copy /Y %~1 %pcsxnewname% if ERRORLEVEL 0 ( echo Target copied to %pcsxnewname% diff --git a/plugins/CDVDiso/src/Win32/vsprops/postBuild.unknown b/plugins/CDVDiso/src/Win32/vsprops/postBuild.unknown index 360b05cad5..d633aa67d3 100644 --- a/plugins/CDVDiso/src/Win32/vsprops/postBuild.unknown +++ b/plugins/CDVDiso/src/Win32/vsprops/postBuild.unknown @@ -7,14 +7,14 @@ rem DestDir - $(SolutionDir) - Directory of the destination, usually the sam rem DestFile - Base filename of the target/dest, without extension! rem DestExt - Extension of the target/dest! -set pcsxoutdir=%2\bin\plugins -set pcsxoutname=%pcsxoutdir%%3%4 +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%%~3%4 IF NOT EXIST %pcsxoutdir% ( md %pcsxoutdir% ) -copy /Y %1 %pcsxoutname% +copy /Y %~1 %pcsxoutname% if ERRORLEVEL 0 ( echo Target copied to %pcsxoutname% ) diff --git a/plugins/CDVDiso/src/Win32/vsprops/preBuild.cmd b/plugins/CDVDiso/src/Win32/vsprops/preBuild.cmd index 9047b6e29a..fc5f233aba 100644 --- a/plugins/CDVDiso/src/Win32/vsprops/preBuild.cmd +++ b/plugins/CDVDiso/src/Win32/vsprops/preBuild.cmd @@ -5,14 +5,14 @@ rem rem ProjectSrcDir - $(ProjectDir)\.. - Directory of project source code. rem VspropsDir - $(PrjectDir)\vsprops - Directory of this script and its counterparts. -SubWCRev.exe %1 %2\svnrev_template.h %1\svnrev.h +SubWCRev.exe %~1 %~2\svnrev_template.h %~1\svnrev.h if %ERRORLEVEL% NEQ 0 ( echo Automatic revision update unavailable, using generic template instead. echo You can safely ignore this message - see svnrev.h for details. - copy /Y %2\svnrev_unknown.h %1\svnrev.h - copy /Y %2\postBuild.unknown %2\postBuild.cmd + copy /Y %~2\svnrev_unknown.h %~1\svnrev.h + copy /Y %~2\postBuild.unknown %~2\postBuild.cmd ) else ( - SubWCRev.exe %1 %2\postBuild.tmpl %2\postBuild.cmd + SubWCRev.exe %~1 %~2\postBuild.tmpl %~2\postBuild.cmd ) rem Always return an errorlevel of 0 -- this allows compilation to continue if SubWCRev failed. diff --git a/plugins/CDVDolio/svnrev_template.h b/plugins/CDVDolio/svnrev_template.h deleted file mode 100644 index c8806d96ae..0000000000 --- a/plugins/CDVDolio/svnrev_template.h +++ /dev/null @@ -1,2 +0,0 @@ -#define SVN_REV $WCREV$ -#define SVN_MODS $WCMODS?1:0$ \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/common.vsprops b/plugins/CDVDolio/vsprops/common.vsprops index b25cc37eaf..5b34339bc0 100644 --- a/plugins/CDVDolio/vsprops/common.vsprops +++ b/plugins/CDVDolio/vsprops/common.vsprops @@ -27,6 +27,13 @@ /> + + diff --git a/plugins/CDVDolio/vsprops/pcsx2_plugin_common.vsprops b/plugins/CDVDolio/vsprops/pcsx2_plugin_common.vsprops new file mode 100644 index 0000000000..086133a60a --- /dev/null +++ b/plugins/CDVDolio/vsprops/pcsx2_plugin_common.vsprops @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/plugins/CDVDolio/vsprops/postBuild.tmpl b/plugins/CDVDolio/vsprops/postBuild.tmpl new file mode 100644 index 0000000000..8423bad3f5 --- /dev/null +++ b/plugins/CDVDolio/vsprops/postBuild.tmpl @@ -0,0 +1,24 @@ +@echo off +rem +rem Usage: postBuild.cmd SourcePath DestDir DestFile DestExt +rem +rem SourcePath - $(TargetPath) - Fully qualified path of the generated target file. +rem DestDir - $(SolutionDir) - Directory of the destination, usually the same as the solution. +rem DestFile - Base filename of the target/dest, without extension! +rem DestExt - Extension of the target/dest! + +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%\%~3%4 +set pcsxnewname=%pcsxoutdir%\%~3-r$WCREV$$WCMODS?m:$%4 + +IF NOT EXIST %pcsxoutdir% ( + md %pcsxoutdir% +) + +copy /Y %~1 %pcsxoutname% +copy /Y %~1 %pcsxnewname% + +if ERRORLEVEL 0 ( + echo Target copied to %pcsxnewname% +) +exit 0 diff --git a/plugins/CDVDolio/vsprops/postBuild.unknown b/plugins/CDVDolio/vsprops/postBuild.unknown new file mode 100644 index 0000000000..d633aa67d3 --- /dev/null +++ b/plugins/CDVDolio/vsprops/postBuild.unknown @@ -0,0 +1,21 @@ +@echo off +rem +rem Usage: postBuild.cmd SourcePath DestDir DestFile DestExt +rem +rem SourcePath - $(TargetPath) - Fully qualified path of the generated target file. +rem DestDir - $(SolutionDir) - Directory of the destination, usually the same as the solution. +rem DestFile - Base filename of the target/dest, without extension! +rem DestExt - Extension of the target/dest! + +set pcsxoutdir=%~2\bin\plugins +set pcsxoutname=%pcsxoutdir%%~3%4 + +IF NOT EXIST %pcsxoutdir% ( + md %pcsxoutdir% +) + +copy /Y %~1 %pcsxoutname% +if ERRORLEVEL 0 ( + echo Target copied to %pcsxoutname% +) +set ERRORLEVEL=0 diff --git a/plugins/CDVDolio/vsprops/preBuild.cmd b/plugins/CDVDolio/vsprops/preBuild.cmd new file mode 100644 index 0000000000..fc5f233aba --- /dev/null +++ b/plugins/CDVDolio/vsprops/preBuild.cmd @@ -0,0 +1,20 @@ +@echo off + +rem Usage: preBuild.cmd ProjectSrcDir VspropsDir +rem +rem ProjectSrcDir - $(ProjectDir)\.. - Directory of project source code. +rem VspropsDir - $(PrjectDir)\vsprops - Directory of this script and its counterparts. + +SubWCRev.exe %~1 %~2\svnrev_template.h %~1\svnrev.h +if %ERRORLEVEL% NEQ 0 ( + echo Automatic revision update unavailable, using generic template instead. + echo You can safely ignore this message - see svnrev.h for details. + copy /Y %~2\svnrev_unknown.h %~1\svnrev.h + copy /Y %~2\postBuild.unknown %~2\postBuild.cmd +) else ( + SubWCRev.exe %~1 %~2\postBuild.tmpl %~2\postBuild.cmd +) + +rem Always return an errorlevel of 0 -- this allows compilation to continue if SubWCRev failed. + +exit 0 diff --git a/plugins/CDVDolio/vsprops/svnrev_template.h b/plugins/CDVDolio/vsprops/svnrev_template.h new file mode 100644 index 0000000000..f2656ef1e8 --- /dev/null +++ b/plugins/CDVDolio/vsprops/svnrev_template.h @@ -0,0 +1,18 @@ +// svnrev_template.h --> svnrev.h +// +// This file acts as a template for the automatic SVN revision/version tag. +// It is used by the utility SubWCrev.exe to create an "svnrev.h" file for +// whichever project is being compiled (as indicated by command line options +// passed to SubWCRev.exe during the project's pre-build step). +// +// The SubWCRev.exe utility is part of TortoiseSVN and requires several DLLs +// installed by TortoiseSVN, so it will only be available if you have TortoiseSVN +// installed on your system. If you do not have it installed, a generic template +// is used instead (see svnrev_generic.h). Having TortoiseSVN is handy but not +// necessary. If you do not have it installed, everything will still compile +// fine except without the SVN revision tagged to the application/dll version. +// +// TortoiseSVN can be downloaded from http://tortoisesvn.tigris.org + +#define SVN_REV $WCREV$ +#define SVN_MODS $WCMODS?1:0$ \ No newline at end of file diff --git a/plugins/CDVDolio/vsprops/svnrev_unknown.h b/plugins/CDVDolio/vsprops/svnrev_unknown.h new file mode 100644 index 0000000000..4872e23b20 --- /dev/null +++ b/plugins/CDVDolio/vsprops/svnrev_unknown.h @@ -0,0 +1,23 @@ +// svnrev_genric.h --> svnrev.h +// +// This file acts as a placebo for people who do not have TortoiseSVN installed. +// It provides "empty" revision information to the Pcsx2 Playground projects in +// the absence of real revisions derived from the repository being built. +// +// This file does not affect application/dll builds in any significant manner, +// other than the lack of automatic revision tags inserted into the app (which +// is very convenient but hardly necessary). +// +// See svn_template.h for more information on how the process of revision +// templating works. +// +// If you would like to enable automatic revisin tagging, TortoiseSVN can be +// downloaded from http://tortoisesvn.tigris.org + +#define SVN_REV_UNKNOWN + +// The following defines are included so that code will still compile even if it +// doesn't check for the SVN_REV_UNKNOWN define. + +#define SVN_REV 0 +#define SVN_MODS "" \ No newline at end of file diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index 9009c9a711..9dbf94a399 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -56,6 +56,7 @@ />