diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index a3140a2f8..c28cea4b2 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -4172,7 +4172,8 @@ void WrappedID3D12Device::CreateInternalResources() m_GPUSyncCounter = 0; - GetShaderCache()->SetDevConfiguration(m_Replay->GetDevConfiguration()); + if(IsReplayMode(m_State)) + GetShaderCache()->SetDevConfiguration(m_Replay->GetDevConfiguration()); if(m_TextRenderer == NULL) m_TextRenderer = new D3D12TextRenderer(this); diff --git a/renderdoc/driver/d3d12/d3d12_hooks.cpp b/renderdoc/driver/d3d12/d3d12_hooks.cpp index cc2d428f9..d985401e6 100644 --- a/renderdoc/driver/d3d12/d3d12_hooks.cpp +++ b/renderdoc/driver/d3d12/d3d12_hooks.cpp @@ -28,6 +28,8 @@ #include "serialise/serialiser.h" #include "d3d12_command_queue.h" #include "d3d12_device.h" +#include "d3d12_replay.h" +#include "d3d12_shader_cache.h" #include "driver/dx/official/D3D11On12On7.h" @@ -396,12 +398,18 @@ public: } } - return CreateD3D12_Internal( + D3D12DevConfiguration devConfig; + devConfig.devfactory = this; + devConfig.devconfig = &config; + + HRESULT ret = CreateD3D12_Internal( [this](IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void **ppDevice) { return m_pReal->CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice); }, - adapter, FeatureLevel, riid, ppvDevice); + &devConfig, adapter, FeatureLevel, riid, ppvDevice); + + return ret; } }; @@ -625,12 +633,13 @@ private: return true; } - friend HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, IUnknown *pAdapter, - D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, - void **ppDevice); + friend HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, D3D12DevConfiguration *devConfig, + IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, + REFIID riid, void **ppDevice); - HRESULT Create_Internal(RealD3D12CreateFunction real, IUnknown *pAdapter, - D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void **ppDevice) + HRESULT Create_Internal(RealD3D12CreateFunction real, D3D12DevConfiguration *devConfig, + IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, + void **ppDevice) { // if we're already inside a wrapped create i.e. this function, then DON'T do anything // special. Just grab the trampolined function and call it. @@ -739,6 +748,13 @@ private: WrappedID3D12Device *wrap = WrappedID3D12Device::Create(dev, params, EnableDebugLayer); + if(devConfig) + { + D3D12DevConfiguration *cfg = new D3D12DevConfiguration(*devConfig); + wrap->GetReplay()->SetDevConfiguration(cfg); + wrap->GetShaderCache()->SetDevConfiguration(cfg); + } + RDCDEBUG("created wrapped device."); *ppDevice = (ID3D12Device *)wrap; @@ -803,7 +819,8 @@ private: } } - return d3d12hooks.Create_Internal(createFunc, pAdapter, MinimumFeatureLevel, riid, ppDevice); + return d3d12hooks.Create_Internal(createFunc, NULL, pAdapter, MinimumFeatureLevel, riid, + ppDevice); } static HRESULT WINAPI D3D12EnableExperimentalFeatures_hook(UINT NumFeatures, const IID *pIIDs, @@ -880,10 +897,12 @@ private: D3D12Hook D3D12Hook::d3d12hooks; -HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, IUnknown *pAdapter, - D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void **ppDevice) +HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, D3D12DevConfiguration *devConfig, + IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, + void **ppDevice) { - return D3D12Hook::d3d12hooks.Create_Internal(real, pAdapter, MinimumFeatureLevel, riid, ppDevice); + return D3D12Hook::d3d12hooks.Create_Internal(real, devConfig, pAdapter, MinimumFeatureLevel, riid, + ppDevice); } HRESULT STDMETHODCALLTYPE WrappedID3D12DeviceFactory::GetConfigurationInterface( diff --git a/renderdoc/driver/d3d12/d3d12_hooks.h b/renderdoc/driver/d3d12/d3d12_hooks.h index b6f8ebc24..b9f3cc847 100644 --- a/renderdoc/driver/d3d12/d3d12_hooks.h +++ b/renderdoc/driver/d3d12/d3d12_hooks.h @@ -28,6 +28,8 @@ #include "driver/dx/official/d3d12.h" #include "driver/dx/official/dxgi.h" +struct D3D12DevConfiguration; + // this is the type of the lambda we use to route the call out to the 'real' function inside our // generic wrapper. // Could be any of D3D12CreateDevice or the AMD wrapper @@ -35,8 +37,9 @@ typedef std::function RealD3D12CreateFunction; -HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, IUnknown *pAdapter, - D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, void **ppDevice); +HRESULT CreateD3D12_Internal(RealD3D12CreateFunction real, D3D12DevConfiguration *devConfig, + IUnknown *pAdapter, D3D_FEATURE_LEVEL MinimumFeatureLevel, REFIID riid, + void **ppDevice); struct ID3DDevice; diff --git a/renderdoc/driver/d3d12/d3d12_replay.h b/renderdoc/driver/d3d12/d3d12_replay.h index 1650a044b..51175dfaa 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.h +++ b/renderdoc/driver/d3d12/d3d12_replay.h @@ -95,6 +95,7 @@ public: D3D12Replay(WrappedID3D12Device *d); D3D12DevConfiguration *GetDevConfiguration() { return m_DevConfig; } + void SetDevConfiguration(D3D12DevConfiguration *config) { m_DevConfig = config; } D3D12DebugManager *GetDebugManager() { return m_DebugManager; } void SetRGP(AMDRGPControl *rgp) { m_RGP = rgp; } diff --git a/renderdoc/driver/ihv/amd/amd_hooks.cpp b/renderdoc/driver/ihv/amd/amd_hooks.cpp index a5174db92..b94db58cb 100644 --- a/renderdoc/driver/ihv/amd/amd_hooks.cpp +++ b/renderdoc/driver/ihv/amd/amd_hooks.cpp @@ -325,7 +325,7 @@ private: return S_OK; }, - creationParams->pAdapter, creationParams->FeatureLevel, __uuidof(ID3D12Device), + NULL, creationParams->pAdapter, creationParams->FeatureLevel, __uuidof(ID3D12Device), (void **)&dev); returnedParams->pDevice = dev;