From 725c5d12a2636cfae13621a173d640f567cadb4e Mon Sep 17 00:00:00 2001 From: Tanner Van De Walle Date: Fri, 20 Feb 2026 17:11:21 -0800 Subject: [PATCH 1/2] Map DXGI HRESULTS to D3DERR HRESULTS so that d3d9 apps can react appropriately --- include/9on12Util.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/9on12Util.h b/include/9on12Util.h index b4877b2..bc16039 100644 --- a/include/9on12Util.h +++ b/include/9on12Util.h @@ -87,6 +87,26 @@ namespace D3D9on12 Value value; }; + // + // Translates DXGI error codes to their D3D9 equivalents so that the + // correct HRESULTs propagate to the D3D9 runtime. Non-DXGI codes pass + // through unchanged. + // + // Not an exhuastive list, but the ones most likely to be hit + // + inline HRESULT TranslateDxgiHrToD3D9(HRESULT hr) + { + switch (hr) + { + case DXGI_ERROR_DEVICE_REMOVED: return D3DERR_DEVICEREMOVED; + case DXGI_ERROR_DEVICE_HUNG: return D3DERR_DEVICEHUNG; + case DXGI_ERROR_DEVICE_RESET: return D3DERR_DEVICELOST; + case DXGI_ERROR_DRIVER_INTERNAL_ERROR: return D3DERR_DRIVERINTERNALERROR; + case DXGI_ERROR_INVALID_CALL: return D3DERR_DRIVERINTERNALERROR; // This is a driver error from the app's perspective as it means that 9on12 made an invalid call + default: return hr; + } + } + #define D3D9on12_DDI_ENTRYPOINT_START(implemented) \ __pragma(warning(suppress:4127)) /* conditional is constant due to constant macro parameter(s) */ \ if((implemented) == false && RegistryConstants::g_cBreakOnMissingDDI) \ @@ -114,6 +134,7 @@ __pragma(warning(suppress:4127)) /* conditional is constant due to constant macr { \ EntryPointHr = E_OUTOFMEMORY; \ } \ + EntryPointHr = TranslateDxgiHrToD3D9(EntryPointHr); \ #define D3D9on12_DDI_ENTRYPOINT_END_AND_RETURN_HR(hr) \ CLOSE_TRYCATCH_AND_STORE_HRESULT(hr) \ From be801736dbf929dde29e54b174f0941f057a6fd3 Mon Sep 17 00:00:00 2001 From: Tanner Van De Walle Date: Mon, 23 Feb 2026 10:30:46 -0800 Subject: [PATCH 2/2] use D3DDDIERR where we can --- include/9on12Util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/9on12Util.h b/include/9on12Util.h index bc16039..5255024 100644 --- a/include/9on12Util.h +++ b/include/9on12Util.h @@ -98,7 +98,7 @@ namespace D3D9on12 { switch (hr) { - case DXGI_ERROR_DEVICE_REMOVED: return D3DERR_DEVICEREMOVED; + case DXGI_ERROR_DEVICE_REMOVED: return D3DDDIERR_DEVICEREMOVED; case DXGI_ERROR_DEVICE_HUNG: return D3DERR_DEVICEHUNG; case DXGI_ERROR_DEVICE_RESET: return D3DERR_DEVICELOST; case DXGI_ERROR_DRIVER_INTERNAL_ERROR: return D3DERR_DRIVERINTERNALERROR;