Skip to content

Commit

Permalink
Added more debug logging for #9085 (Clone failed @ 'dxCreateShader')
Browse files Browse the repository at this point in the history
  • Loading branch information
ccw808 committed Jan 1, 2016
1 parent 17f793b commit a8e2e53
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 15 deletions.
30 changes: 20 additions & 10 deletions MTA10/core/CMemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,18 @@ void CMemStats::UpdateFrameStats ( void )

static CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
&m_MemStatsNow.d3dMemory.Effect };

static CProxyDirect3DDevice9::SResourceMemory* const maxList[] = { &m_MemStatsMax.d3dMemory.StaticVertexBuffer, &m_MemStatsMax.d3dMemory.DynamicVertexBuffer,
&m_MemStatsMax.d3dMemory.StaticIndexBuffer, &m_MemStatsMax.d3dMemory.DynamicIndexBuffer,
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture };
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture,
&m_MemStatsMax.d3dMemory.Effect };

CProxyDirect3DDevice9::SResourceMemory* const prevList[] = { &m_MemStatsPrev.d3dMemory.StaticVertexBuffer, &m_MemStatsPrev.d3dMemory.DynamicVertexBuffer,
&m_MemStatsPrev.d3dMemory.StaticIndexBuffer, &m_MemStatsPrev.d3dMemory.DynamicIndexBuffer,
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture };
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture,
&m_MemStatsPrev.d3dMemory.Effect };

for ( uint i = 0 ; i < NUMELMS( nowList ) ; i++ )
{
Expand Down Expand Up @@ -530,19 +533,23 @@ void CMemStats::UpdateIntervalStats ( void )

static const CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
&m_MemStatsNow.d3dMemory.Effect };

static const CProxyDirect3DDevice9::SResourceMemory* const prevList[] = { &m_MemStatsPrev.d3dMemory.StaticVertexBuffer, &m_MemStatsPrev.d3dMemory.DynamicVertexBuffer,
&m_MemStatsPrev.d3dMemory.StaticIndexBuffer, &m_MemStatsPrev.d3dMemory.DynamicIndexBuffer,
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture };
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture,
&m_MemStatsPrev.d3dMemory.Effect };

static CProxyDirect3DDevice9::SResourceMemory* const deltaList[] = { &m_MemStatsDelta.d3dMemory.StaticVertexBuffer, &m_MemStatsDelta.d3dMemory.DynamicVertexBuffer,
&m_MemStatsDelta.d3dMemory.StaticIndexBuffer, &m_MemStatsDelta.d3dMemory.DynamicIndexBuffer,
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture };
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture,
&m_MemStatsDelta.d3dMemory.Effect };

static const CProxyDirect3DDevice9::SResourceMemory* const maxList[] = { &m_MemStatsMax.d3dMemory.StaticVertexBuffer, &m_MemStatsMax.d3dMemory.DynamicVertexBuffer,
&m_MemStatsMax.d3dMemory.StaticIndexBuffer, &m_MemStatsMax.d3dMemory.DynamicIndexBuffer,
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture };
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture,
&m_MemStatsMax.d3dMemory.Effect };

for ( uint i = 0 ; i < NUMELMS( nowList ) ; i++ )
{
Expand Down Expand Up @@ -697,16 +704,19 @@ void CMemStats::CreateTables ( void )
DynamicIndexBuffer 1 1 1 10 1000
StaticTexture 1 1 1 10 1000
DynamicTexture 1 1 1 10 1000
Effect 1 1 1 10 1000
*/
static const char* const nameList[] = { "Vertices", "Vertices dynamic", "Indices", "Indices dynamic", "Textures", "Textures dynamic" };
static const char* const nameList[] = { "Vertices", "Vertices dynamic", "Indices", "Indices dynamic", "Textures", "Textures dynamic", "Effects" };

static const CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
&m_MemStatsNow.d3dMemory.Effect };

static const CProxyDirect3DDevice9::SResourceMemory* const deltaList[] = { &m_MemStatsDelta.d3dMemory.StaticVertexBuffer, &m_MemStatsDelta.d3dMemory.DynamicVertexBuffer,
&m_MemStatsDelta.d3dMemory.StaticIndexBuffer, &m_MemStatsDelta.d3dMemory.DynamicIndexBuffer,
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture };
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture,
&m_MemStatsDelta.d3dMemory.Effect };

