Skip to content

Commit a8e2e53

Browse files
committed
Added more debug logging for #9085 (Clone failed @ 'dxCreateShader')
1 parent 17f793b commit a8e2e53

File tree

8 files changed

+331
-15
lines changed

8 files changed

+331
-15
lines changed

MTA10/core/CMemStats.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,18 @@ void CMemStats::UpdateFrameStats ( void )
408408

409409
static CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
410410
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
411-
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
411+
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
412+
&m_MemStatsNow.d3dMemory.Effect };
412413

413414
static CProxyDirect3DDevice9::SResourceMemory* const maxList[] = { &m_MemStatsMax.d3dMemory.StaticVertexBuffer, &m_MemStatsMax.d3dMemory.DynamicVertexBuffer,
414415
&m_MemStatsMax.d3dMemory.StaticIndexBuffer, &m_MemStatsMax.d3dMemory.DynamicIndexBuffer,
415-
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture };
416+
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture,
417+
&m_MemStatsMax.d3dMemory.Effect };
416418

417419
CProxyDirect3DDevice9::SResourceMemory* const prevList[] = { &m_MemStatsPrev.d3dMemory.StaticVertexBuffer, &m_MemStatsPrev.d3dMemory.DynamicVertexBuffer,
418420
&m_MemStatsPrev.d3dMemory.StaticIndexBuffer, &m_MemStatsPrev.d3dMemory.DynamicIndexBuffer,
419-
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture };
421+
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture,
422+
&m_MemStatsPrev.d3dMemory.Effect };
420423

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

531534
static const CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
532535
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
533-
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
536+
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
537+
&m_MemStatsNow.d3dMemory.Effect };
534538

535539
static const CProxyDirect3DDevice9::SResourceMemory* const prevList[] = { &m_MemStatsPrev.d3dMemory.StaticVertexBuffer, &m_MemStatsPrev.d3dMemory.DynamicVertexBuffer,
536540
&m_MemStatsPrev.d3dMemory.StaticIndexBuffer, &m_MemStatsPrev.d3dMemory.DynamicIndexBuffer,
537-
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture };
541+
&m_MemStatsPrev.d3dMemory.StaticTexture, &m_MemStatsPrev.d3dMemory.DynamicTexture,
542+
&m_MemStatsPrev.d3dMemory.Effect };
538543

539544
static CProxyDirect3DDevice9::SResourceMemory* const deltaList[] = { &m_MemStatsDelta.d3dMemory.StaticVertexBuffer, &m_MemStatsDelta.d3dMemory.DynamicVertexBuffer,
540545
&m_MemStatsDelta.d3dMemory.StaticIndexBuffer, &m_MemStatsDelta.d3dMemory.DynamicIndexBuffer,
541-
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture };
546+
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture,
547+
&m_MemStatsDelta.d3dMemory.Effect };
542548

543549
static const CProxyDirect3DDevice9::SResourceMemory* const maxList[] = { &m_MemStatsMax.d3dMemory.StaticVertexBuffer, &m_MemStatsMax.d3dMemory.DynamicVertexBuffer,
544550
&m_MemStatsMax.d3dMemory.StaticIndexBuffer, &m_MemStatsMax.d3dMemory.DynamicIndexBuffer,
545-
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture };
551+
&m_MemStatsMax.d3dMemory.StaticTexture, &m_MemStatsMax.d3dMemory.DynamicTexture,
552+
&m_MemStatsMax.d3dMemory.Effect };
546553

547554
for ( uint i = 0 ; i < NUMELMS( nowList ) ; i++ )
548555
{
@@ -697,16 +704,19 @@ void CMemStats::CreateTables ( void )
697704
DynamicIndexBuffer 1 1 1 10 1000
698705
StaticTexture 1 1 1 10 1000
699706
DynamicTexture 1 1 1 10 1000
707+
Effect 1 1 1 10 1000
700708
*/
701-
static const char* const nameList[] = { "Vertices", "Vertices dynamic", "Indices", "Indices dynamic", "Textures", "Textures dynamic" };
709+
static const char* const nameList[] = { "Vertices", "Vertices dynamic", "Indices", "Indices dynamic", "Textures", "Textures dynamic", "Effects" };
702710

703711
static const CProxyDirect3DDevice9::SResourceMemory* const nowList[] = { &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
704712
&m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
705-
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture };
713+
&m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
714+
&m_MemStatsNow.d3dMemory.Effect };
706715

707716
static const CProxyDirect3DDevice9::SResourceMemory* const deltaList[] = { &m_MemStatsDelta.d3dMemory.StaticVertexBuffer, &m_MemStatsDelta.d3dMemory.DynamicVertexBuffer,
708717
&m_MemStatsDelta.d3dMemory.StaticIndexBuffer, &m_MemStatsDelta.d3dMemory.DynamicIndexBuffer,
709-
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture };
718+
&m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture,
719+
&m_MemStatsDelta.d3dMemory.Effect };
710720

711721
m_TableList.push_back ( CDxTable ( "|" ) );
712722
CDxTable& table = m_TableList.back ();

