Skip to content

Commit

Permalink
Big gif transfer code rewrite!
Browse files Browse the repository at this point in the history
Pcsx2 now has a gifUnit class which acts like the ps2's gif and executes a single gif transfer at a time (and performs path arbitration according to priority and path3 slicing).

This new code is generally a speedup for most games. Particularly VU heavy games like GoW.
This revision breaks old saved state compatibility so don't update if you wish to keep playing with your old saved states.
Leave comments if this revision fixes or breaks anything...

Message to GS Plugin authors:
This new code now uses only 1 gif callback to transfer data to the gs plugin (GSgifTransfer).
pcsx2 also is garaunteed to send full GS primitives to the plugin. So you don't have to account for partial-transfers anymore.

Thanks goes out to shadowlady who tested around 500 games for me :D

Note 1: The old gif code is still in this revision, and can be enabled by the USE_OLD_GIF macro. The old code will be deleted soon.
Note 2: This revision also enables assertion dialogs in devel builds, and changed a lot of assume cases into assertions.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4821 96395faa-99c1-11dd-bbfe-3dabce05a288
  • Loading branch information
cottonvibes committed Jul 24, 2011
1 parent 7cb4dbb commit c05dc75
Show file tree
Hide file tree
Showing 78 changed files with 1,533 additions and 761 deletions.
1 change: 1 addition & 0 deletions common/include/Pcsx2Defs.h
Expand Up @@ -309,6 +309,7 @@ static const int __pagesize = PCSX2_PAGESIZE;
#define __ri __releaseinline
#define __fi __forceinline
#define __fc __fastcall
#define elif else if


#endif
37 changes: 25 additions & 12 deletions common/include/Utilities/Assertions.h
Expand Up @@ -84,15 +84,18 @@ extern pxDoAssertFnType* pxDoAssert;
// --------------------------------------------------------------------------------------
// pxAssume / pxAssumeDev / pxFail / pxFailDev
// --------------------------------------------------------------------------------------
// Assumptions are like "extra rigid" assertions, which should never fail under any circum-
// stance in release build optimized code.
// Assumptions are hints to the compiler that the condition will always be true,
// the condition should never fail under any circumstance in release builds
// or else you might get incorrect compiler generated code.
//
// Performance: All assumption/fail types optimize into __assume()/likely() directives in
// Release builds (non-dev varieties optimize as such in Devel builds as well). If using
// Release builds (non-dev varieties optimize as such in Devel builds as well).
// __assume(0) is a special form of __assume() which tells the compiler that the code path
// is not reachable and will cause undefined results if it is reachable...
//
// Having pxFail and pxFailDev translate into __assume statements is very dangerous, since
// it can lead to the compiler optimizing out code and leading to crashes in dev/release
// builds. To have code optimized, explicitly use pxAssume(false) or pxAssumeDev(false,msg);
// builds. To have code optimized, explicitly use pxAssume(false) or pxAssumeDev(false,msg);

#define pxDiagSpot DiagnosticOrigin( __TFILE__, __LINE__, __pxFUNCTION__ )
#define pxAssertSpot(cond) DiagnosticOrigin( __TFILE__, __LINE__, __pxFUNCTION__, _T(#cond) )
Expand All @@ -119,16 +122,26 @@ extern pxDoAssertFnType* pxDoAssert;

#elif defined(PCSX2_DEVBUILD)

// Devel builds use __assume for standard assertions and call pxOnAssertDevel
// for AssertDev brand assertions (which typically throws a LogicError exception).
// Devel builds now will give you a release-mode assertion dialog window if any of the
// following macro's 'cond' field is false.
// Note: Only use pxAssume/Msg/Dev if you know what you're doing, __assume is supposed
// to be used as an optimization hint, yet many devs have been using psAssume
// thinking its the same as an assertion.
// __assume(0) is also very dangerous because it is a special case of __assume() which
// tells the compiler that the code path is not reachable, and it can cause unpredictable
// results if the code path can be reached.
// i.e. if (1) { __assume(0); something(); }
// In the above example, something() may never be called.
// __assume(0)'s real use is in optimizing stuff such as "default:" cases on a switch
// statement. See jNO_DEFAULT

# define pxAssertMsg(cond, msg) (likely(cond))
# define pxAssertMsg(cond, msg) pxAssertRel(cond, msg)
# define pxAssertDev(cond, msg) pxAssertRel(cond, msg)

# define pxAssumeMsg(cond, msg) (__assume(cond))
# define pxAssumeMsg(cond, msg) pxAssumeRel(cond, msg) //(__assume(cond))
# define pxAssumeDev(cond, msg) pxAssumeRel(cond, msg)

