mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-28 09:26:52 +00:00
Create fake descriptor storage objects for GL and D3D11
This commit is contained in:
@@ -662,6 +662,14 @@ API-specific concepts.
|
||||
|
||||
A structure used to carry implementation-defined spatial partitioning data and related
|
||||
information, used to accelerate geometry intersection queries (e.g. for ray tracing).
|
||||
|
||||
.. data:: DescriptorStore
|
||||
|
||||
A descriptor store, either driver or application managed. For example a Vulkan descriptor set or
|
||||
a D3D12 descriptor heap.
|
||||
|
||||
APIs without an explicit concept of descriptor storage will have virtual objects corresponding to
|
||||
temporary bindings.
|
||||
)");
|
||||
enum class ResourceType : uint32_t
|
||||
{
|
||||
@@ -690,6 +698,8 @@ enum class ResourceType : uint32_t
|
||||
Pool,
|
||||
|
||||
AccelerationStructure,
|
||||
|
||||
DescriptorStore,
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_ENUM(ResourceType);
|
||||
|
||||
@@ -69,6 +69,12 @@ HRESULT STDMETHODCALLTYPE WrappedID3DUserDefinedAnnotation::QueryInterface(REFII
|
||||
extern uint32_t NullCBOffsets[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
|
||||
extern uint32_t NullCBCounts[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
|
||||
|
||||
D3DDescriptorStore::D3DDescriptorStore(WrappedID3D11Device *device)
|
||||
{
|
||||
m_ID = ResourceIDGen::GetNewUniqueID();
|
||||
device->GetResourceManager()->AddCurrentResource(GetResourceID(), this);
|
||||
}
|
||||
|
||||
WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *realDevice,
|
||||
ID3D11DeviceContext *context)
|
||||
: m_pDevice(realDevice),
|
||||
@@ -138,10 +144,16 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real
|
||||
if(RenderDoc::Inst().IsReplayApp())
|
||||
{
|
||||
m_State = CaptureState::LoadingReplaying;
|
||||
|
||||
m_DescriptorStore = new D3DDescriptorStore(m_pDevice);
|
||||
m_pDevice->GetResourceManager()->AddLiveResource(m_DescriptorStore->GetResourceID(),
|
||||
m_DescriptorStore);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_State = CaptureState::BackgroundCapturing;
|
||||
|
||||
m_DescriptorStore = NULL;
|
||||
}
|
||||
|
||||
// create a temporary and grab its resource ID
|
||||
@@ -210,8 +222,6 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real
|
||||
m_SuccessfulCapture = false;
|
||||
}
|
||||
}
|
||||
|
||||
ReplayFakeContext(ResourceId());
|
||||
}
|
||||
|
||||
WrappedID3D11DeviceContext::~WrappedID3D11DeviceContext()
|
||||
@@ -222,6 +232,12 @@ WrappedID3D11DeviceContext::~WrappedID3D11DeviceContext()
|
||||
if(m_pRealContext && GetType() != D3D11_DEVICE_CONTEXT_IMMEDIATE)
|
||||
m_pDevice->RemoveDeferredContext(this);
|
||||
|
||||
// if this context is being destroyed by the resource manager the descriptor store may already be
|
||||
// "removed"
|
||||
if(m_DescriptorStore && GetResourceManager()->HasLiveResource(m_DescriptorStore->GetResourceID()))
|
||||
GetResourceManager()->EraseLiveResource(m_DescriptorStore->GetResourceID());
|
||||
SAFE_DELETE(m_DescriptorStore);
|
||||
|
||||
SAFE_DELETE(m_FrameReader);
|
||||
|
||||
SAFE_RELEASE(m_WrappedVideo.m_pReal);
|
||||
@@ -1217,11 +1233,6 @@ const APIEvent &WrappedID3D11DeviceContext::GetEvent(uint32_t eventId) const
|
||||
return m_Events[RDCMIN(idx, m_Events.size() - 1)];
|
||||
}
|
||||
|
||||
void WrappedID3D11DeviceContext::ReplayFakeContext(ResourceId id)
|
||||
{
|
||||
m_FakeContext = id;
|
||||
}
|
||||
|
||||
RDResult WrappedID3D11DeviceContext::ReplayLog(CaptureState readType, uint32_t startEventID,
|
||||
uint32_t endEventID, bool partial)
|
||||
{
|
||||
|
||||
@@ -93,6 +93,36 @@ enum CaptureFailReason
|
||||
CaptureFailed_UncappedCmdlist,
|
||||
};
|
||||
|
||||
// a fake device child to be able to register a resource without needing a wrapper
|
||||
struct D3DDescriptorStore : public ID3D11DeviceChild
|
||||
{
|
||||
private:
|
||||
ResourceId m_ID;
|
||||
|
||||
public:
|
||||
D3DDescriptorStore(WrappedID3D11Device *device);
|
||||
virtual ~D3DDescriptorStore() {}
|
||||
|
||||
ResourceId GetResourceID() { return m_ID; }
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef() { return 1; }
|
||||
ULONG STDMETHODCALLTYPE Release() { return 1; }
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) { return E_NOTIMPL; }
|
||||
void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice) {}
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(REFGUID guid, UINT *pDataSize, void *pData)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(REFGUID guid, const IUnknown *pData)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
};
|
||||
|
||||
class WrappedID3D11DeviceContext : public ID3D11DeviceContext4
|
||||
{
|
||||
private:
|
||||
@@ -145,6 +175,7 @@ private:
|
||||
std::set<rdcstr> m_StringDB;
|
||||
|
||||
ResourceId m_CurContextId;
|
||||
D3DDescriptorStore *m_DescriptorStore;
|
||||
|
||||
StreamReader *m_FrameReader = NULL;
|
||||
|
||||
@@ -168,8 +199,6 @@ private:
|
||||
RenderDoc::Inst().AddActiveDriver(RDCDriver::D3D11, false);
|
||||
}
|
||||
|
||||
ResourceId m_FakeContext;
|
||||
|
||||
bool m_DoStateVerify;
|
||||
D3D11RenderState *m_CurrentPipelineState;
|
||||
|
||||
@@ -266,6 +295,11 @@ public:
|
||||
|
||||
void VerifyState();
|
||||
|
||||
ResourceId GetDescriptorsID()
|
||||
{
|
||||
return m_DescriptorStore ? m_DescriptorStore->GetResourceID() : ResourceId();
|
||||
}
|
||||
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
|
||||
@@ -300,7 +334,6 @@ public:
|
||||
bool IsFL11_1();
|
||||
|
||||
bool ProcessChunk(ReadSerialiser &ser, D3D11Chunk chunk);
|
||||
void ReplayFakeContext(ResourceId id);
|
||||
RDResult ReplayLog(CaptureState readType, uint32_t startEventID, uint32_t endEventID, bool partial);
|
||||
void SetFrameReader(StreamReader *reader) { m_FrameReader = reader; }
|
||||
void MarkResourceReferenced(ResourceId id, FrameRefType refType);
|
||||
|
||||
@@ -1032,11 +1032,19 @@ bool WrappedID3D11Device::ProcessChunk(ReadSerialiser &ser, D3D11Chunk context)
|
||||
m_pImmediateContext->AddRef();
|
||||
m_ResourceManager->AddLiveResource(ImmediateContext, m_pImmediateContext);
|
||||
|
||||
ResourceId descId = m_pImmediateContext->GetDescriptorsID();
|
||||
AddResource(descId, ResourceType::DescriptorStore, "");
|
||||
|
||||
AddResource(ImmediateContext, ResourceType::Queue, "");
|
||||
ResourceDescription &desc = GetReplay()->GetResourceDesc(ImmediateContext);
|
||||
desc.autogeneratedName = false;
|
||||
desc.name = "Immediate Context";
|
||||
desc.initialisationChunks.clear();
|
||||
ResourceDescription &ctxdesc = GetReplay()->GetResourceDesc(ImmediateContext);
|
||||
ctxdesc.SetCustomName("Immediate Context");
|
||||
ctxdesc.initialisationChunks.clear();
|
||||
|
||||
ResourceDescription &bindsdesc = GetReplay()->GetResourceDesc(descId);
|
||||
bindsdesc.SetCustomName("Immediate Context Bindings");
|
||||
bindsdesc.initialisationChunks.clear();
|
||||
ctxdesc.derivedResources.push_back(descId);
|
||||
bindsdesc.parentResources.push_back(ImmediateContext);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1667,10 +1667,17 @@ void D3D11Replay::SavePipelineState(uint32_t eventId)
|
||||
rdcarray<Descriptor> D3D11Replay::GetDescriptors(ResourceId descriptorStore,
|
||||
const rdcarray<DescriptorRange> &ranges)
|
||||
{
|
||||
rdcarray<Descriptor> ret;
|
||||
|
||||
if(descriptorStore != m_pImmediateContext->GetDescriptorsID())
|
||||
{
|
||||
RDCERR("Descriptors query for invalid descriptor store on fixed bindings API (D3D11)");
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
for(const DescriptorRange &r : ranges)
|
||||
count += r.count;
|
||||
rdcarray<Descriptor> ret;
|
||||
ret.resize(count);
|
||||
return ret;
|
||||
}
|
||||
@@ -1678,10 +1685,17 @@ rdcarray<Descriptor> D3D11Replay::GetDescriptors(ResourceId descriptorStore,
|
||||
rdcarray<SamplerDescriptor> D3D11Replay::GetSamplerDescriptors(ResourceId descriptorStore,
|
||||
const rdcarray<DescriptorRange> &ranges)
|
||||
{
|
||||
rdcarray<SamplerDescriptor> ret;
|
||||
|
||||
if(descriptorStore != m_pImmediateContext->GetDescriptorsID())
|
||||
{
|
||||
RDCERR("Descriptors query for invalid descriptor store on fixed bindings API (D3D11)");
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
for(const DescriptorRange &r : ranges)
|
||||
count += r.count;
|
||||
rdcarray<SamplerDescriptor> ret;
|
||||
ret.resize(count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -962,7 +962,7 @@ bool WrappedID3D12Device::Serialise_CreateDescriptorHeap(
|
||||
|
||||
GetResourceManager()->AddLiveResource(pHeap, ret);
|
||||
|
||||
AddResource(pHeap, ResourceType::ShaderBinding, "Descriptor Heap");
|
||||
AddResource(pHeap, ResourceType::DescriptorStore, "Descriptor Heap");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -695,6 +695,16 @@ WrappedOpenGL::WrappedOpenGL(GLPlatform &platform)
|
||||
m_DeviceRecord = m_ContextRecord = NULL;
|
||||
|
||||
ResourceIDGen::SetReplayResourceIDs();
|
||||
|
||||
m_DescriptorsID = GetResourceManager()->RegisterResource(
|
||||
GLResource(NULL, eResSpecial, eSpecialResDescriptorStorage));
|
||||
|
||||
GetResourceManager()->AddLiveResource(
|
||||
m_DescriptorsID, GLResource(NULL, eResSpecial, eSpecialResDescriptorStorage));
|
||||
|
||||
AddResource(m_DescriptorsID, ResourceType::DescriptorStore, "");
|
||||
GetReplay()->GetResourceDesc(m_DescriptorsID).SetCustomName("Context Bindings");
|
||||
GetReplay()->GetResourceDesc(m_DescriptorsID).initialisationChunks.clear();
|
||||
}
|
||||
|
||||
rdcspv::Init();
|
||||
|
||||
@@ -220,6 +220,8 @@ private:
|
||||
ResourceId m_ContextResourceID;
|
||||
GLResourceRecord *m_ContextRecord;
|
||||
|
||||
ResourceId m_DescriptorsID;
|
||||
|
||||
GLResourceManager *m_ResourceManager;
|
||||
|
||||
uint64_t m_TimeBase = 0;
|
||||
|
||||
@@ -2123,10 +2123,17 @@ void GLReplay::SavePipelineState(uint32_t eventId)
|
||||
rdcarray<Descriptor> GLReplay::GetDescriptors(ResourceId descriptorStore,
|
||||
const rdcarray<DescriptorRange> &ranges)
|
||||
{
|
||||
rdcarray<Descriptor> ret;
|
||||
|
||||
if(descriptorStore != m_pDriver->m_DescriptorsID)
|
||||
{
|
||||
RDCERR("Descriptors query for invalid descriptor store on fixed bindings API (OpenGL)");
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
for(const DescriptorRange &r : ranges)
|
||||
count += r.count;
|
||||
rdcarray<Descriptor> ret;
|
||||
ret.resize(count);
|
||||
return ret;
|
||||
}
|
||||
@@ -2134,10 +2141,17 @@ rdcarray<Descriptor> GLReplay::GetDescriptors(ResourceId descriptorStore,
|
||||
rdcarray<SamplerDescriptor> GLReplay::GetSamplerDescriptors(ResourceId descriptorStore,
|
||||
const rdcarray<DescriptorRange> &ranges)
|
||||
{
|
||||
rdcarray<SamplerDescriptor> ret;
|
||||
|
||||
if(descriptorStore != m_pDriver->m_DescriptorsID)
|
||||
{
|
||||
RDCERR("Descriptors query for invalid descriptor store on fixed bindings API (OpenGL)");
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
for(const DescriptorRange &r : ranges)
|
||||
count += r.count;
|
||||
rdcarray<SamplerDescriptor> ret;
|
||||
ret.resize(count);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ enum GLSpecialResource
|
||||
{
|
||||
eSpecialResDevice = 0,
|
||||
eSpecialResContext = 0,
|
||||
eSpecialResDescriptorStorage = 0,
|
||||
};
|
||||
|
||||
enum NullInitialiser
|
||||
|
||||
@@ -502,7 +502,7 @@ bool WrappedVulkan::Serialise_vkAllocateDescriptorSets(SerialiserType &ser, VkDe
|
||||
variableDescriptorAlloc);
|
||||
}
|
||||
|
||||
AddResource(DescriptorSet, ResourceType::ShaderBinding, "Descriptor Set");
|
||||
AddResource(DescriptorSet, ResourceType::DescriptorStore, "Descriptor Set");
|
||||
DerivedResource(device, DescriptorSet);
|
||||
DerivedResource(AllocateInfo.pSetLayouts[0], DescriptorSet);
|
||||
DerivedResource(AllocateInfo.descriptorPool, DescriptorSet);
|
||||
|
||||
Reference in New Issue
Block a user