Wrap and intercept command lists and queues, and add a couple of unwraps

* At this point the HelloD3D12 sample runs with RenderDoc injected, and
  renders properly.
This commit is contained in:
baldurk
2016-07-05 19:32:25 +03:00
parent f8fa72c305
commit 3a65091b3c
10 changed files with 782 additions and 88 deletions
+132 -1
View File
@@ -26,10 +26,74 @@
#include "common/wrapped_pool.h"
#include "d3d12_common.h"
#include "d3d12_device.h"
#include "d3d12_resources.h"
class WrappedID3D12GraphicsCommandList;
struct DummyID3D12DebugCommandList : public ID3D12DebugCommandList
{
WrappedID3D12GraphicsCommandList *m_pList;
ID3D12DebugCommandList *m_pReal;
DummyID3D12DebugCommandList() {}
//////////////////////////////
// implement IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)
{
if(riid == __uuidof(ID3D12DebugCommandList))
{
*ppvObject = (ID3D12DebugCommandList *)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
//////////////////////////////
// implement ID3D12DebugCommandList
virtual BOOL STDMETHODCALLTYPE AssertResourceState(ID3D12Resource *pResource, UINT Subresource,
UINT State)
{
if(m_pReal)
m_pReal->AssertResourceState(pResource, Subresource, State);
return TRUE;
}
virtual HRESULT STDMETHODCALLTYPE SetFeatureMask(D3D12_DEBUG_FEATURE Mask)
{
if(m_pReal)
m_pReal->SetFeatureMask(Mask);
return S_OK;
}
virtual D3D12_DEBUG_FEATURE STDMETHODCALLTYPE GetFeatureMask()
{
if(m_pReal)
return m_pReal->GetFeatureMask();
return D3D12_DEBUG_FEATURE_NONE;
}
};
class WrappedID3D12GraphicsCommandList : public RefCounter12<ID3D12GraphicsCommandList>,
public ID3D12GraphicsCommandList
{
ID3D12GraphicsCommandList *m_pList;
WrappedID3D12Device *m_pDevice;
ResourceId m_ResourceID;
D3D12ResourceRecord *m_ListRecord;
Serialiser *m_pSerialiser;
LogState m_State;
DummyID3D12DebugCommandList m_DummyDebug;
public:
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12GraphicsCommandList);
@@ -37,6 +101,68 @@ public:
Serialiser *serialiser);
virtual ~WrappedID3D12GraphicsCommandList();
Serialiser *GetSerialiser() { return m_pSerialiser; }
ResourceId GetResourceID() { return m_ResourceID; }
ID3D12GraphicsCommandList *GetReal() { return m_pList; }
WrappedID3D12Device *GetWrappedDevice() { return m_pDevice; }
//////////////////////////////
// implement IUnknown
ULONG STDMETHODCALLTYPE AddRef() { return RefCounter12::SoftRef(m_pDevice); }
ULONG STDMETHODCALLTYPE Release() { return RefCounter12::SoftRelease(m_pDevice); }
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
//////////////////////////////
// implement ID3D12Object
HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData)
{
return m_pList->GetPrivateData(guid, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
{
if(guid == WKPDID_D3DDebugObjectName)
m_pDevice->SetResourceName(this, (const char *)pData);
return m_pList->SetPrivateData(guid, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown *pData)
{
return m_pList->SetPrivateDataInterface(guid, pData);
}
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
{
string utf8 = StringFormat::Wide2UTF8(Name);
m_pDevice->SetResourceName(this, utf8.c_str());
return m_pList->SetName(Name);
}
//////////////////////////////
// implement ID3D12DeviceChild
virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice)
{
if(riid == __uuidof(ID3D12Device) && ppvDevice)
{
*ppvDevice = (ID3D12Device *)m_pDevice;
m_pDevice->AddRef();
}
else if(riid != __uuidof(ID3D12Device))
{
return E_NOINTERFACE;
}
return E_INVALIDARG;
}
//////////////////////////////
// implement ID3D12CommandList
virtual D3D12_COMMAND_LIST_TYPE STDMETHODCALLTYPE GetType() { return m_pList->GetType(); }
//////////////////////////////
// implement ID3D12GraphicsCommandList
@@ -262,4 +388,9 @@ public:
UINT64 ArgumentBufferOffset,
ID3D12Resource *pCountBuffer,
UINT64 CountBufferOffset));
};
};
template <>
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList *obj);
template <>
ID3D12CommandList *Unwrap(ID3D12CommandList *obj);
@@ -37,15 +37,15 @@ HRESULT WrappedID3D12GraphicsCommandList::Reset(ID3D12CommandAllocator *pAllocat
void WrappedID3D12GraphicsCommandList::ClearState(ID3D12PipelineState *pPipelineState)
{
return m_pReal->ClearState(pPipelineState);
m_pReal->ClearState(pPipelineState);
}
void WrappedID3D12GraphicsCommandList::DrawInstanced(UINT VertexCountPerInstance,
UINT InstanceCount, UINT StartVertexLocation,
UINT StartInstanceLocation)
{
return m_pReal->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation,
StartInstanceLocation);
m_pReal->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation,
StartInstanceLocation);
}
void WrappedID3D12GraphicsCommandList::DrawIndexedInstanced(UINT IndexCountPerInstance,
@@ -54,21 +54,21 @@ void WrappedID3D12GraphicsCommandList::DrawIndexedInstanced(UINT IndexCountPerIn
INT BaseVertexLocation,
UINT StartInstanceLocation)
{
return m_pReal->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation,
BaseVertexLocation, StartInstanceLocation);
m_pReal->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation,
BaseVertexLocation, StartInstanceLocation);
}
void WrappedID3D12GraphicsCommandList::Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY,
UINT ThreadGroupCountZ)
{
return m_pReal->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
m_pReal->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
}
void WrappedID3D12GraphicsCommandList::CopyBufferRegion(ID3D12Resource *pDstBuffer,
UINT64 DstOffset, ID3D12Resource *pSrcBuffer,
UINT64 SrcOffset, UINT64 NumBytes)
{
return m_pReal->CopyBufferRegion(pDstBuffer, DstOffset, pSrcBuffer, SrcOffset, NumBytes);
m_pReal->CopyBufferRegion(pDstBuffer, DstOffset, pSrcBuffer, SrcOffset, NumBytes);
}
void WrappedID3D12GraphicsCommandList::CopyTextureRegion(const D3D12_TEXTURE_COPY_LOCATION *pDst,
@@ -76,13 +76,13 @@ void WrappedID3D12GraphicsCommandList::CopyTextureRegion(const D3D12_TEXTURE_COP
const D3D12_TEXTURE_COPY_LOCATION *pSrc,
const D3D12_BOX *pSrcBox)
{
return m_pReal->CopyTextureRegion(pDst, DstX, DstY, DstZ, pSrc, pSrcBox);
m_pReal->CopyTextureRegion(pDst, DstX, DstY, DstZ, pSrc, pSrcBox);
}
void WrappedID3D12GraphicsCommandList::CopyResource(ID3D12Resource *pDstResource,
ID3D12Resource *pSrcResource)
{
return m_pReal->CopyResource(pDstResource, pSrcResource);
m_pReal->CopyResource(pDstResource, pSrcResource);
}
void WrappedID3D12GraphicsCommandList::CopyTiles(
@@ -90,8 +90,8 @@ void WrappedID3D12GraphicsCommandList::CopyTiles(
const D3D12_TILE_REGION_SIZE *pTileRegionSize, ID3D12Resource *pBuffer,
UINT64 BufferStartOffsetInBytes, D3D12_TILE_COPY_FLAGS Flags)
{
return m_pReal->CopyTiles(pTiledResource, pTileRegionStartCoordinate, pTileRegionSize, pBuffer,
BufferStartOffsetInBytes, Flags);
m_pReal->CopyTiles(pTiledResource, pTileRegionStartCoordinate, pTileRegionSize, pBuffer,
BufferStartOffsetInBytes, Flags);
}
void WrappedID3D12GraphicsCommandList::ResolveSubresource(ID3D12Resource *pDstResource,
@@ -99,92 +99,105 @@ void WrappedID3D12GraphicsCommandList::ResolveSubresource(ID3D12Resource *pDstRe
ID3D12Resource *pSrcResource,
UINT SrcSubresource, DXGI_FORMAT Format)
{
return m_pReal->ResolveSubresource(pDstResource, DstSubresource, pSrcResource, SrcSubresource,
Format);
m_pReal->ResolveSubresource(pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format);
}
void WrappedID3D12GraphicsCommandList::IASetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology)
{
return m_pReal->IASetPrimitiveTopology(PrimitiveTopology);
m_pReal->IASetPrimitiveTopology(PrimitiveTopology);
}
void WrappedID3D12GraphicsCommandList::RSSetViewports(UINT NumViewports,
const D3D12_VIEWPORT *pViewports)
{
return m_pReal->RSSetViewports(NumViewports, pViewports);
m_pReal->RSSetViewports(NumViewports, pViewports);
}
void WrappedID3D12GraphicsCommandList::RSSetScissorRects(UINT NumRects, const D3D12_RECT *pRects)
{
return m_pReal->RSSetScissorRects(NumRects, pRects);
m_pReal->RSSetScissorRects(NumRects, pRects);
}
void WrappedID3D12GraphicsCommandList::OMSetBlendFactor(const FLOAT BlendFactor[4])
{
return m_pReal->OMSetBlendFactor(BlendFactor);
m_pReal->OMSetBlendFactor(BlendFactor);
}
void WrappedID3D12GraphicsCommandList::OMSetStencilRef(UINT StencilRef)
{
return m_pReal->OMSetStencilRef(StencilRef);
m_pReal->OMSetStencilRef(StencilRef);
}
void WrappedID3D12GraphicsCommandList::SetPipelineState(ID3D12PipelineState *pPipelineState)
{
return m_pReal->SetPipelineState(pPipelineState);
m_pReal->SetPipelineState(pPipelineState);
}
void WrappedID3D12GraphicsCommandList::ResourceBarrier(UINT NumBarriers,
const D3D12_RESOURCE_BARRIER *pBarriers)
{
return m_pReal->ResourceBarrier(NumBarriers, pBarriers);
D3D12_RESOURCE_BARRIER *barriers = new D3D12_RESOURCE_BARRIER[NumBarriers];
for(UINT i = 0; i < NumBarriers; i++)
{
barriers[i] = pBarriers[i];
barriers[i].Transition.pResource = Unwrap(barriers[i].Transition.pResource);
// hack while not all resources are wrapped
if(barriers[i].Transition.pResource == NULL)
barriers[i].Transition.pResource = pBarriers[i].Transition.pResource;
}
m_pReal->ResourceBarrier(NumBarriers, barriers);
SAFE_DELETE_ARRAY(barriers);
}
void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList *pCommandList)
{
return m_pReal->ExecuteBundle(pCommandList);
m_pReal->ExecuteBundle(pCommandList);
}
void WrappedID3D12GraphicsCommandList::SetDescriptorHeaps(UINT NumDescriptorHeaps,
ID3D12DescriptorHeap *const *ppDescriptorHeaps)
{
return m_pReal->SetDescriptorHeaps(NumDescriptorHeaps, ppDescriptorHeaps);
m_pReal->SetDescriptorHeaps(NumDescriptorHeaps, ppDescriptorHeaps);
}
void WrappedID3D12GraphicsCommandList::SetComputeRootSignature(ID3D12RootSignature *pRootSignature)
{
return m_pReal->SetComputeRootSignature(pRootSignature);
m_pReal->SetComputeRootSignature(pRootSignature);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootSignature(ID3D12RootSignature *pRootSignature)
{
return m_pReal->SetGraphicsRootSignature(pRootSignature);
m_pReal->SetGraphicsRootSignature(pRootSignature);
}
void WrappedID3D12GraphicsCommandList::SetComputeRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
return m_pReal->SetComputeRootDescriptorTable(RootParameterIndex, BaseDescriptor);
m_pReal->SetComputeRootDescriptorTable(RootParameterIndex, BaseDescriptor);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable(
UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
return m_pReal->SetGraphicsRootDescriptorTable(RootParameterIndex, BaseDescriptor);
m_pReal->SetGraphicsRootDescriptorTable(RootParameterIndex, BaseDescriptor);
}
void WrappedID3D12GraphicsCommandList::SetComputeRoot32BitConstant(UINT RootParameterIndex,
UINT SrcData,
UINT DestOffsetIn32BitValues)
{
return m_pReal->SetComputeRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
m_pReal->SetComputeRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRoot32BitConstant(UINT RootParameterIndex,
UINT SrcData,
UINT DestOffsetIn32BitValues)
{
return m_pReal->SetGraphicsRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
m_pReal->SetGraphicsRoot32BitConstant(RootParameterIndex, SrcData, DestOffsetIn32BitValues);
}
void WrappedID3D12GraphicsCommandList::SetComputeRoot32BitConstants(UINT RootParameterIndex,
@@ -192,8 +205,8 @@ void WrappedID3D12GraphicsCommandList::SetComputeRoot32BitConstants(UINT RootPar
const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
return m_pReal->SetComputeRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
m_pReal->SetComputeRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRoot32BitConstants(UINT RootParameterIndex,
@@ -201,118 +214,117 @@ void WrappedID3D12GraphicsCommandList::SetGraphicsRoot32BitConstants(UINT RootPa
const void *pSrcData,
UINT DestOffsetIn32BitValues)
{
return m_pReal->SetGraphicsRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
m_pReal->SetGraphicsRoot32BitConstants(RootParameterIndex, Num32BitValuesToSet, pSrcData,
DestOffsetIn32BitValues);
}
void WrappedID3D12GraphicsCommandList::SetComputeRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetComputeRootConstantBufferView(RootParameterIndex, BufferLocation);
m_pReal->SetComputeRootConstantBufferView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootConstantBufferView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetGraphicsRootConstantBufferView(RootParameterIndex, BufferLocation);
m_pReal->SetGraphicsRootConstantBufferView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::SetComputeRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetComputeRootShaderResourceView(RootParameterIndex, BufferLocation);
m_pReal->SetComputeRootShaderResourceView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootShaderResourceView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetGraphicsRootShaderResourceView(RootParameterIndex, BufferLocation);
m_pReal->SetGraphicsRootShaderResourceView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::SetComputeRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetComputeRootUnorderedAccessView(RootParameterIndex, BufferLocation);
m_pReal->SetComputeRootUnorderedAccessView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::SetGraphicsRootUnorderedAccessView(
UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
return m_pReal->SetGraphicsRootUnorderedAccessView(RootParameterIndex, BufferLocation);
m_pReal->SetGraphicsRootUnorderedAccessView(RootParameterIndex, BufferLocation);
}
void WrappedID3D12GraphicsCommandList::IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW *pView)
{
return m_pReal->IASetIndexBuffer(pView);
m_pReal->IASetIndexBuffer(pView);
}
void WrappedID3D12GraphicsCommandList::IASetVertexBuffers(UINT StartSlot, UINT NumViews,
const D3D12_VERTEX_BUFFER_VIEW *pViews)
{
return m_pReal->IASetVertexBuffers(StartSlot, NumViews, pViews);
m_pReal->IASetVertexBuffers(StartSlot, NumViews, pViews);
}
void WrappedID3D12GraphicsCommandList::SOSetTargets(UINT StartSlot, UINT NumViews,
const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews)
{
return m_pReal->SOSetTargets(StartSlot, NumViews, pViews);
m_pReal->SOSetTargets(StartSlot, NumViews, pViews);
}
void WrappedID3D12GraphicsCommandList::OMSetRenderTargets(
UINT NumRenderTargetDescriptors, const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors,
BOOL RTsSingleHandleToDescriptorRange, const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor)
{
return m_pReal->OMSetRenderTargets(NumRenderTargetDescriptors, pRenderTargetDescriptors,
RTsSingleHandleToDescriptorRange, pDepthStencilDescriptor);
m_pReal->OMSetRenderTargets(NumRenderTargetDescriptors, pRenderTargetDescriptors,
RTsSingleHandleToDescriptorRange, pDepthStencilDescriptor);
}
void WrappedID3D12GraphicsCommandList::ClearDepthStencilView(
D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, D3D12_CLEAR_FLAGS ClearFlags, FLOAT Depth,
UINT8 Stencil, UINT NumRects, const D3D12_RECT *pRects)
{
return m_pReal->ClearDepthStencilView(DepthStencilView, ClearFlags, Depth, Stencil, NumRects,
pRects);
m_pReal->ClearDepthStencilView(DepthStencilView, ClearFlags, Depth, Stencil, NumRects, pRects);
}
void WrappedID3D12GraphicsCommandList::ClearRenderTargetView(
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, const FLOAT ColorRGBA[4], UINT NumRects,
const D3D12_RECT *pRects)
{
return m_pReal->ClearRenderTargetView(RenderTargetView, ColorRGBA, NumRects, pRects);
m_pReal->ClearRenderTargetView(RenderTargetView, ColorRGBA, NumRects, pRects);
}
void WrappedID3D12GraphicsCommandList::ClearUnorderedAccessViewUint(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const UINT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
return m_pReal->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle, pResource,
Values, NumRects, pRects);
m_pReal->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap, ViewCPUHandle, pResource,
Values, NumRects, pRects);
}
void WrappedID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat(
D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle,
ID3D12Resource *pResource, const FLOAT Values[4], UINT NumRects, const D3D12_RECT *pRects)
{
return m_pReal->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle,
pResource, Values, NumRects, pRects);
m_pReal->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap, ViewCPUHandle, pResource,
Values, NumRects, pRects);
}
void WrappedID3D12GraphicsCommandList::DiscardResource(ID3D12Resource *pResource,
const D3D12_DISCARD_REGION *pRegion)
{
return m_pReal->DiscardResource(pResource, pRegion);
m_pReal->DiscardResource(pResource, pRegion);
}
void WrappedID3D12GraphicsCommandList::BeginQuery(ID3D12QueryHeap *pQueryHeap,
D3D12_QUERY_TYPE Type, UINT Index)
{
return m_pReal->BeginQuery(pQueryHeap, Type, Index);
m_pReal->BeginQuery(pQueryHeap, Type, Index);
}
void WrappedID3D12GraphicsCommandList::EndQuery(ID3D12QueryHeap *pQueryHeap, D3D12_QUERY_TYPE Type,
UINT Index)
{
return m_pReal->EndQuery(pQueryHeap, Type, Index);
m_pReal->EndQuery(pQueryHeap, Type, Index);
}
void WrappedID3D12GraphicsCommandList::ResolveQueryData(ID3D12QueryHeap *pQueryHeap,
@@ -321,30 +333,30 @@ void WrappedID3D12GraphicsCommandList::ResolveQueryData(ID3D12QueryHeap *pQueryH
ID3D12Resource *pDestinationBuffer,
UINT64 AlignedDestinationBufferOffset)
{
return m_pReal->ResolveQueryData(pQueryHeap, Type, StartIndex, NumQueries, pDestinationBuffer,
AlignedDestinationBufferOffset);
m_pReal->ResolveQueryData(pQueryHeap, Type, StartIndex, NumQueries, pDestinationBuffer,
AlignedDestinationBufferOffset);
}
void WrappedID3D12GraphicsCommandList::SetPredication(ID3D12Resource *pBuffer,
UINT64 AlignedBufferOffset,
D3D12_PREDICATION_OP Operation)
{
return m_pReal->SetPredication(pBuffer, AlignedBufferOffset, Operation);
m_pReal->SetPredication(pBuffer, AlignedBufferOffset, Operation);
}
void WrappedID3D12GraphicsCommandList::SetMarker(UINT Metadata, const void *pData, UINT Size)
{
return m_pReal->SetMarker(Metadata, pData, Size);
m_pReal->SetMarker(Metadata, pData, Size);
}
void WrappedID3D12GraphicsCommandList::BeginEvent(UINT Metadata, const void *pData, UINT Size)
{
return m_pReal->BeginEvent(Metadata, pData, Size);
m_pReal->BeginEvent(Metadata, pData, Size);
}
void WrappedID3D12GraphicsCommandList::EndEvent()
{
return m_pReal->EndEvent();
m_pReal->EndEvent();
}
void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *pCommandSignature,
@@ -354,6 +366,6 @@ void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *p
ID3D12Resource *pCountBuffer,
UINT64 CountBufferOffset)
{
return m_pReal->ExecuteIndirect(pCommandSignature, MaxCommandCount, pArgumentBuffer,
ArgumentBufferOffset, pCountBuffer, CountBufferOffset);
m_pReal->ExecuteIndirect(pCommandSignature, MaxCommandCount, pArgumentBuffer,
ArgumentBufferOffset, pCountBuffer, CountBufferOffset);
}
+143 -3
View File
@@ -26,12 +26,61 @@
#include "common/wrapped_pool.h"
#include "d3d12_common.h"
#include "d3d12_device.h"
#include "d3d12_resources.h"
class WrappedID3D12CommandQueue : public RefCounter12<ID3D12CommandQueue>, public ID3D12CommandQueue
class WrappedID3D12CommandQueue;
struct DummyID3D12DebugCommandQueue : public ID3D12DebugCommandQueue
{
ID3D12CommandQueue *m_pReal;
WrappedID3D12CommandQueue *m_pQueue;
ID3D12DebugCommandQueue *m_pReal;
DummyID3D12DebugCommandQueue() {}
//////////////////////////////
// implement IUnknown
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)
{
if(riid == __uuidof(ID3D12DebugCommandQueue))
{
*ppvObject = (ID3D12DebugCommandQueue *)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
//////////////////////////////
// implement ID3D12DebugCommandQueue
virtual BOOL STDMETHODCALLTYPE AssertResourceState(ID3D12Resource *pResource, UINT Subresource,
UINT State)
{
if(m_pReal)
m_pReal->AssertResourceState(pResource, Subresource, State);
return TRUE;
}
};
class WrappedID3D12CommandQueue : public ID3D12CommandQueue,
public RefCounter12<ID3D12CommandQueue>,
public ID3DDevice
{
ID3D12CommandQueue *m_pQueue;
WrappedID3D12Device *m_pDevice;
ResourceId m_ResourceID;
D3D12ResourceRecord *m_QueueRecord;
Serialiser *m_pSerialiser;
LogState m_State;
DummyID3D12DebugCommandQueue m_DummyDebug;
public:
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12CommandQueue);
@@ -39,7 +88,95 @@ public:
Serialiser *serialiser);
virtual ~WrappedID3D12CommandQueue();
Serialiser *GetSerialiser() { return m_pSerialiser; }
ResourceId GetResourceID() { return m_ResourceID; }
ID3D12CommandQueue *GetReal() { return m_pQueue; }
WrappedID3D12Device *GetWrappedDevice() { return m_pDevice; }
// interface for DXGI
virtual IUnknown *GetRealIUnknown() { return GetReal(); }
virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); }
virtual IID GetDeviceUUID() { return __uuidof(ID3D12CommandQueue); }
virtual IUnknown *GetDeviceInterface() { return (ID3D12CommandQueue *)this; }
// the rest forward to the device
virtual void FirstFrame(WrappedIDXGISwapChain3 *swapChain) { m_pDevice->FirstFrame(swapChain); }
virtual void ShutdownSwapchain(WrappedIDXGISwapChain3 *swapChain)
{
m_pDevice->FirstFrame(swapChain);
}
virtual void NewSwapchainBuffer(IUnknown *backbuffer)
{
m_pDevice->NewSwapchainBuffer(backbuffer);
}
virtual void ReleaseSwapchainResources(WrappedIDXGISwapChain3 *swapChain)
{
m_pDevice->ReleaseSwapchainResources(swapChain);
}
virtual IUnknown *WrapSwapchainBuffer(WrappedIDXGISwapChain3 *swap, DXGI_SWAP_CHAIN_DESC *swapDesc,
UINT buffer, IUnknown *realSurface)
{
return m_pDevice->WrapSwapchainBuffer(swap, swapDesc, buffer, realSurface);
}
virtual HRESULT Present(WrappedIDXGISwapChain3 *swapChain, UINT SyncInterval, UINT Flags)
{
return m_pDevice->Present(swapChain, SyncInterval, Flags);
}
//////////////////////////////
// implement IUnknown
ULONG STDMETHODCALLTYPE AddRef() { return RefCounter12::SoftRef(m_pDevice); }
ULONG STDMETHODCALLTYPE Release() { return RefCounter12::SoftRelease(m_pDevice); }
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
//////////////////////////////
// implement ID3D12Object
HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData)
{
return m_pQueue->GetPrivateData(guid, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
{
if(guid == WKPDID_D3DDebugObjectName)
m_pDevice->SetResourceName(this, (const char *)pData);
return m_pQueue->SetPrivateData(guid, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown *pData)
{
return m_pQueue->SetPrivateDataInterface(guid, pData);
}
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
{
string utf8 = StringFormat::Wide2UTF8(Name);
m_pDevice->SetResourceName(this, utf8.c_str());
return m_pQueue->SetName(Name);
}
//////////////////////////////
// implement ID3D12DeviceChild
virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice)
{
if(riid == __uuidof(ID3D12Device) && ppvDevice)
{
*ppvDevice = (ID3D12Device *)m_pDevice;
m_pDevice->AddRef();
}
else if(riid != __uuidof(ID3D12Device))
{
return E_NOINTERFACE;
}
return E_INVALIDARG;
}
//////////////////////////////
// implement ID3D12CommandQueue
@@ -85,4 +222,7 @@ public:
GetClockCalibration(UINT64 *pGpuTimestamp, UINT64 *pCpuTimestamp));
virtual D3D12_COMMAND_QUEUE_DESC STDMETHODCALLTYPE GetDesc() { return m_pReal->GetDesc(); }
};
};
template <>
ID3D12CommandQueue *Unwrap(ID3D12CommandQueue *obj);
@@ -23,6 +23,8 @@
******************************************************************************/
#include "d3d12_command_queue.h"
#include "d3d12_command_list.h"
#include "d3d12_resources.h"
void STDMETHODCALLTYPE WrappedID3D12CommandQueue::UpdateTileMappings(
ID3D12Resource *pResource, UINT NumResourceRegions,
@@ -48,7 +50,13 @@ void STDMETHODCALLTYPE WrappedID3D12CommandQueue::CopyTileMappings(
void STDMETHODCALLTYPE WrappedID3D12CommandQueue::ExecuteCommandLists(
UINT NumCommandLists, ID3D12CommandList *const *ppCommandLists)
{
m_pReal->ExecuteCommandLists(NumCommandLists, ppCommandLists);
ID3D12CommandList **unwrapped = new ID3D12CommandList *[NumCommandLists];
for(UINT i = 0; i < NumCommandLists; i++)
unwrapped[i] = Unwrap(ppCommandLists[i]);
m_pReal->ExecuteCommandLists(NumCommandLists, unwrapped);
SAFE_DELETE_ARRAY(unwrapped);
}
void STDMETHODCALLTYPE WrappedID3D12CommandQueue::SetMarker(UINT Metadata, const void *pData,
@@ -87,4 +95,4 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12CommandQueue::GetClockCalibration(UINT64
UINT64 *pCpuTimestamp)
{
return m_pReal->GetClockCalibration(pGpuTimestamp, pCpuTimestamp);
}
}
+234
View File
@@ -27,3 +27,237 @@
WRAPPED_POOL_INST(WrappedID3D12CommandQueue);
WRAPPED_POOL_INST(WrappedID3D12GraphicsCommandList);
template <>
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList *obj)
{
if(obj == NULL)
return NULL;
return ((WrappedID3D12GraphicsCommandList *)obj)->GetReal();
}
template <>
ID3D12CommandList *Unwrap(ID3D12CommandList *obj)
{
if(obj == NULL)
return NULL;
return ((WrappedID3D12GraphicsCommandList *)obj)->GetReal();
}
template <>
ID3D12CommandQueue *Unwrap(ID3D12CommandQueue *obj)
{
if(obj == NULL)
return NULL;
return ((WrappedID3D12CommandQueue *)obj)->GetReal();
}
ULONG STDMETHODCALLTYPE DummyID3D12DebugCommandQueue::AddRef()
{
m_pQueue->AddRef();
return 1;
}
ULONG STDMETHODCALLTYPE DummyID3D12DebugCommandQueue::Release()
{
m_pQueue->Release();
return 1;
}
ULONG STDMETHODCALLTYPE DummyID3D12DebugCommandList::AddRef()
{
m_pList->AddRef();
return 1;
}
ULONG STDMETHODCALLTYPE DummyID3D12DebugCommandList::Release()
{
m_pList->Release();
return 1;
}
WrappedID3D12CommandQueue::WrappedID3D12CommandQueue(ID3D12CommandQueue *real,
WrappedID3D12Device *device,
Serialiser *serialiser)
: RefCounter12(real), m_pDevice(device), m_pQueue(real)
{
if(RenderDoc::Inst().GetCrashHandler())
RenderDoc::Inst().GetCrashHandler()->RegisterMemoryRegion(this,
sizeof(WrappedID3D12CommandQueue));
m_pQueue->QueryInterface(__uuidof(ID3D12DebugCommandQueue), (void **)&m_DummyDebug.m_pReal);
if(RenderDoc::Inst().IsReplayApp())
{
m_State = READING;
m_pSerialiser = serialiser;
}
else
{
m_pSerialiser = new Serialiser(NULL, Serialiser::WRITING, true);
m_State = WRITING_IDLE;
m_pSerialiser->SetDebugText(true);
}
// create a temporary and grab its resource ID
m_ResourceID = ResourceIDGen::GetNewUniqueID();
m_QueueRecord = NULL;
if(!RenderDoc::Inst().IsReplayApp())
{
m_QueueRecord = m_pDevice->GetResourceManager()->AddResourceRecord(m_ResourceID);
m_QueueRecord->DataInSerialiser = false;
m_QueueRecord->SpecialResource = true;
m_QueueRecord->Length = 0;
m_QueueRecord->NumSubResources = 0;
m_QueueRecord->SubResources = NULL;
m_QueueRecord->ignoreSerialise = true;
}
m_pDevice->SoftRef();
}
WrappedID3D12CommandQueue::~WrappedID3D12CommandQueue()
{
}
HRESULT STDMETHODCALLTYPE WrappedID3D12CommandQueue::QueryInterface(REFIID riid, void **ppvObject)
{
if(riid == __uuidof(IUnknown))
{
*ppvObject = (IUnknown *)(ID3D12CommandQueue *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12CommandQueue))
{
*ppvObject = (ID3D12CommandQueue *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12Pageable))
{
*ppvObject = (ID3D12Pageable *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12DeviceChild))
{
*ppvObject = (ID3D12DeviceChild *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12Object))
{
*ppvObject = (ID3D12DeviceChild *)this;
AddRef();
return S_OK;
}
else
{
string guid = ToStr::Get(riid);
RDCWARN("Querying ID3D12CommandQueue for interface: %s", guid.c_str());
}
return RefCounter12::QueryInterface(riid, ppvObject);
}
WrappedID3D12GraphicsCommandList::WrappedID3D12GraphicsCommandList(ID3D12GraphicsCommandList *real,
WrappedID3D12Device *device,
Serialiser *serialiser)
: RefCounter12(real), m_pDevice(device), m_pList(real)
{
if(RenderDoc::Inst().GetCrashHandler())
RenderDoc::Inst().GetCrashHandler()->RegisterMemoryRegion(
this, sizeof(WrappedID3D12GraphicsCommandList));
m_pList->QueryInterface(__uuidof(ID3D12DebugCommandList), (void **)&m_DummyDebug.m_pReal);
if(RenderDoc::Inst().IsReplayApp())
{
m_State = READING;
m_pSerialiser = serialiser;
}
else
{
m_pSerialiser = new Serialiser(NULL, Serialiser::WRITING, true);
m_State = WRITING_IDLE;
m_pSerialiser->SetDebugText(true);
}
// create a temporary and grab its resource ID
m_ResourceID = ResourceIDGen::GetNewUniqueID();
m_ListRecord = NULL;
if(!RenderDoc::Inst().IsReplayApp())
{
m_ListRecord = m_pDevice->GetResourceManager()->AddResourceRecord(m_ResourceID);
m_ListRecord->DataInSerialiser = false;
m_ListRecord->SpecialResource = true;
m_ListRecord->Length = 0;
m_ListRecord->NumSubResources = 0;
m_ListRecord->SubResources = NULL;
m_ListRecord->ignoreSerialise = true;
}
m_pDevice->SoftRef();
}
WrappedID3D12GraphicsCommandList::~WrappedID3D12GraphicsCommandList()
{
}
HRESULT STDMETHODCALLTYPE WrappedID3D12GraphicsCommandList::QueryInterface(REFIID riid,
void **ppvObject)
{
if(riid == __uuidof(IUnknown))
{
*ppvObject = (IUnknown *)(ID3D12GraphicsCommandList *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12GraphicsCommandList))
{
*ppvObject = (ID3D12GraphicsCommandList *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12CommandList))
{
*ppvObject = (ID3D12CommandList *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12Pageable))
{
*ppvObject = (ID3D12Pageable *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12DeviceChild))
{
*ppvObject = (ID3D12DeviceChild *)this;
AddRef();
return S_OK;
}
else if(riid == __uuidof(ID3D12Object))
{
*ppvObject = (ID3D12DeviceChild *)this;
AddRef();
return S_OK;
}
else
{
string guid = ToStr::Get(riid);
RDCWARN("Querying ID3D12GraphicsCommandList for interface: %s", guid.c_str());
}
return RefCounter12::QueryInterface(riid, ppvObject);
}
+39 -1
View File
@@ -42,6 +42,31 @@ void Serialiser::Serialise(const char *name, D3D12_RESOURCE_DESC &el)
Serialise("Flags", el.Flags);
}
template <>
void Serialiser::Serialise(const char *name, D3D12_COMMAND_QUEUE_DESC &el)
{
ScopedContext scope(this, name, "D3D12_COMMAND_QUEUE_DESC", 0, true);
Serialise("Type", el.Type);
Serialise("Priority", el.Priority);
Serialise("Flags", el.Flags);
Serialise("NodeMask", el.NodeMask);
}
string ToStrHelper<false, D3D12_COMMAND_LIST_TYPE>::Get(const D3D12_COMMAND_LIST_TYPE &el)
{
switch(el)
{
TOSTR_CASE_STRINGIZE(D3D12_COMMAND_LIST_TYPE_DIRECT)
TOSTR_CASE_STRINGIZE(D3D12_COMMAND_LIST_TYPE_BUNDLE)
TOSTR_CASE_STRINGIZE(D3D12_COMMAND_LIST_TYPE_COMPUTE)
TOSTR_CASE_STRINGIZE(D3D12_COMMAND_LIST_TYPE_COPY)
default: break;
}
return StringFormat::Fmt("D3D12_COMMAND_LIST_TYPE<%d>", el);
}
string ToStrHelper<false, D3D12_RESOURCE_DIMENSION>::Get(const D3D12_RESOURCE_DIMENSION &el)
{
switch(el)
@@ -92,4 +117,17 @@ string ToStrHelper<false, D3D12_RESOURCE_FLAGS>::Get(const D3D12_RESOURCE_FLAGS
ret = ret.substr(3);
return ret;
}
}
string ToStrHelper<false, D3D12_COMMAND_QUEUE_FLAGS>::Get(const D3D12_COMMAND_QUEUE_FLAGS &el)
{
string ret;
if(el & D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT)
ret += " | D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT";
if(!ret.empty())
ret = ret.substr(3);
return ret;
}
+6
View File
@@ -110,6 +110,8 @@ public:
template <>
void Serialiser::Serialise(const char *name, D3D12_RESOURCE_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_COMMAND_QUEUE_DESC &el);
#pragma region Chunks
@@ -133,6 +135,10 @@ enum D3D12ChunkType
SET_SHADER_DEBUG_PATH,
CREATE_COMMAND_QUEUE,
CREATE_COMMAND_ALLOCATOR,
CREATE_COMMAND_LIST,
NUM_D3D12_CHUNKS,
};
+12 -8
View File
@@ -36,16 +36,16 @@
WRAPPED_POOL_INST(WrappedID3D12Device);
const char *D3D12ChunkNames[] = {
"ID3D11Device::Initialisation",
"ID3D12Device::Initialisation",
"ID3D12Object::SetName",
"ID3D12Resource::Release",
"IUnknown::Release",
"IDXGISwapChain::GetBuffer",
"Capture",
"ID3D12CommandQueue::BeginEvent",
"ID3D12CommandQueue::SetMarker",
"ID3D12CommandQueue::EndEvent",
"BeginEvent",
"SetMarker",
"EndEvent",
"DebugMessageList",
@@ -53,6 +53,10 @@ const char *D3D12ChunkNames[] = {
"ContextEnd",
"SetShaderDebugPath",
"WrappedID3D12Device::CreateCommandQueue",
"WrappedID3D12Device::CreateCommandAllocator",
"WrappedID3D12Device::CreateCommandList",
};
D3D12InitParams::D3D12InitParams()
@@ -200,6 +204,8 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
{
m_State = WRITING_IDLE;
m_pSerialiser = new Serialiser(NULL, Serialiser::WRITING, true);
m_pSerialiser->SetDebugText(true);
}
m_ResourceManager = new D3D12ResourceManager(m_State, m_pSerialiser, this);
@@ -503,7 +509,7 @@ bool WrappedID3D12Device::Serialise_WrapSwapchainBuffer(WrappedIDXGISwapChain3 *
WrappedID3D12Resource *wrapped = new WrappedID3D12Resource(fakeBB, this);
fakeBB = wrapped;
fakeBB->SetName(L"Serialised Swap Chain Buffer");
fakeBB->SetName(L"Swap Chain Buffer");
GetResourceManager()->AddLiveResource(TexID, fakeBB);
}
@@ -529,8 +535,6 @@ IUnknown *WrappedID3D12Device::WrapSwapchainBuffer(WrappedIDXGISwapChain3 *swap,
ID3D12Resource *pRes = new WrappedID3D12Resource((ID3D12Resource *)realSurface, this);
pRes->SetName(L"Swap Chain Backbuffer");
ResourceId id = GetResID(pRes);
// there shouldn't be a resource record for this texture as it wasn't created via
+132 -11
View File
@@ -23,12 +23,68 @@
******************************************************************************/
#include "d3d12_device.h"
#include "d3d12_command_list.h"
#include "d3d12_command_queue.h"
#include "d3d12_resources.h"
bool WrappedID3D12Device::Serialise_CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC *pDesc,
REFIID riid, void **ppCommandQueue)
{
SERIALISE_ELEMENT_PTR(D3D12_COMMAND_QUEUE_DESC, Descriptor, pDesc);
SERIALISE_ELEMENT(IID, guid, riid);
SERIALISE_ELEMENT(ResourceId, Queue,
((WrappedID3D12CommandQueue *)*ppCommandQueue)->GetResourceID());
if(m_State == READING)
{
ID3D12CommandQueue *ret = NULL;
HRESULT hr = m_pDevice->CreateCommandQueue(&Descriptor, guid, (void **)&ret);
if(FAILED(hr))
{
RDCERR("Failed on resource serialise-creation, HRESULT: 0x%08x", hr);
}
else
{
ret = new WrappedID3D12CommandQueue(ret, this, m_pSerialiser);
GetResourceManager()->AddLiveResource(Queue, ret);
}
}
return true;
}
HRESULT WrappedID3D12Device::CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC *pDesc, REFIID riid,
void **ppCommandQueue)
{
return m_pDevice->CreateCommandQueue(pDesc, riid, ppCommandQueue);
if(ppCommandQueue == NULL)
return m_pDevice->CreateCommandQueue(pDesc, riid, NULL);
if(riid != __uuidof(ID3D12CommandQueue))
return E_NOINTERFACE;
ID3D12CommandQueue *real = NULL;
HRESULT ret = m_pDevice->CreateCommandQueue(pDesc, riid, (void **)&real);
if(SUCCEEDED(ret))
{
SCOPED_LOCK(m_D3DLock);
WrappedID3D12CommandQueue *wrapped = new WrappedID3D12CommandQueue(real, this, m_pSerialiser);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CREATE_COMMAND_QUEUE);
Serialise_CreateCommandQueue(pDesc, riid, (void **)&wrapped);
m_DeviceRecord->AddChunk(scope.Get());
}
*ppCommandQueue = (ID3D12CommandQueue *)wrapped;
}
return ret;
}
HRESULT WrappedID3D12Device::CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type, REFIID riid,
@@ -37,6 +93,80 @@ HRESULT WrappedID3D12Device::CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE type
return m_pDevice->CreateCommandAllocator(type, riid, ppCommandAllocator);
}
bool WrappedID3D12Device::Serialise_CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type,
ID3D12CommandAllocator *pCommandAllocator,
ID3D12PipelineState *pInitialState,
REFIID riid, void **ppCommandList)
{
SERIALISE_ELEMENT(UINT, Mask, nodeMask);
SERIALISE_ELEMENT(D3D12_COMMAND_LIST_TYPE, ListType, type);
SERIALISE_ELEMENT(ResourceId, Allocator, GetResID(pCommandAllocator));
SERIALISE_ELEMENT(ResourceId, State, GetResID(pInitialState));
SERIALISE_ELEMENT(IID, guid, riid);
SERIALISE_ELEMENT(ResourceId, List,
((WrappedID3D12GraphicsCommandList *)*ppCommandList)->GetResourceID());
if(m_State == READING)
{
pCommandAllocator = (ID3D12CommandAllocator *)GetResourceManager()->GetLiveResource(Allocator);
pInitialState = (ID3D12PipelineState *)GetResourceManager()->GetLiveResource(State);
ID3D12GraphicsCommandList *ret = NULL;
HRESULT hr = m_pDevice->CreateCommandList(Mask, ListType, pCommandAllocator, pInitialState,
guid, (void **)&ret);
if(FAILED(hr))
{
RDCERR("Failed on resource serialise-creation, HRESULT: 0x%08x", hr);
}
else
{
ret = new WrappedID3D12GraphicsCommandList(ret, this, m_pSerialiser);
GetResourceManager()->AddLiveResource(List, ret);
}
}
return true;
}
HRESULT WrappedID3D12Device::CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type,
ID3D12CommandAllocator *pCommandAllocator,
ID3D12PipelineState *pInitialState, REFIID riid,
void **ppCommandList)
{
if(ppCommandList == NULL)
return m_pDevice->CreateCommandList(nodeMask, type, pCommandAllocator, pInitialState, riid, NULL);
if(riid != __uuidof(ID3D12GraphicsCommandList))
return E_NOINTERFACE;
ID3D12GraphicsCommandList *real = NULL;
HRESULT ret = m_pDevice->CreateCommandList(nodeMask, type, pCommandAllocator, pInitialState, riid,
(void **)&real);
if(SUCCEEDED(ret))
{
SCOPED_LOCK(m_D3DLock);
WrappedID3D12GraphicsCommandList *wrapped =
new WrappedID3D12GraphicsCommandList(real, this, m_pSerialiser);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(CREATE_COMMAND_LIST);
Serialise_CreateCommandList(nodeMask, type, pCommandAllocator, pInitialState, riid,
(void **)&wrapped);
m_DeviceRecord->AddChunk(scope.Get());
}
*ppCommandList = (ID3D12GraphicsCommandList *)wrapped;
}
return ret;
}
HRESULT WrappedID3D12Device::CreateGraphicsPipelineState(const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc,
REFIID riid, void **ppPipelineState)
{
@@ -49,15 +179,6 @@ HRESULT WrappedID3D12Device::CreateComputePipelineState(const D3D12_COMPUTE_PIPE
return m_pDevice->CreateComputePipelineState(pDesc, riid, ppPipelineState);
}
HRESULT WrappedID3D12Device::CreateCommandList(UINT nodeMask, D3D12_COMMAND_LIST_TYPE type,
ID3D12CommandAllocator *pCommandAllocator,
ID3D12PipelineState *pInitialState, REFIID riid,
void **ppCommandList)
{
return m_pDevice->CreateCommandList(nodeMask, type, pCommandAllocator, pInitialState, riid,
ppCommandList);
}
HRESULT WrappedID3D12Device::CreateDescriptorHeap(const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc,
REFIID riid, void **ppvHeap)
{
@@ -97,7 +218,7 @@ void WrappedID3D12Device::CreateRenderTargetView(ID3D12Resource *pResource,
const D3D12_RENDER_TARGET_VIEW_DESC *pDesc,
D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor)
{
return m_pDevice->CreateRenderTargetView(pResource, pDesc, DestDescriptor);
return m_pDevice->CreateRenderTargetView(Unwrap(pResource), pDesc, DestDescriptor);
}
void WrappedID3D12Device::CreateDepthStencilView(ID3D12Resource *pResource,
+1 -1
View File
@@ -33,7 +33,7 @@
ID3DDevice *GetD3D12DeviceIfAlloc(IUnknown *dev)
{
if(WrappedID3D12CommandQueue::IsAlloc(dev))
return ((WrappedID3D12CommandQueue *)dev)->GetWrappedDevice();
return (WrappedID3D12CommandQueue *)dev;
return NULL;
}