m_TableList.push_back ( CDxTable ( "|" ) );
CDxTable& table = m_TableList.back ();
Expand Down
1 change: 1 addition & 0 deletions MTA10/core/CProxyDirect3DDevice9.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ interface CProxyDirect3DDevice9 : public IDirect3DDevice9
SResourceMemory DynamicIndexBuffer;
SResourceMemory StaticTexture;
SResourceMemory DynamicTexture;
SResourceMemory Effect;
};

struct SStreamSourceState
Expand Down
133 changes: 133 additions & 0 deletions MTA10/core/CProxyDirect3DEffect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: core/CProxyDirect3DEffect.cpp
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"
#include "CProxyDirect3DEffect.h"


/////////////////////////////////////////////////////////////
//
// CProxyDirect3DEffect::CProxyDirect3DEffect
//
//
//
/////////////////////////////////////////////////////////////
CProxyDirect3DEffect::CProxyDirect3DEffect ( IDirect3DDevice9* InD3DDevice9, ID3DXEffect* pOriginal )
: m_stats ( g_pDeviceState->MemoryState.Effect )
{
m_pOriginal = pOriginal;
m_stats.iCurrentCount++;
m_stats.iCreatedCount++;
}


/////////////////////////////////////////////////////////////
//
// CProxyDirect3DEffect::~CProxyDirect3DEffect
//
//
//
/////////////////////////////////////////////////////////////
CProxyDirect3DEffect::~CProxyDirect3DEffect ( void )
{
m_stats.iCurrentCount--;
m_stats.iDestroyedCount++;
}


/////////////////////////////////////////////////////////////
//
// CProxyDirect3DEffect::QueryInterface
//
// Used to find the pointer to the real interface
//
/////////////////////////////////////////////////////////////
HRESULT CProxyDirect3DEffect::QueryInterface ( REFIID riid, void** ppvObj )
{
*ppvObj = NULL;

// Looking for me?
if( riid == CProxyDirect3DEffect_GUID )
{
*ppvObj = this;
return S_OK;
}

return m_pOriginal->QueryInterface ( riid, ppvObj );
}


/////////////////////////////////////////////////////////////
//
// CProxyDirect3DEffect::Release
//
// Delete this object on final release of the original
//
/////////////////////////////////////////////////////////////
ULONG CProxyDirect3DEffect::Release ( void )
{
// Call original function
ULONG count = m_pOriginal->Release ();

if ( count == 0 )
{
// now, the Original Object has deleted itself, so do we here
delete this ; // destructor will be called automatically
}

return count;
}


/////////////////////////////////////////////////////////////
//
// CProxyDirect3DEffect::CloneEffect
//
//
//
/////////////////////////////////////////////////////////////
HRESULT CProxyDirect3DEffect::CloneEffect ( LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect )
{
HRESULT hr = m_pOriginal->CloneEffect( pDevice, ppEffect );
if( SUCCEEDED( hr ) )
{
// Create proxy so we can track when it's finished with
*ppEffect = new CProxyDirect3DEffect( pDevice, *ppEffect );
}
return hr;
}


/////////////////////////////////////////////////////////////
//
// MyD3DXCreateEffectFromFile
//
// Wrap result of orignal function
//
/////////////////////////////////////////////////////////////
HRESULT WINAPI
MyD3DXCreateEffectFromFile(
LPDIRECT3DDEVICE9 pDevice,
LPCSTR pSrcFile,
CONST D3DXMACRO* pDefines,
LPD3DXINCLUDE pInclude,
DWORD Flags,
LPD3DXEFFECTPOOL pPool,
LPD3DXEFFECT* ppEffect,
LPD3DXBUFFER* ppCompilationErrors)
{
HRESULT hr = D3DXCreateEffectFromFile( pDevice, pSrcFile, pDefines, pInclude, Flags, pPool, ppEffect, ppCompilationErrors );
if( SUCCEEDED( hr ) )
{
// Create proxy so we can track when it's finished with
*ppEffect = new CProxyDirect3DEffect( pDevice, *ppEffect );
}
return hr;
}

0 comments on commit a8e2e53

Please sign in to comment.