# define pxFail(msg)
# define pxFail(msg) pxAssertDev(false, msg)
# define pxFailDev(msg) pxAssertDev(false, msg)

#else
Expand All @@ -142,8 +155,8 @@ extern pxDoAssertFnType* pxDoAssert;
# define pxAssumeMsg(cond, msg) (__assume(cond))
# define pxAssumeDev(cond, msg) (__assume(cond))

# define pxFail(msg)
# define pxFailDev(msg)
# define pxFail(msg) do{} while(0)
# define pxFailDev(msg) do{} while(0)

#endif

Expand Down Expand Up @@ -186,7 +199,7 @@ extern void pxOnAssert( const DiagnosticOrigin& origin, const char* msg );
# define jNO_DEFAULT \
default: \
{ \
pxAssumeDev( false, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)" ); \
pxAssumeDev( 0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)" ); \
break; \
}
#endif
13 changes: 7 additions & 6 deletions common/include/Utilities/Dependencies.h
Expand Up @@ -195,18 +195,19 @@ class ScopedBool
// --------------------------------------------------------------------------------------
// Handy Human-readable constants for common immediate values (_16kb -> _4gb)

static const sptr _64kb = 0x10000;
static const sptr _16kb = _64kb / 4;
static const sptr _128kb = _64kb * 2;
static const sptr _256kb = _128kb * 2;
static const sptr _1kb = 1024 * 1;
static const sptr _16kb = _1kb * 16;
static const sptr _64kb = _1kb * 64;
static const sptr _128kb = _1kb * 128;
static const sptr _256kb = _1kb * 256;

static const s64 _1mb = 0x100000;
static const s64 _1mb = 1024 * 1024;
static const s64 _8mb = _1mb * 8;
static const s64 _16mb = _1mb * 16;
static const s64 _32mb = _1mb * 32;
static const s64 _64mb = _1mb * 64;
static const s64 _256mb = _1mb * 256;
static const s64 _1gb = _256mb * 4;
static const s64 _1gb = _1mb * 1024;
static const s64 _4gb = _1gb * 4;


Expand Down
2 changes: 1 addition & 1 deletion common/include/Utilities/IniInterface.h
Expand Up @@ -43,7 +43,7 @@ class IniInterface
void SetPath( const wxString& path );
void Flush();

wxConfigBase& GetConfig() { pxAssume( m_Config ); return *m_Config; }
wxConfigBase& GetConfig() { pxAssert( m_Config ); return *m_Config; }
bool IsOk() const { return m_Config != NULL; }

virtual bool IsLoading() const=0;
Expand Down
4 changes: 2 additions & 2 deletions common/include/Utilities/PageFaultSource.h
Expand Up @@ -199,13 +199,13 @@ class VirtualMemoryReserve

u8& operator[](uint idx)
{
pxAssume(idx < (m_pages_reserved * __pagesize));
pxAssert(idx < (m_pages_reserved * __pagesize));
return *((u8*)m_baseptr + idx);
}

const u8& operator[](uint idx) const
{
pxAssume(idx < (m_pages_reserved * __pagesize));
pxAssert(idx < (m_pages_reserved * __pagesize));
return *((u8*)m_baseptr + idx);
}

Expand Down
2 changes: 1 addition & 1 deletion common/include/Utilities/ScopedAlloc.h
Expand Up @@ -107,7 +107,7 @@ class BaseScopedAlloc

virtual ~BaseScopedAlloc() throw()
{
//pxAssume(m_buffer==NULL);
//pxAssert(m_buffer==NULL);
}

public:
Expand Down
12 changes: 6 additions & 6 deletions common/include/Utilities/pxCheckBox.h
Expand Up @@ -50,12 +50,12 @@ class pxCheckBox : public wxPanelWithHelpers
pxCheckBox& SetIndeterminate();
pxCheckBox& SetState( wxCheckBoxState state );

