Skip to content

Commit d316c8d

Browse files
committed
Add warnings to D3d9to9Ex
1 parent a04bef0 commit d316c8d

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

Dllmain/BuildNo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define BUILD_NUMBER 8155
1+
#define BUILD_NUMBER 8156

d3d9/IDirect3D9Ex.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ HRESULT m_IDirect3D9Ex::GetAdapterLUID(THIS_ UINT Adapter, LUID * pLUID)
417417

418418
void m_IDirect3D9Ex::InitInterface()
419419
{
420+
if (Config.D3d9to9Ex && !IsForcingD3d9to9Ex())
421+
{
422+
LOG_LIMIT(3, __FUNCTION__ << " Warning: Creating non-Ex interface when using D3d9to9Ex!");
423+
}
424+
420425
ProxyAddressLookupTable9.SaveAddress(this, ProxyInterface);
421426
}
422427

d3d9/IDirect3DDevice9Ex.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,23 @@ HRESULT m_IDirect3DDevice9Ex::GetDisplayMode(THIS_ UINT iSwapChain, D3DDISPLAYMO
232232
{
233233
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";
234234

235-
if (IsForcingD3d9to9Ex() && pMode)
235+
if (IsForcingD3d9to9Ex())
236236
{
237237
D3DDISPLAYMODEEX ModeEx = {};
238238
ModeEx.Size = sizeof(D3DDISPLAYMODEEX);
239+
D3DDISPLAYMODEEX* pModeEx = pMode ? &ModeEx : nullptr;
240+
239241
D3DDISPLAYROTATION Rotation = D3DDISPLAYROTATION_IDENTITY;
242+
D3DDISPLAYROTATION* pRotation = pMode ? &Rotation : nullptr;
240243

241-
HRESULT hr = GetDisplayModeEx(iSwapChain, &ModeEx, &Rotation);
244+
HRESULT hr = GetDisplayModeEx(iSwapChain, pModeEx, pRotation);
242245

243246
if (SUCCEEDED(hr))
244247
{
245-
ModeExToMode(ModeEx, *pMode);
248+
if (pMode)
249+
{
250+
ModeExToMode(ModeEx, *pMode);
251+
}
246252

247253
return hr;
248254
}
@@ -414,16 +420,20 @@ HRESULT m_IDirect3DDevice9Ex::Reset(D3DPRESENT_PARAMETERS* pPresentationParamete
414420
{
415421
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";
416422

417-
if (IsForcingD3d9to9Ex() && pPresentationParameters)
423+
if (IsForcingD3d9to9Ex())
418424
{
419425
D3DDISPLAYMODEEX FullscreenDisplayMode = {};
426+
D3DDISPLAYMODEEX* pFullscreenDisplayMode = nullptr;
420427

421-
m_IDirect3D9Ex::GetFullscreenDisplayMode(*pPresentationParameters, FullscreenDisplayMode);
422-
423-
if (SUCCEEDED(ResetEx(pPresentationParameters, &FullscreenDisplayMode)))
428+
if (pPresentationParameters)
424429
{
425-
return D3D_OK;
430+
pFullscreenDisplayMode = &FullscreenDisplayMode;
431+
m_IDirect3D9Ex::GetFullscreenDisplayMode(*pPresentationParameters, FullscreenDisplayMode);
426432
}
433+
434+
LOG_LIMIT(3, __FUNCTION__ << " Warning: Calling Reset() when using D3d9to9Ex. Managed interfaces converted to the default pool will be lost!");
435+
436+
return ResetEx(pPresentationParameters, pFullscreenDisplayMode);
427437
}
428438

429439
return ResetT<fReset>(nullptr, pPresentationParameters, false, nullptr);
@@ -3420,6 +3430,11 @@ void m_IDirect3DDevice9Ex::SetEnvironmentCubeMapTexture()
34203430
// Runs when device is created and on every successful Reset()
34213431
void m_IDirect3DDevice9Ex::ReInitInterface()
34223432
{
3433+
if (Config.D3d9to9Ex && !IsForcingD3d9to9Ex())
3434+
{
3435+
LOG_LIMIT(3, __FUNCTION__ << " Warning: Creating non-Ex interface when using D3d9to9Ex!");
3436+
}
3437+
34233438
Utils::GetScreenSize(SHARED.hMonitor, SHARED.screenWidth, SHARED.screenHeight);
34243439

34253440
IsGammaSet = false;

d3d9/IDirect3DSwapChain9Ex.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,23 @@ HRESULT m_IDirect3DSwapChain9Ex::GetDisplayMode(THIS_ D3DDISPLAYMODE* pMode)
130130
{
131131
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";
132132

133-
if (IsForcingD3d9to9Ex() && pMode)
133+
if (IsForcingD3d9to9Ex())
134134
{
135135
D3DDISPLAYMODEEX ModeEx = {};
136136
ModeEx.Size = sizeof(D3DDISPLAYMODEEX);
137+
D3DDISPLAYMODEEX* pModeEx = pMode ? &ModeEx : nullptr;
138+
137139
D3DDISPLAYROTATION Rotation = D3DDISPLAYROTATION_IDENTITY;
140+
D3DDISPLAYROTATION* pRotation = pMode ? &Rotation : nullptr;
138141

139-
HRESULT hr = GetDisplayModeEx(&ModeEx, &Rotation);
142+
HRESULT hr = GetDisplayModeEx(pModeEx, pRotation);
140143

141144
if (SUCCEEDED(hr))
142145
{
143-
m_IDirect3DDevice9Ex::ModeExToMode(ModeEx, *pMode);
146+
if (pMode)
147+
{
148+
m_IDirect3DDevice9Ex::ModeExToMode(ModeEx, *pMode);
149+
}
144150

145151
return hr;
146152
}

d3d9/IDirect3DSwapChain9Ex.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ class m_IDirect3DSwapChain9Ex : public IDirect3DSwapChain9Ex, public AddressLook
5757
{
5858
ProxyInterfaceEx = nullptr;
5959
}
60+
if (Config.D3d9to9Ex && !IsForcingD3d9to9Ex())
61+
{
62+
LOG_LIMIT(3, __FUNCTION__ << " Warning: Creating non-Ex interface when using D3d9to9Ex!");
63+
}
6064
}
6165
};

0 commit comments

Comments
 (0)