d3d12: Implement ID3D12SharingContract on the ID3D12CommandQueue

https://learn.microsoft.com/en-us/windows/win32/api/d3d12sdklayers/nn-d3d12sdklayers-id3d12sharingcontract
says:

> You may want to use this interface to enable diagnostic tools to
> capture usage patterns that don't use DXGI swap chains for
> presentation. If so, you can access this interface via
> QueryInterface from a D3D12 command queue.

Currently, this is implemented on the ID3D12Device. Implement
it on the D3D12CommandQueue as well.
This commit is contained in:
Jasper St. Pierre
2025-12-20 12:05:03 -08:00
committed by Baldur Karlsson
parent 1b5543e74f
commit f5c73155b5
3 changed files with 26 additions and 8 deletions
@@ -183,6 +183,7 @@ class WrappedID3D12CommandQueue : public ID3D12CommandQueue1,
WrappedID3D12DebugCommandQueue m_WrappedDebug;
WrappedID3D12CompatibilityQueue m_WrappedCompat;
WrappedID3D12SharingContract m_SharingContract;
rdcarray<D3D12ResourceRecord *> m_CmdListRecords;
rdcarray<D3D12ResourceRecord *> m_CmdListAllocators;
+10 -1
View File
@@ -499,7 +499,8 @@ WrappedID3D12CommandQueue::WrappedID3D12CommandQueue(ID3D12CommandQueue *real,
m_pDevice(device),
m_State(state),
m_WrappedDownlevel(*this),
m_WrappedCompat(*this)
m_WrappedCompat(*this),
m_SharingContract(*m_pDevice)
{
RenderDoc::Inst().RegisterMemoryRegion(this, sizeof(WrappedID3D12CommandQueue));
@@ -513,6 +514,7 @@ WrappedID3D12CommandQueue::WrappedID3D12CommandQueue(ID3D12CommandQueue *real,
m_pReal->QueryInterface(__uuidof(ID3D12CommandQueueDownlevel), (void **)&m_pDownlevel);
m_pReal->QueryInterface(__uuidof(ID3D12CommandQueue1), (void **)&m_pReal1);
m_pReal->QueryInterface(__uuidof(ID3D12CompatibilityQueue), (void **)&m_WrappedCompat.m_pReal);
m_pReal->QueryInterface(__uuidof(ID3D12SharingContract), (void **)&m_SharingContract.m_pReal);
}
if(RenderDoc::Inst().IsReplayApp())
@@ -573,6 +575,7 @@ WrappedID3D12CommandQueue::~WrappedID3D12CommandQueue()
SAFE_RELEASE(m_WrappedCompat.m_pReal);
SAFE_RELEASE(m_WrappedDebug.m_pReal);
SAFE_RELEASE(m_WrappedDebug.m_pReal1);
SAFE_RELEASE(m_SharingContract.m_pReal);
SAFE_RELEASE(m_pReal);
}
@@ -629,6 +632,12 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12CommandQueue::QueryInterface(REFIID riid,
return E_NOINTERFACE;
}
}
else if(riid == __uuidof(ID3D12SharingContract))
{
*ppvObject = (ID3D12SharingContract *)&m_SharingContract;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12Pageable))
{
*ppvObject = (ID3D12Pageable *)this;
+15 -7
View File
@@ -301,25 +301,29 @@ void STDMETHODCALLTYPE WrappedID3D12SharingContract::Present(_In_ ID3D12Resource
m_pDevice.Present(NULL, this, 0, 0);
m_pReal->Present(Unwrap(pResource), Subresource, window);
if(m_pReal != NULL)
m_pReal->Present(Unwrap(pResource), Subresource, window);
}
void STDMETHODCALLTYPE WrappedID3D12SharingContract::SharedFenceSignal(_In_ ID3D12Fence *pFence,
UINT64 FenceValue)
{
m_pReal->SharedFenceSignal(Unwrap(pFence), FenceValue);
if(m_pReal != NULL)
m_pReal->SharedFenceSignal(Unwrap(pFence), FenceValue);
}
void STDMETHODCALLTYPE WrappedID3D12SharingContract::BeginCapturableWork(_In_ REFGUID guid)
{
// undocumented what this does
m_pReal->BeginCapturableWork(guid);
if(m_pReal != NULL)
m_pReal->BeginCapturableWork(guid);
}
void STDMETHODCALLTYPE WrappedID3D12SharingContract::EndCapturableWork(_In_ REFGUID guid)
{
// undocumented what this does
m_pReal->EndCapturableWork(guid);
if(m_pReal != NULL)
m_pReal->EndCapturableWork(guid);
}
HRESULT STDMETHODCALLTYPE WrappedDRED::QueryInterface(REFIID riid, void **ppvObject)
@@ -1990,9 +1994,13 @@ IUnknown *WrappedID3D12Device::WrapSwapchainBuffer(IDXGISwapper *swapper, DXGI_F
FreeRTV(m_SwapChains[swapper].rtvs[buffer]);
m_SwapChains[swapper].rtvs[buffer] = rtv;
ID3DDevice *swapQ = swapper->GetD3DDevice();
RDCASSERT(WrappedID3D12CommandQueue::IsAlloc(swapQ));
m_SwapChains[swapper].queue = (WrappedID3D12CommandQueue *)swapQ;
ID3DDevice *swapDev = swapper->GetD3DDevice();
if(WrappedID3D12CommandQueue::IsAlloc(swapDev))
m_SwapChains[swapper].queue = (WrappedID3D12CommandQueue *)swapDev;
else if(swapDev == this)
m_SwapChains[swapper].queue = m_Queue;
else
RDCERR("Unexpected swapper D3D device");
}
return pRes;