From 1d32b45ca59fb0f5bfd1b5ccbfb854cb77a5b26a Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 17 Jul 2026 14:12:11 +0100 Subject: [PATCH] Add TryCreate* variants of D3D12 descriptor write functions * These are identical to the old versions but with a return value, so we can share the implementation and have a common path just with a bool, and discard the return value as needed. * In the new path, only successful writes will be serialised. --- renderdoc/driver/d3d12/d3d12_commands.cpp | 6 + renderdoc/driver/d3d12/d3d12_common.h | 6 + renderdoc/driver/d3d12/d3d12_device.cpp | 6 + renderdoc/driver/d3d12/d3d12_device.h | 64 ++++++ renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 200 +++++++++++++++--- .../driver/d3d12/d3d12_device_wrap11.cpp | 33 ++- .../driver/d3d12/d3d12_device_wrap15.cpp | 39 ++++ renderdoc/driver/d3d12/d3d12_device_wrap8.cpp | 21 +- renderdoc/driver/d3d12/d3d12_stringise.cpp | 13 +- .../driver/d3d12/renderdoc_d3d12.vcxproj | 1 + .../d3d12/renderdoc_d3d12.vcxproj.filters | 3 + 11 files changed, 354 insertions(+), 38 deletions(-) create mode 100644 renderdoc/driver/d3d12/d3d12_device_wrap15.cpp diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index ca40841a5..57e467384 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -753,6 +753,12 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu case D3D12Chunk::Device_CreateDepthStencilView: case D3D12Chunk::Device_CreateSampler: case D3D12Chunk::Device_CreateSampler2: + case D3D12Chunk::Device_TryCreateShaderResourceView: + case D3D12Chunk::Device_TryCreateUnorderedAccessView: + case D3D12Chunk::Device_TryCreateConstantBufferView: + case D3D12Chunk::Device_TryCreateSampler2: + case D3D12Chunk::Device_TryCreateRenderTargetView: + case D3D12Chunk::Device_TryCreateDepthStencilView: ret = m_pDevice->Serialise_DynamicDescriptorWrite(ser, NULL); break; case D3D12Chunk::Device_CopyDescriptors: diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 3a5463316..ddcffa969 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -1324,5 +1324,11 @@ enum class D3D12Chunk : uint32_t List_DispatchGraph, SetQueueAnnotation, SetCommandAnnotation, + Device_TryCreateShaderResourceView, + Device_TryCreateUnorderedAccessView, + Device_TryCreateConstantBufferView, + Device_TryCreateSampler2, + Device_TryCreateRenderTargetView, + Device_TryCreateDepthStencilView, Max, }; diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 6b79b25d7..c15a0f750 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -5322,6 +5322,12 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context) case D3D12Chunk::List_DispatchGraph: case D3D12Chunk::SetCommandAnnotation: case D3D12Chunk::SetQueueAnnotation: + case D3D12Chunk::Device_TryCreateShaderResourceView: + case D3D12Chunk::Device_TryCreateUnorderedAccessView: + case D3D12Chunk::Device_TryCreateConstantBufferView: + case D3D12Chunk::Device_TryCreateSampler2: + case D3D12Chunk::Device_TryCreateRenderTargetView: + case D3D12Chunk::Device_TryCreateDepthStencilView: RDCERR("Unexpected chunk while processing initialisation: %s", ToStr(context).c_str()); return false; diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index b6ee96d6e..70d4920e3 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -1947,6 +1947,70 @@ public: _In_ SIZE_T blobLengthInBytes, _In_opt_ LPCWSTR subobjectName, REFIID riid, _COM_Outptr_ void **ppvRootSignature); + ////////////////////////////// + // implement ID3D12Device15 + + virtual HRESULT STDMETHODCALLTYPE + RegisterTrimNotificationCallback(D3D12_REGISTER_TRIM_NOTIFICATION *pData); + + virtual HRESULT STDMETHODCALLTYPE UnregisterTrimNotificationCallback(DWORD CallbackCookie); + + // the TryCreate* variants forward into a common implementation with an extra bool flag + + virtual HRESULT STDMETHODCALLTYPE TryCreateShaderResourceView( + ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE TryCreateUnorderedAccessView( + ID3D12Resource *pResource, ID3D12Resource *pCounterResource, + const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE TryCreateConstantBufferView( + const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE TryCreateSampler2(const D3D12_SAMPLER_DESC2 *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE + TryCreateRenderTargetView(ID3D12Resource *pResource, const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE + TryCreateDepthStencilView(ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + virtual HRESULT STDMETHODCALLTYPE TryCreateSamplerFeedbackUnorderedAccessView( + ID3D12Resource *pTargetedResource, ID3D12Resource *pFeedbackResource, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + // internal functions + HRESULT CreateShaderResourceView(bool tryCall, ID3D12Resource *pResource, + const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateUnorderedAccessView(bool tryCall, ID3D12Resource *pResource, + ID3D12Resource *pCounterResource, + const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateConstantBufferView(bool tryCall, const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateSampler2(bool tryCall, const D3D12_SAMPLER_DESC2 *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateRenderTargetView(bool tryCall, ID3D12Resource *pResource, + const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateDepthStencilView(bool tryCall, ID3D12Resource *pResource, + const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + HRESULT CreateSamplerFeedbackUnorderedAccessView(bool tryCall, ID3D12Resource *pTargetedResource, + ID3D12Resource *pFeedbackResource, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + ////////////////////////////// // implement ID3D12DeviceTools virtual void STDMETHODCALLTYPE SetNextAllocationAddress(UINT64 pVirtualAddress) diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index 6ade5c21b..ae28052e1 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -1397,9 +1397,24 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorWrite(SerialiserType &ser, return true; } -void WrappedID3D12Device::CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, - D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +HRESULT WrappedID3D12Device::CreateConstantBufferView(bool tryCall, + const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL(hr = m_pDevice15->TryCreateConstantBufferView(pDesc, Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL(m_pDevice->CreateConstantBufferView(pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { @@ -1407,8 +1422,6 @@ void WrappedID3D12Device::CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_V capframe = IsActiveCapturing(m_State); } - SERIALISE_TIME_CALL(m_pDevice->CreateConstantBufferView(pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -1435,22 +1448,36 @@ void WrappedID3D12Device::CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_V } GetWrapped(DestDescriptor)->Init(pDesc); + + return hr; } -void WrappedID3D12Device::CreateShaderResourceView(ID3D12Resource *pResource, - const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, - D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +HRESULT WrappedID3D12Device::CreateShaderResourceView(bool tryCall, ID3D12Resource *pResource, + const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL(hr = m_pDevice15->TryCreateShaderResourceView(Unwrap(pResource), pDesc, + Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL( + m_pDevice->CreateShaderResourceView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { SCOPED_READLOCK(m_CapTransitionLock); capframe = IsActiveCapturing(m_State); } - - SERIALISE_TIME_CALL( - m_pDevice->CreateShaderResourceView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -1483,23 +1510,38 @@ void WrappedID3D12Device::CreateShaderResourceView(ID3D12Resource *pResource, pDesc->ViewDimension == D3D12_SRV_DIMENSION_TEXTURECUBEARRAY) m_Cubemaps.insert(GetResID(pResource)); } + + return hr; } -void WrappedID3D12Device::CreateUnorderedAccessView(ID3D12Resource *pResource, - ID3D12Resource *pCounterResource, - const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, - D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +HRESULT WrappedID3D12Device::CreateUnorderedAccessView(bool tryCall, ID3D12Resource *pResource, + ID3D12Resource *pCounterResource, + const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL( + hr = m_pDevice15->TryCreateUnorderedAccessView(Unwrap(pResource), Unwrap(pCounterResource), + pDesc, Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL(m_pDevice->CreateUnorderedAccessView( + Unwrap(pResource), Unwrap(pCounterResource), pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { SCOPED_READLOCK(m_CapTransitionLock); capframe = IsActiveCapturing(m_State); } - - SERIALISE_TIME_CALL(m_pDevice->CreateUnorderedAccessView( - Unwrap(pResource), Unwrap(pCounterResource), pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -1528,22 +1570,36 @@ void WrappedID3D12Device::CreateUnorderedAccessView(ID3D12Resource *pResource, } GetWrapped(DestDescriptor)->Init(pResource, pCounterResource, pDesc); + + return hr; } -void WrappedID3D12Device::CreateRenderTargetView(ID3D12Resource *pResource, - const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, - D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +HRESULT WrappedID3D12Device::CreateRenderTargetView(bool tryCall, ID3D12Resource *pResource, + const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL(hr = m_pDevice15->TryCreateRenderTargetView(Unwrap(pResource), pDesc, + Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL( + m_pDevice->CreateRenderTargetView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { SCOPED_READLOCK(m_CapTransitionLock); capframe = IsActiveCapturing(m_State); } - - SERIALISE_TIME_CALL( - m_pDevice->CreateRenderTargetView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -1569,22 +1625,36 @@ void WrappedID3D12Device::CreateRenderTargetView(ID3D12Resource *pResource, } GetWrapped(DestDescriptor)->Init(pResource, pDesc); + + return hr; } -void WrappedID3D12Device::CreateDepthStencilView(ID3D12Resource *pResource, - const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, - D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +HRESULT WrappedID3D12Device::CreateDepthStencilView(bool tryCall, ID3D12Resource *pResource, + const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL(hr = m_pDevice15->TryCreateDepthStencilView(Unwrap(pResource), pDesc, + Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL( + m_pDevice->CreateDepthStencilView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { SCOPED_READLOCK(m_CapTransitionLock); capframe = IsActiveCapturing(m_State); } - - SERIALISE_TIME_CALL( - m_pDevice->CreateDepthStencilView(Unwrap(pResource), pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -1605,6 +1675,70 @@ void WrappedID3D12Device::CreateDepthStencilView(ID3D12Resource *pResource, } GetWrapped(DestDescriptor)->Init(pResource, pDesc); + + return hr; +} + +// 'real' calls that forward onto internal helpers above that either try or don't + +void STDMETHODCALLTYPE WrappedID3D12Device::CreateConstantBufferView( + const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + CreateConstantBufferView(false, pDesc, DestDescriptor); +} +void STDMETHODCALLTYPE WrappedID3D12Device::CreateShaderResourceView( + ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + CreateShaderResourceView(false, pResource, pDesc, DestDescriptor); +} +void STDMETHODCALLTYPE WrappedID3D12Device::CreateUnorderedAccessView( + ID3D12Resource *pResource, ID3D12Resource *pCounterResource, + const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + CreateUnorderedAccessView(false, pResource, pCounterResource, pDesc, DestDescriptor); +} +void STDMETHODCALLTYPE WrappedID3D12Device::CreateRenderTargetView( + ID3D12Resource *pResource, const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + CreateRenderTargetView(false, pResource, pDesc, DestDescriptor); +} +void STDMETHODCALLTYPE WrappedID3D12Device::CreateDepthStencilView( + ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + CreateDepthStencilView(false, pResource, pDesc, DestDescriptor); +} + +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateConstantBufferView( + const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateConstantBufferView(true, pDesc, DestDescriptor); +} +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateShaderResourceView( + ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateShaderResourceView(true, pResource, pDesc, DestDescriptor); +} +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateUnorderedAccessView( + ID3D12Resource *pResource, ID3D12Resource *pCounterResource, + const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateUnorderedAccessView(true, pResource, pCounterResource, pDesc, DestDescriptor); +} +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateRenderTargetView( + ID3D12Resource *pResource, const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateRenderTargetView(true, pResource, pDesc, DestDescriptor); +} +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateDepthStencilView( + ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateDepthStencilView(true, pResource, pDesc, DestDescriptor); } void WrappedID3D12Device::CreateSampler(const D3D12_SAMPLER_DESC *pDesc, diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap11.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap11.cpp index cb80bef56..062ddf5ff 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap11.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap11.cpp @@ -30,6 +30,32 @@ void WrappedID3D12Device::CreateSampler2(const D3D12_SAMPLER_DESC2 *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { + CreateSampler2(false, pDesc, DestDescriptor); +} + +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateSampler2( + const D3D12_SAMPLER_DESC2 *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateSampler2(true, pDesc, DestDescriptor); +} + +HRESULT WrappedID3D12Device::CreateSampler2(bool tryCall, const D3D12_SAMPLER_DESC2 *pDesc, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + HRESULT hr = S_OK; + if(tryCall) + { + SERIALISE_TIME_CALL(hr = m_pDevice15->TryCreateSampler2(pDesc, Unwrap(DestDescriptor))); + } + else + { + SERIALISE_TIME_CALL(m_pDevice11->CreateSampler2(pDesc, Unwrap(DestDescriptor))); + } + + // don't perform the actual write if it failed + if(FAILED(hr)) + return hr; + bool capframe = false; { @@ -37,8 +63,6 @@ void WrappedID3D12Device::CreateSampler2(const D3D12_SAMPLER_DESC2 *pDesc, capframe = IsActiveCapturing(m_State); } - SERIALISE_TIME_CALL(m_pDevice11->CreateSampler2(pDesc, Unwrap(DestDescriptor))); - // assume descriptors are volatile if(capframe) { @@ -49,7 +73,8 @@ void WrappedID3D12Device::CreateSampler2(const D3D12_SAMPLER_DESC2 *pDesc, { CACHE_THREAD_SERIALISER(); - SCOPED_SERIALISE_CHUNK(D3D12Chunk::Device_CreateSampler2); + SCOPED_SERIALISE_CHUNK(tryCall ? D3D12Chunk::Device_TryCreateSampler2 + : D3D12Chunk::Device_CreateSampler2); Serialise_DynamicDescriptorWrite(ser, &write); m_FrameCaptureRecord->AddChunk(scope.Get()); @@ -57,4 +82,6 @@ void WrappedID3D12Device::CreateSampler2(const D3D12_SAMPLER_DESC2 *pDesc, } GetWrapped(DestDescriptor)->Init(pDesc); + + return hr; } diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap15.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap15.cpp new file mode 100644 index 000000000..bc5dcfaf1 --- /dev/null +++ b/renderdoc/driver/d3d12/d3d12_device_wrap15.cpp @@ -0,0 +1,39 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2026 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "d3d12_device.h" + +// pass these through unmodified +HRESULT STDMETHODCALLTYPE +WrappedID3D12Device::RegisterTrimNotificationCallback(D3D12_REGISTER_TRIM_NOTIFICATION *pData) +{ + return m_pDevice15->RegisterTrimNotificationCallback(pData); +} + +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::UnregisterTrimNotificationCallback(DWORD CallbackCookie) +{ + return m_pDevice15->UnregisterTrimNotificationCallback(CallbackCookie); +} + +// implementations of TryCreate* for descriptors are with their associated non-try functions to share implementations diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap8.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap8.cpp index 763e160a8..84aff967b 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap8.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap8.cpp @@ -39,7 +39,26 @@ void STDMETHODCALLTYPE WrappedID3D12Device::CreateSamplerFeedbackUnorderedAccess _In_opt_ ID3D12Resource *pTargetedResource, _In_opt_ ID3D12Resource *pFeedbackResource, _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) { - RDCERR("CreateSamplerFeedbackUnorderedAccessView called but sampler feedback is not supported!"); + CreateSamplerFeedbackUnorderedAccessView(false, pTargetedResource, pFeedbackResource, + DestDescriptor); +} + +HRESULT STDMETHODCALLTYPE WrappedID3D12Device::TryCreateSamplerFeedbackUnorderedAccessView( + ID3D12Resource *pTargetedResource, ID3D12Resource *pFeedbackResource, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + return CreateSamplerFeedbackUnorderedAccessView(true, pTargetedResource, pFeedbackResource, + DestDescriptor); +} + +HRESULT WrappedID3D12Device::CreateSamplerFeedbackUnorderedAccessView( + bool tryCall, ID3D12Resource *pTargetedResource, ID3D12Resource *pFeedbackResource, + D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) +{ + RDCERR( + "TryCreateSamplerFeedbackUnorderedAccessView called but sampler feedback is not " + "supported!"); + return E_NOINTERFACE; } void STDMETHODCALLTYPE WrappedID3D12Device::GetCopyableFootprints1( diff --git a/renderdoc/driver/d3d12/d3d12_stringise.cpp b/renderdoc/driver/d3d12/d3d12_stringise.cpp index e59b4ea04..48a9d6b29 100644 --- a/renderdoc/driver/d3d12/d3d12_stringise.cpp +++ b/renderdoc/driver/d3d12/d3d12_stringise.cpp @@ -28,7 +28,7 @@ template <> rdcstr DoStringise(const D3D12Chunk &el) { - RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1139, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1145, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(D3D12Chunk) { @@ -244,6 +244,17 @@ rdcstr DoStringise(const D3D12Chunk &el) STRINGISE_ENUM_CLASS_NAMED(List_DispatchGraph, "ID3D12GraphicsCommandList10::DispatchGraph"); STRINGISE_ENUM_CLASS_NAMED(SetCommandAnnotation, "Internal::SetCommandAnnotation"); STRINGISE_ENUM_CLASS_NAMED(SetQueueAnnotation, "Internal::SetQueueAnnotation"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateShaderResourceView, + "ID3D12Device15::TryCreateShaderResourceView"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateUnorderedAccessView, + "ID3D12Device15::TryCreateUnorderedAccessView"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateConstantBufferView, + "ID3D12Device15::TryCreateConstantBufferView"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateSampler2, "ID3D12Device15::TryCreateSampler2"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateRenderTargetView, + "ID3D12Device15::TryCreateRenderTargetView"); + STRINGISE_ENUM_CLASS_NAMED(Device_TryCreateDepthStencilView, + "ID3D12Device15::TryCreateDepthStencilView"); STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk"); } END_ENUM_STRINGISE() diff --git a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj index 495de7276..94df6ea11 100644 --- a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj +++ b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj @@ -121,6 +121,7 @@ + diff --git a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters index 77bcb66e4..c62fab436 100644 --- a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters +++ b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters @@ -254,5 +254,8 @@ Wrapped + + Wrapped + \ No newline at end of file