MTA10/core/CProxyDirect3DDevice9.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ interface CProxyDirect3DDevice9 : public IDirect3DDevice9
462462
SResourceMemory DynamicIndexBuffer;
463463
SResourceMemory StaticTexture;
464464
SResourceMemory DynamicTexture;
465+
SResourceMemory Effect;
465466
};
466467

467468
struct SStreamSourceState
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto v1.0
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: core/CProxyDirect3DEffect.cpp
6+
*
7+
* Multi Theft Auto is available from http://www.multitheftauto.com/
8+
*
9+
*****************************************************************************/
10+
11+
#include "StdInc.h"
12+
#include "CProxyDirect3DEffect.h"
13+
14+
15+
/////////////////////////////////////////////////////////////
16+
//
17+
// CProxyDirect3DEffect::CProxyDirect3DEffect
18+
//
19+
//
20+
//
21+
/////////////////////////////////////////////////////////////
22+
CProxyDirect3DEffect::CProxyDirect3DEffect ( IDirect3DDevice9* InD3DDevice9, ID3DXEffect* pOriginal )
23+
: m_stats ( g_pDeviceState->MemoryState.Effect )
24+
{
25+
m_pOriginal = pOriginal;
26+
m_stats.iCurrentCount++;
27+
m_stats.iCreatedCount++;
28+
}
29+
30+
31+
/////////////////////////////////////////////////////////////
32+
//
33+
// CProxyDirect3DEffect::~CProxyDirect3DEffect
34+
//
35+
//
36+
//
37+
/////////////////////////////////////////////////////////////
38+
CProxyDirect3DEffect::~CProxyDirect3DEffect ( void )
39+
{
40+
m_stats.iCurrentCount--;
41+
m_stats.iDestroyedCount++;
42+
}
43+
44+
45+
/////////////////////////////////////////////////////////////
46+
//
47+
// CProxyDirect3DEffect::QueryInterface
48+
//
49+
// Used to find the pointer to the real interface
50+
//
51+
/////////////////////////////////////////////////////////////
52+
HRESULT CProxyDirect3DEffect::QueryInterface ( REFIID riid, void** ppvObj )
53+
{
54+
*ppvObj = NULL;
55+
56+
// Looking for me?
57+
if( riid == CProxyDirect3DEffect_GUID )
58+
{
59+
*ppvObj = this;
60+
return S_OK;
61+
}
62+
63+
return m_pOriginal->QueryInterface ( riid, ppvObj );
64+
}
65+
66+
67+
/////////////////////////////////////////////////////////////
68+
//
69+
// CProxyDirect3DEffect::Release
70+
//
71+
// Delete this object on final release of the original
72+
//
73+
/////////////////////////////////////////////////////////////
74+
ULONG CProxyDirect3DEffect::Release ( void )
75+
{
76+
// Call original function
77+
ULONG count = m_pOriginal->Release ();
78+
79+
if ( count == 0 )
80+
{
81+
// now, the Original Object has deleted itself, so do we here
82+
delete this ; // destructor will be called automatically
83+
}
84+
85+
return count;
86+
}
87+
88+
89+
/////////////////////////////////////////////////////////////
90+
//
91+
// CProxyDirect3DEffect::CloneEffect
92+
//
93+
//
94+
//
95+
/////////////////////////////////////////////////////////////
96+
HRESULT CProxyDirect3DEffect::CloneEffect ( LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect )
97+
{
98+
HRESULT hr = m_pOriginal->CloneEffect( pDevice, ppEffect );
99+
if( SUCCEEDED( hr ) )
100+
{
101+
// Create proxy so we can track when it's finished with
102+
*ppEffect = new CProxyDirect3DEffect( pDevice, *ppEffect );
103+
}
104+
return hr;
105+
}
106+
107+
108+
/////////////////////////////////////////////////////////////
109+
//
110+
// MyD3DXCreateEffectFromFile
111+
//
112+
// Wrap result of orignal function
113+
//
114+
/////////////////////////////////////////////////////////////
115+
HRESULT WINAPI
116+
MyD3DXCreateEffectFromFile(
117+
LPDIRECT3DDEVICE9 pDevice,
118+
LPCSTR pSrcFile,
119+
CONST D3DXMACRO* pDefines,
120+
LPD3DXINCLUDE pInclude,
121+
DWORD Flags,
122+
LPD3DXEFFECTPOOL pPool,
123+
LPD3DXEFFECT* ppEffect,
124+
LPD3DXBUFFER* ppCompilationErrors)
125+
{
126+
HRESULT hr = D3DXCreateEffectFromFile( pDevice, pSrcFile, pDefines, pInclude, Flags, pPool, ppEffect, ppCompilationErrors );
127+
if( SUCCEEDED( hr ) )
128+
{
129+
// Create proxy so we can track when it's finished with
130+
*ppEffect = new CProxyDirect3DEffect( pDevice, *ppEffect );
131+
}
132+
return hr;
133+
}

0 commit comments

Comments
 (0)