wxCheckBoxState GetState() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
bool GetValue() const { pxAssume( m_checkbox != NULL ); return m_checkbox->GetValue(); }
bool IsChecked() const { pxAssume( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
bool IsIndeterminate() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
operator wxCheckBox&() { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
operator const wxCheckBox&() const { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
wxCheckBoxState GetState() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
bool GetValue() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetValue(); }
bool IsChecked() const { pxAssert( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
bool IsIndeterminate() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
operator wxCheckBox&() { pxAssert( m_checkbox != NULL ); return *m_checkbox; }
operator const wxCheckBox&() const { pxAssert( m_checkbox != NULL ); return *m_checkbox; }

wxCheckBox* GetWxPtr() { return m_checkbox; }
const wxCheckBox* GetWxPtr() const { return m_checkbox; }
Expand Down
2 changes: 1 addition & 1 deletion common/include/x86emitter/x86types.h
Expand Up @@ -501,7 +501,7 @@ template< typename T > void xWrite( T val );
&xmm6, &xmm7
};

pxAssume(id < iREGCNT_XMM);
pxAssert(id < iREGCNT_XMM);
return *m_tbl_xmmRegs[id];
}

Expand Down
6 changes: 3 additions & 3 deletions common/src/Utilities/AlignedMalloc.cpp
Expand Up @@ -28,7 +28,7 @@ static const uint headsize = sizeof(AlignedMallocHeader);

void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align)
{
pxAssume( align < 0x10000 );
pxAssert( align < 0x10000 );

u8* p = (u8*)malloc(size+align+headsize);

Expand All @@ -37,7 +37,7 @@ void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align)
uptr aligned = (pasthead + align-1) & ~(align-1);

AlignedMallocHeader* header = (AlignedMallocHeader*)(aligned-headsize);
pxAssume( (uptr)header >= (uptr)p );
pxAssert( (uptr)header >= (uptr)p );

header->baseptr = p;
header->size = size;
Expand All @@ -47,7 +47,7 @@ void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align)

void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align)
{
pxAssume( align < 0x10000 );
pxAssert( align < 0x10000 );

void* newbuf = pcsx2_aligned_malloc( size, align );

Expand Down
4 changes: 2 additions & 2 deletions common/src/Utilities/FastFormatString.cpp
Expand Up @@ -92,14 +92,14 @@ class FastFormatBuffers
BufferType& GrabBuffer()
{
++m_curslot;
pxAssume(m_curslot < BufferCount);
pxAssert(m_curslot < BufferCount);
return m_buffers[m_curslot];
}

void ReleaseBuffer()
{
--m_curslot;
pxAssume(m_curslot < BufferCount);
pxAssert(m_curslot < BufferCount);
}

BufferType& operator[](uint i)
Expand Down
2 changes: 1 addition & 1 deletion common/src/Utilities/Mutex.cpp
Expand Up @@ -270,7 +270,7 @@ void Threading::ScopedLock::AssignAndLock( const Mutex& locker )

void Threading::ScopedLock::AssignAndLock( const Mutex* locker )
{
pxAssume(!m_IsLocked); // if we're already locked, changing the lock is bad mojo.
pxAssert(!m_IsLocked); // if we're already locked, changing the lock is bad mojo.

m_lock = const_cast<Mutex*>(locker);
if( !m_lock ) return;
Expand Down
2 changes: 1 addition & 1 deletion common/src/Utilities/VirtualMemory.cpp
Expand Up @@ -44,7 +44,7 @@ void pxInstallSignalHandler()
// --------------------------------------------------------------------------------------
EventListener_PageFault::EventListener_PageFault()
{
pxAssume(Source_PageFault);
pxAssert(Source_PageFault);
Source_PageFault->Add( *this );
}

Expand Down
6 changes: 3 additions & 3 deletions common/src/Utilities/pxCheckBox.cpp
Expand Up @@ -83,22 +83,22 @@ pxCheckBox& pxCheckBox::SetToolTip( const wxString& tip )

pxCheckBox& pxCheckBox::SetValue( bool val )
{
pxAssume( m_checkbox );
pxAssert( m_checkbox );
m_checkbox->SetValue( val );
return *this;
}

pxCheckBox& pxCheckBox::SetIndeterminate()
{
pxAssume( m_checkbox );
pxAssert( m_checkbox );
m_checkbox->Set3StateValue( wxCHK_UNDETERMINED );
return *this;
}


pxCheckBox& pxCheckBox::SetState( wxCheckBoxState state )
{
pxAssume( m_checkbox );
pxAssert( m_checkbox );
m_checkbox->Set3StateValue( state );
return *this;
}
Expand Down
6 changes: 3 additions & 3 deletions common/src/Utilities/pxStaticText.cpp
Expand Up @@ -116,7 +116,7 @@ pxStaticText& pxStaticText::PaddingPixV( int pixels )

pxStaticText& pxStaticText::PaddingPctH( float pct )
{
pxAssume( pct < 0.5 );
pxAssert( pct < 0.5 );

m_paddingPct_horiz = pct;
UpdateWrapping( false );
Expand All @@ -126,7 +126,7 @@ pxStaticText& pxStaticText::PaddingPctH( float pct )

pxStaticText& pxStaticText::PaddingPctV( float pct )
{
pxAssume( pct < 0.5 );
pxAssert( pct < 0.5 );

m_paddingPct_vert = pct;
Refresh();
Expand All @@ -152,7 +152,7 @@ int pxStaticText::calcPaddingHeight( int newHeight ) const

wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
{
pxAssume( m_autowrap );
pxAssert( m_autowrap );

// Find an ideal(-ish) width, based on a search of all parent controls and their
// valid Minimum sizes.
Expand Down
4 changes: 2 additions & 2 deletions common/src/Utilities/pxWindowTextWriter.cpp
Expand Up @@ -86,7 +86,7 @@ pxWindowTextWriter& pxWindowTextWriter::MoveY( int ydelta )

void pxWindowTextWriter::_DoWriteLn( const wxChar* msg )
{
pxAssume( msg );
pxAssert( msg );

int tWidth, tHeight;
m_dc.GetMultiLineTextExtent( msg, &tWidth, &tHeight );
Expand All @@ -110,7 +110,7 @@ void pxWindowTextWriter::_DoWriteLn( const wxChar* msg )
// to the text writer.
void pxWindowTextWriter::_DoWrite( const wxChar* msg )
{
pxAssume( msg );
pxAssert( msg );

wxArrayString parts;
SplitString( parts, msg, L'\n' );
Expand Down
2 changes: 1 addition & 1 deletion common/src/Utilities/wxAppWithHelpers.cpp
Expand Up @@ -44,7 +44,7 @@ ConsoleLogSource_App pxConLog_App;
void BaseDeletableObject::DoDeletion()
{
wxAppWithHelpers* app = wxDynamicCast( wxApp::GetInstance(), wxAppWithHelpers );
pxAssume( app != NULL );
pxAssert( app != NULL );
app->DeleteObject( *this );
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/Utilities/wxGuiTools.cpp
Expand Up @@ -616,6 +616,6 @@ wxFont pxGetFixedFont( int ptsize, int weight )

wxString pxGetAppName()
{
pxAssume( wxTheApp );
pxAssert( wxTheApp );
return wxTheApp->GetAppName();
}
2 changes: 1 addition & 1 deletion common/src/Utilities/wxHelpers.cpp
Expand Up @@ -368,7 +368,7 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
void wxDialogWithHelpers::AddOkCancel( wxSizer *sizer, bool hasApply )
{
if( sizer == NULL ) sizer = GetSizer();
pxAssume( sizer );
pxAssert( sizer );
AddOkCancel( *sizer, hasApply );
}

Expand Down
4 changes: 2 additions & 2 deletions pcsx2/CDVD/CDVD.cpp
Expand Up @@ -831,7 +831,7 @@ __fi void cdvdReadInterrupt()

// Any other value besides 0 should be considered invalid here (wtf is that wacky
// plugin trying to do?)
pxAssume( cdvd.RErr == 0 );
pxAssert( cdvd.RErr == 0 );
}

if (cdvd.nSectors > 0)
Expand All @@ -844,7 +844,7 @@ __fi void cdvdReadInterrupt()
// An arbitrary delay of some number of cycles probably makes more sense here,
// but for now it's based on the cdvd.ReadTime value. -- air

pxAssume((int)cdvd.ReadTime > 0 );
pxAssert((int)cdvd.ReadTime > 0 );
CDVDREAD_INT(cdvd.ReadTime/4);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions pcsx2/CDVD/IsoFileFormats.cpp
Expand Up @@ -185,14 +185,14 @@ void isoFile::_ReadBlockD(u8* dst, uint lsn)

void isoFile::_ReadBlock(u8* dst, uint lsn)
{
pxAssumeMsg(lsn <= m_blocks, "Invalid lsn passed into isoFile::_ReadBlock.");
pxAssumeMsg(m_numparts, "Invalid isoFile object state; an iso file needs at least one part!");
pxAssertMsg(lsn <= m_blocks, "Invalid lsn passed into isoFile::_ReadBlock.");
pxAssertMsg(m_numparts, "Invalid isoFile object state; an iso file needs at least one part!");

uint i;
for (i = 0; i < m_numparts-1; ++i)
{
// lsn indexes should always go in order; use an assertion just to be sure:
pxAssume(lsn >= m_parts[i].slsn);
pxAssert(lsn >= m_parts[i].slsn);
if (lsn <= m_parts[i].elsn) break;
}

Expand Down

0 comments on commit c05dc75

Please sign in to comment.