mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 09:30:44 +00:00
Update D3D12 device non-wrapping code to new serialisation scheme
This commit is contained in:
@@ -159,7 +159,7 @@ public:
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
if(guid == WKPDID_D3DDebugObjectName)
|
||||
m_pDevice->SetResourceName(this, (const char *)pData);
|
||||
m_pDevice->SetName(this, (const char *)pData);
|
||||
|
||||
return m_pReal->SetPrivateData(guid, DataSize, pData);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
|
||||
{
|
||||
string utf8 = StringFormat::Wide2UTF8(Name);
|
||||
m_pDevice->SetResourceName(this, utf8.c_str());
|
||||
m_pDevice->SetName(this, utf8.c_str());
|
||||
|
||||
return m_pReal->SetName(Name);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(REFGUID guid, UINT DataSize, const void *pData)
|
||||
{
|
||||
if(guid == WKPDID_D3DDebugObjectName)
|
||||
m_pDevice->SetResourceName(this, (const char *)pData);
|
||||
m_pDevice->SetName(this, (const char *)pData);
|
||||
|
||||
return m_pReal->SetPrivateData(guid, DataSize, pData);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
|
||||
{
|
||||
string utf8 = StringFormat::Wide2UTF8(Name);
|
||||
m_pDevice->SetResourceName(this, utf8.c_str());
|
||||
m_pDevice->SetName(this, utf8.c_str());
|
||||
|
||||
return m_pReal->SetName(Name);
|
||||
}
|
||||
|
||||
@@ -297,6 +297,13 @@ struct D3D12CommandSignature
|
||||
ret func; \
|
||||
bool CONCAT(Serialise_, func);
|
||||
|
||||
// A handy macros to say "is the serialiser reading and we're doing replay-mode stuff?"
|
||||
// The reason we check both is that checking the first allows the compiler to eliminate the other
|
||||
// path at compile-time, and the second because we might be just struct-serialising in which case we
|
||||
// should be doing no work to restore states.
|
||||
// Writing is unambiguously during capture mode, so we don't have to check both in that case.
|
||||
#define IsReplayingAndReading() (ser.IsReading() && IsReplayMode(m_State))
|
||||
|
||||
// this is special - these serialise overloads will fetch the ID during capture, serialise the ID
|
||||
// directly as-if it were the original type, then on replay load up the resource if available.
|
||||
// Really this is only one type of serialisation, but we declare a couple of overloads to account
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -219,7 +219,8 @@ class WrappedID3D12CommandQueue;
|
||||
|
||||
#define IMPLEMENT_FUNCTION_THREAD_SERIALISED(ret, func, ...) \
|
||||
ret func(__VA_ARGS__); \
|
||||
bool CONCAT(Serialise_, func(Serialiser *localSerialiser, __VA_ARGS__));
|
||||
template <typename SerialiserType> \
|
||||
bool CONCAT(Serialise_, func(SerialiserType &ser, __VA_ARGS__));
|
||||
|
||||
class WrappedID3D12Device : public IFrameCapturer, public ID3DDevice, public ID3D12Device1
|
||||
{
|
||||
@@ -259,7 +260,7 @@ private:
|
||||
Threading::CriticalSection m_MapsLock;
|
||||
vector<MapState> m_Maps;
|
||||
|
||||
void ProcessChunk(uint64_t offset, D3D12ChunkType context);
|
||||
void ProcessChunk(ReadSerialiser &ser, D3D12Chunk context);
|
||||
|
||||
unsigned int m_InternalRefcount;
|
||||
RefCounter12<ID3D12Device> m_RefCounter;
|
||||
@@ -269,7 +270,7 @@ private:
|
||||
uint64_t threadSerialiserTLSSlot;
|
||||
|
||||
Threading::CriticalSection m_ThreadSerialisersLock;
|
||||
vector<Serialiser *> m_ThreadSerialisers;
|
||||
std::vector<WriteSerialiser *> m_ThreadSerialisers;
|
||||
|
||||
uint64_t tempMemoryTLSSlot;
|
||||
struct TempMem
|
||||
@@ -281,8 +282,6 @@ private:
|
||||
Threading::CriticalSection m_ThreadTempMemLock;
|
||||
vector<TempMem *> m_ThreadTempMem;
|
||||
|
||||
Serialiser *GetThreadSerialiser();
|
||||
|
||||
vector<DebugMessage> m_DebugMessages;
|
||||
|
||||
SDFile *m_StructuredFile = NULL;
|
||||
@@ -293,11 +292,10 @@ private:
|
||||
FrameRecord m_FrameRecord;
|
||||
vector<DrawcallDescription *> m_Drawcalls;
|
||||
|
||||
Serialiser *m_pSerialiser;
|
||||
bool m_AppControlledCapture;
|
||||
|
||||
Threading::CriticalSection m_CapTransitionLock;
|
||||
LogState m_State;
|
||||
CaptureState m_State;
|
||||
|
||||
D3D12InitParams m_InitParams;
|
||||
uint64_t m_SectionVersion;
|
||||
@@ -306,6 +304,9 @@ private:
|
||||
D3D12ResourceRecord *m_FrameCaptureRecord;
|
||||
Chunk *m_HeaderChunk;
|
||||
|
||||
WriteSerialiser m_ScratchSerialiser;
|
||||
std::set<std::string> m_StringDB;
|
||||
|
||||
ResourceId m_ResourceID;
|
||||
D3D12ResourceRecord *m_DeviceRecord;
|
||||
|
||||
@@ -344,7 +345,8 @@ private:
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS m_D3D12Opts;
|
||||
UINT m_DescriptorIncrements[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES];
|
||||
|
||||
void Serialise_CaptureScope(uint64_t offset);
|
||||
template <typename SerialiserType>
|
||||
void Serialise_CaptureScope(SerialiserType &ser);
|
||||
void EndCaptureFrame(ID3D12Resource *presentImage);
|
||||
|
||||
public:
|
||||
@@ -362,11 +364,12 @@ public:
|
||||
////////////////////////////////////////////////////////////////
|
||||
// non wrapping interface
|
||||
|
||||
WriteSerialiser &GetThreadSerialiser();
|
||||
|
||||
ID3D12Device *GetReal() { return m_pDevice; }
|
||||
static const char *GetChunkName(uint32_t idx);
|
||||
static std::string GetChunkName(uint32_t idx);
|
||||
D3D12ResourceManager *GetResourceManager() { return m_ResourceManager; }
|
||||
D3D12DebugManager *GetDebugManager() { return m_DebugManager; }
|
||||
Serialiser *GetMainSerialiser() { return m_pSerialiser; }
|
||||
ResourceId GetResourceID() { return m_ResourceID; }
|
||||
Threading::CriticalSection &GetCapTransitionLock() { return m_CapTransitionLock; }
|
||||
void ReleaseSwapchainResources(IDXGISwapChain *swap, IUnknown **backbuffers, int numBackbuffers);
|
||||
@@ -376,7 +379,7 @@ public:
|
||||
|
||||
ResourceId GetFrameCaptureResourceId() { return m_FrameCaptureRecord->GetResourceID(); }
|
||||
void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, std::string d);
|
||||
void AddDebugMessage(const DebugMessage &msg) { m_DebugMessages.push_back(msg); }
|
||||
void AddDebugMessage(const DebugMessage &msg);
|
||||
vector<DebugMessage> GetDebugMessages();
|
||||
|
||||
const string &GetResourceName(ResourceId id) { return m_ResourceNames[id]; }
|
||||
@@ -456,11 +459,13 @@ public:
|
||||
void StartFrameCapture(void *dev, void *wnd);
|
||||
bool EndFrameCapture(void *dev, void *wnd);
|
||||
|
||||
bool Serialise_BeginCaptureFrame(bool applyInitialState);
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_BeginCaptureFrame(SerialiserType &ser, bool applyInitialState);
|
||||
|
||||
bool Serialise_DynamicDescriptorWrite(Serialiser *localSerialiser,
|
||||
const DynamicDescriptorWrite *write);
|
||||
bool Serialise_DynamicDescriptorCopies(Serialiser *localSerialiser,
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_DynamicDescriptorWrite(SerialiserType &ser, const DynamicDescriptorWrite *write);
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_DynamicDescriptorCopies(SerialiserType &ser,
|
||||
const std::vector<DynamicDescriptorCopy> *copies);
|
||||
|
||||
void ReadLogInitialisation(RDCFile *rdc, bool storeStructuredBuffers);
|
||||
@@ -495,13 +500,13 @@ public:
|
||||
void ReleaseSwapchainResources(WrappedIDXGISwapChain4 *swap, UINT QueueCount,
|
||||
IUnknown *const *ppPresentQueue, IUnknown **unwrappedQueues);
|
||||
|
||||
void Map(WrappedID3D12Resource *Resource, UINT Subresource);
|
||||
void Unmap(WrappedID3D12Resource *Resource, UINT Subresource, byte *mapPtr,
|
||||
void Map(ID3D12Resource *Resource, UINT Subresource);
|
||||
void Unmap(ID3D12Resource *Resource, UINT Subresource, byte *mapPtr,
|
||||
const D3D12_RANGE *pWrittenRange);
|
||||
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, MapDataWrite, WrappedID3D12Resource *Resource,
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, MapDataWrite, ID3D12Resource *Resource,
|
||||
UINT Subresource, byte *mapPtr, D3D12_RANGE range);
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, WriteToSubresource, WrappedID3D12Resource *Resource,
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, WriteToSubresource, ID3D12Resource *Resource,
|
||||
UINT Subresource, const D3D12_BOX *pDstBox,
|
||||
const void *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch);
|
||||
|
||||
@@ -525,12 +530,12 @@ public:
|
||||
}
|
||||
void CheckForDeath();
|
||||
|
||||
void ReleaseResource(ID3D12DeviceChild *pResource);
|
||||
|
||||
// Resource
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, SetResourceName, ID3D12DeviceChild *res,
|
||||
const char *name);
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(HRESULT, SetShaderDebugPath, ID3D12DeviceChild *res,
|
||||
const char *name);
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, ReleaseResource, ID3D12DeviceChild *res);
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, SetName, ID3D12DeviceChild *pResource, const char *Name);
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(HRESULT, SetShaderDebugPath, ID3D12DeviceChild *pResource,
|
||||
const char *Path);
|
||||
|
||||
//////////////////////////////
|
||||
// implement IUnknown
|
||||
|
||||
@@ -724,41 +724,41 @@ void D3D12ResourceManager::ApplyBarriers(vector<D3D12_RESOURCE_BARRIER> &barrier
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12ResourceManager::SerialiseResourceStates(vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
map<ResourceId, SubresourceStateVector> &states)
|
||||
template <typename SerialiserType>
|
||||
void D3D12ResourceManager::SerialiseResourceStates(SerialiserType &ser,
|
||||
std::vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
std::map<ResourceId, SubresourceStateVector> &states)
|
||||
{
|
||||
SERIALISE_ELEMENT(uint32_t, NumMems, (uint32_t)states.size());
|
||||
SERIALISE_ELEMENT_LOCAL(NumMems, (uint32_t)states.size());
|
||||
|
||||
auto srcit = states.begin();
|
||||
|
||||
for(uint32_t i = 0; i < NumMems; i++)
|
||||
{
|
||||
SERIALISE_ELEMENT(ResourceId, id, srcit->first);
|
||||
SERIALISE_ELEMENT(uint32_t, NumStates, (uint32_t)srcit->second.size());
|
||||
SERIALISE_ELEMENT_LOCAL(Resource, srcit->first);
|
||||
SERIALISE_ELEMENT_LOCAL(States, srcit->second);
|
||||
|
||||
ResourceId liveid;
|
||||
if(m_State < WRITING && HasLiveResource(id))
|
||||
liveid = GetLiveID(id);
|
||||
if(IsReplayingAndReading() && HasLiveResource(Resource))
|
||||
liveid = GetLiveID(Resource);
|
||||
|
||||
for(uint32_t m = 0; m < NumStates; m++)
|
||||
if(IsReplayingAndReading() && liveid != ResourceId())
|
||||
{
|
||||
SERIALISE_ELEMENT(D3D12_RESOURCE_STATES, state, srcit->second[m]);
|
||||
|
||||
if(m_State < WRITING && liveid != ResourceId() && srcit != states.end())
|
||||
for(size_t m = 0; m < States.size(); m++)
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER b;
|
||||
b.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
b.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
b.Transition.pResource = (ID3D12Resource *)GetCurrentResource(liveid);
|
||||
b.Transition.Subresource = m;
|
||||
b.Transition.Subresource = (UINT)m;
|
||||
b.Transition.StateBefore = states[liveid][m];
|
||||
b.Transition.StateAfter = state;
|
||||
b.Transition.StateAfter = States[m];
|
||||
|
||||
barriers.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_State >= WRITING)
|
||||
if(ser.IsWriting())
|
||||
srcit++;
|
||||
}
|
||||
|
||||
@@ -774,6 +774,13 @@ void D3D12ResourceManager::SerialiseResourceStates(vector<D3D12_RESOURCE_BARRIER
|
||||
ApplyBarriers(barriers, states);
|
||||
}
|
||||
|
||||
template void D3D12ResourceManager::SerialiseResourceStates(
|
||||
ReadSerialiser &ser, std::vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
std::map<ResourceId, SubresourceStateVector> &states);
|
||||
template void D3D12ResourceManager::SerialiseResourceStates(
|
||||
WriteSerialiser &ser, std::vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
std::map<ResourceId, SubresourceStateVector> &states);
|
||||
|
||||
bool D3D12ResourceManager::SerialisableResource(ResourceId id, D3D12ResourceRecord *record)
|
||||
{
|
||||
if(record->type == Resource_GraphicsCommandList || record->type == Resource_CommandQueue)
|
||||
|
||||
@@ -372,7 +372,7 @@ struct GPUAddressRangeTracker
|
||||
|
||||
struct MapState
|
||||
{
|
||||
WrappedID3D12Resource *res;
|
||||
ID3D12Resource *res;
|
||||
UINT subres;
|
||||
UINT64 totalSize;
|
||||
};
|
||||
@@ -443,11 +443,10 @@ class D3D12ResourceManager
|
||||
: public ResourceManager<ID3D12DeviceChild *, ID3D12DeviceChild *, D3D12ResourceRecord>
|
||||
{
|
||||
public:
|
||||
D3D12ResourceManager(LogState state, Serialiser *ser, WrappedID3D12Device *dev)
|
||||
: ResourceManager(state, ser), m_Device(dev)
|
||||
D3D12ResourceManager(CaptureState state, WrappedID3D12Device *dev)
|
||||
: ResourceManager(), m_State(state), m_Device(dev)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T *GetLiveAs(ResourceId id)
|
||||
{
|
||||
@@ -463,10 +462,12 @@ public:
|
||||
void ApplyBarriers(vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
map<ResourceId, SubresourceStateVector> &states);
|
||||
|
||||
void SerialiseResourceStates(vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
map<ResourceId, SubresourceStateVector> &states);
|
||||
template <typename SerialiserType>
|
||||
void SerialiseResourceStates(SerialiserType &ser, std::vector<D3D12_RESOURCE_BARRIER> &barriers,
|
||||
std::map<ResourceId, SubresourceStateVector> &states);
|
||||
|
||||
bool Serialise_InitialState(ResourceId resid, ID3D12DeviceChild *res);
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_InitialState(SerialiserType &ser, ResourceId resid, ID3D12DeviceChild *res);
|
||||
|
||||
private:
|
||||
bool SerialisableResource(ResourceId id, D3D12ResourceRecord *record);
|
||||
@@ -477,8 +478,14 @@ private:
|
||||
bool Force_InitialState(ID3D12DeviceChild *res, bool prepare);
|
||||
bool Need_InitialStateChunk(ID3D12DeviceChild *res);
|
||||
bool Prepare_InitialState(ID3D12DeviceChild *res);
|
||||
uint32_t GetSize_InitialState(ResourceId id, ID3D12DeviceChild *res);
|
||||
bool Serialise_InitialState(WriteSerialiser &ser, ResourceId resid, ID3D12DeviceChild *res)
|
||||
{
|
||||
return Serialise_InitialState<WriteSerialiser>(ser, resid, res);
|
||||
}
|
||||
void Create_InitialState(ResourceId id, ID3D12DeviceChild *live, bool hasData);
|
||||
void Apply_InitialState(ID3D12DeviceChild *live, InitialContentData data);
|
||||
|
||||
CaptureState m_State;
|
||||
WrappedID3D12Device *m_Device;
|
||||
};
|
||||
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
return m_pDevice->SetShaderDebugPath(this, (const char *)pData);
|
||||
|
||||
if(guid == WKPDID_D3DDebugObjectName)
|
||||
m_pDevice->SetResourceName(this, (const char *)pData);
|
||||
m_pDevice->SetName(this, (const char *)pData);
|
||||
|
||||
if(!m_pReal)
|
||||
return S_OK;
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
HRESULT STDMETHODCALLTYPE SetName(LPCWSTR Name)
|
||||
{
|
||||
string utf8 = StringFormat::Wide2UTF8(Name);
|
||||
m_pDevice->SetResourceName(this, utf8.c_str());
|
||||
m_pDevice->SetName(this, utf8.c_str());
|
||||
|
||||
if(!m_pReal)
|
||||
return S_OK;
|
||||
|
||||
Reference in New Issue
Block a user