mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-26 16:36:31 +00:00
Set up drawcall previous/next/parent IDs in replay drivers
This commit is contained in:
@@ -72,6 +72,9 @@ struct array
|
||||
|
||||
T &operator [](size_t i) { return elems[i]; }
|
||||
const T &operator [](size_t i) const { return elems[i]; }
|
||||
|
||||
// to help simple template specializations for vector/rdctype::array
|
||||
size_t size() { return (size_t)count; }
|
||||
|
||||
array(const T *const in) { elems = 0; count = 0; *this = in; }
|
||||
array &operator =(const T *const in);
|
||||
|
||||
@@ -1068,6 +1068,8 @@ void WrappedID3D11Device::ReadLogInitialisation()
|
||||
break;
|
||||
}
|
||||
|
||||
SetupDrawcallPointers(&m_Drawcalls, m_FrameRecord.back().frameInfo.immContextId, m_FrameRecord.back().drawcallList, NULL, NULL);
|
||||
|
||||
for(auto it=chunkInfos.begin(); it != chunkInfos.end(); ++it)
|
||||
{
|
||||
double dcount = double(it->second.count);
|
||||
@@ -3411,48 +3413,10 @@ WrappedID3D11DeviceContext *WrappedID3D11Device::GetDeferredContext( size_t idx
|
||||
return *it;
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedID3D11Device::GetDrawcall(const FetchDrawcall *draw, uint32_t eventID)
|
||||
{
|
||||
if(draw == NULL) return NULL;
|
||||
if(draw->eventID == eventID) return draw;
|
||||
|
||||
int32_t count = draw->children.count;
|
||||
for(int32_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &draw->children.elems[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &draw->children.elems[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedID3D11Device::GetDrawcall(uint32_t frameID, uint32_t eventID)
|
||||
{
|
||||
if(frameID >= m_FrameRecord.size())
|
||||
if(eventID >= m_Drawcalls.size())
|
||||
return NULL;
|
||||
|
||||
size_t count = m_FrameRecord[frameID].drawcallList.size();
|
||||
for(size_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &m_FrameRecord[frameID].drawcallList[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &m_FrameRecord[frameID].drawcallList[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return m_Drawcalls[eventID];
|
||||
}
|
||||
@@ -267,7 +267,7 @@ private:
|
||||
vector<DebugMessage> m_DebugMessages;
|
||||
|
||||
vector<FetchFrameRecord> m_FrameRecord;
|
||||
const FetchDrawcall *GetDrawcall(const FetchDrawcall *draw, uint32_t eventID);
|
||||
vector<FetchDrawcall*> m_Drawcalls;
|
||||
public:
|
||||
static const int AllocPoolCount = 4;
|
||||
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D11Device, AllocPoolCount);
|
||||
|
||||
@@ -1268,7 +1268,7 @@ vector<uint32_t> D3D11Replay::GetPassEvents(uint32_t frameID, uint32_t eventID)
|
||||
if(start->flags & eDraw_Drawcall)
|
||||
passEvents.push_back(start->eventID);
|
||||
|
||||
start = m_pDevice->GetDrawcall((uint32_t)start->next, 0);
|
||||
start = m_pDevice->GetDrawcall(frameID, (uint32_t)start->next);
|
||||
}
|
||||
|
||||
return passEvents;
|
||||
|
||||
@@ -3978,6 +3978,8 @@ void WrappedOpenGL::ContextReplayLog(LogState readType, uint32_t startEventID, u
|
||||
{
|
||||
GetFrameRecord().back().drawcallList = m_ParentDrawcall.Bake();
|
||||
GetFrameRecord().back().frameInfo.debugMessages = GetDebugMessages();
|
||||
|
||||
SetupDrawcallPointers(&m_Drawcalls, GetFrameRecord().back().frameInfo.immContextId, GetFrameRecord().back().drawcallList, NULL, NULL);
|
||||
|
||||
// it's easier to remove duplicate usages here than check it as we go.
|
||||
// this means if textures are bound in multiple places in the same draw
|
||||
@@ -4431,50 +4433,12 @@ FetchAPIEvent WrappedOpenGL::GetEvent(uint32_t eventID)
|
||||
return m_Events[0];
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedOpenGL::GetDrawcall(const FetchDrawcall *draw, uint32_t eventID)
|
||||
{
|
||||
if(draw == NULL) return NULL;
|
||||
if(draw->eventID == eventID) return draw;
|
||||
|
||||
int32_t count = draw->children.count;
|
||||
for(int32_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &draw->children.elems[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &draw->children.elems[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedOpenGL::GetDrawcall(uint32_t frameID, uint32_t eventID)
|
||||
{
|
||||
if(frameID >= m_FrameRecord.size())
|
||||
if(eventID >= m_Drawcalls.size())
|
||||
return NULL;
|
||||
|
||||
size_t count = m_FrameRecord[frameID].drawcallList.size();
|
||||
for(size_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &m_FrameRecord[frameID].drawcallList[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &m_FrameRecord[frameID].drawcallList[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return m_Drawcalls[eventID];
|
||||
}
|
||||
|
||||
void WrappedOpenGL::ReplayLog(uint32_t frameID, uint32_t startEventID, uint32_t endEventID, ReplayLogType replayType)
|
||||
|
||||
@@ -189,8 +189,7 @@ class WrappedOpenGL : public IFrameCapturer
|
||||
{ if(!m_CoherentMaps.empty()) PersistentMapMemoryBarrier(m_CoherentMaps); }
|
||||
|
||||
vector<FetchFrameRecord> m_FrameRecord;
|
||||
|
||||
const FetchDrawcall *GetDrawcall(const FetchDrawcall *draw, uint32_t eventID);
|
||||
vector<FetchDrawcall*> m_Drawcalls;
|
||||
|
||||
static const char *GetChunkName(uint32_t idx);
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ vector<uint32_t> GLReplay::GetPassEvents(uint32_t frameID, uint32_t eventID)
|
||||
if(start->flags & eDraw_Drawcall)
|
||||
passEvents.push_back(start->eventID);
|
||||
|
||||
start = m_pDriver->GetDrawcall((uint32_t)start->next, 0);
|
||||
start = m_pDriver->GetDrawcall(frameID, (uint32_t)start->next);
|
||||
}
|
||||
|
||||
return passEvents;
|
||||
|
||||
@@ -1293,6 +1293,8 @@ void WrappedVulkan::ContextReplayLog(LogState readType, uint32_t startEventID, u
|
||||
{
|
||||
GetFrameRecord().back().drawcallList = m_ParentDrawcall.Bake();
|
||||
|
||||
SetupDrawcallPointers(&m_Drawcalls, GetFrameRecord().back().frameInfo.immContextId, GetFrameRecord().back().drawcallList, NULL, NULL);
|
||||
|
||||
struct SortEID
|
||||
{
|
||||
bool operator() (const FetchAPIEvent &a, const FetchAPIEvent &b) { return a.eventID < b.eventID; }
|
||||
@@ -1913,48 +1915,10 @@ FetchAPIEvent WrappedVulkan::GetEvent(uint32_t eventID)
|
||||
return m_Events[0];
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedVulkan::GetDrawcall(const FetchDrawcall *draw, uint32_t eventID)
|
||||
{
|
||||
if(draw == NULL) return NULL;
|
||||
if(draw->eventID == eventID) return draw;
|
||||
|
||||
int32_t count = draw->children.count;
|
||||
for(int32_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &draw->children.elems[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &draw->children.elems[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const FetchDrawcall *WrappedVulkan::GetDrawcall(uint32_t frameID, uint32_t eventID)
|
||||
{
|
||||
if(frameID >= m_FrameRecord.size())
|
||||
if(eventID >= m_Drawcalls.size())
|
||||
return NULL;
|
||||
|
||||
size_t count = m_FrameRecord[frameID].drawcallList.size();
|
||||
for(size_t i=0; i < count; i++)
|
||||
{
|
||||
const FetchDrawcall *cur = &m_FrameRecord[frameID].drawcallList[i];
|
||||
const FetchDrawcall *next = i+1 < count ? &m_FrameRecord[frameID].drawcallList[i+1] : NULL;
|
||||
|
||||
if(next && next->eventID <= eventID)
|
||||
continue;
|
||||
|
||||
cur = GetDrawcall(cur, eventID);
|
||||
|
||||
if(cur)
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return m_Drawcalls[eventID];
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ private:
|
||||
double m_TotalTime, m_AvgFrametime, m_MinFrametime, m_MaxFrametime;
|
||||
|
||||
vector<FetchFrameRecord> m_FrameRecord;
|
||||
const FetchDrawcall *GetDrawcall(const FetchDrawcall *draw, uint32_t eventID);
|
||||
vector<FetchDrawcall *> m_Drawcalls;
|
||||
|
||||
struct PhysicalDeviceData
|
||||
{
|
||||
|
||||
@@ -586,7 +586,7 @@ vector<uint32_t> VulkanReplay::GetPassEvents(uint32_t frameID, uint32_t eventID)
|
||||
if(start->flags & eDraw_Drawcall)
|
||||
passEvents.push_back(start->eventID);
|
||||
|
||||
start = m_pDriver->GetDrawcall((uint32_t)start->next, 0);
|
||||
start = m_pDriver->GetDrawcall(frameID, (uint32_t)start->next);
|
||||
}
|
||||
|
||||
return passEvents;
|
||||
|
||||
@@ -155,3 +155,44 @@ class IReplayDriver : public IRemoteDriver
|
||||
virtual void PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t sliceFace, uint32_t mip, uint32_t sample, float pixel[4]) = 0;
|
||||
virtual uint32_t PickVertex(uint32_t frameID, uint32_t eventID, MeshDisplay cfg, uint32_t x, uint32_t y) = 0;
|
||||
};
|
||||
|
||||
// utility function useful in any driver implementation
|
||||
template<typename FetchDrawcallContainer>
|
||||
FetchDrawcall *SetupDrawcallPointers(vector<FetchDrawcall*> *drawcallTable, ResourceId contextID, FetchDrawcallContainer &draws,
|
||||
FetchDrawcall *parent, FetchDrawcall *previous)
|
||||
{
|
||||
FetchDrawcall *ret = NULL;
|
||||
|
||||
for(size_t i=0; i < draws.size(); i++)
|
||||
{
|
||||
FetchDrawcall *draw = &draws[i];
|
||||
|
||||
draw->parent = parent ? parent->eventID : 0;
|
||||
|
||||
if(draw->children.count > 0)
|
||||
{
|
||||
ret = previous = SetupDrawcallPointers(drawcallTable, contextID, draw->children, draw, previous);
|
||||
}
|
||||
else if(draw->flags & (eDraw_PushMarker|eDraw_SetMarker|eDraw_Present|eDraw_MultiDraw))
|
||||
{
|
||||
// don't want to set up previous/next links for markers
|
||||
}
|
||||
else
|
||||
{
|
||||
if(previous != NULL)
|
||||
previous->next = draw->eventID;
|
||||
draw->previous = previous ? previous->eventID : 0;
|
||||
|
||||
if(drawcallTable)
|
||||
{
|
||||
RDCASSERT(drawcallTable->empty() || draw->eventID > drawcallTable->back()->eventID || draw->context != contextID);
|
||||
drawcallTable->resize(RDCMAX(drawcallTable->size(), size_t(draw->eventID+1)));
|
||||
(*drawcallTable)[draw->eventID] = draw;
|
||||
}
|
||||
|
||||
ret = previous = draw;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1487,47 +1487,12 @@ ReplayCreateStatus ReplayRenderer::PostCreateInit(IReplayDriver *device)
|
||||
m_FrameRecord.back().frameInfo = fr[i].frameInfo;
|
||||
m_FrameRecord.back().m_DrawCallList = fr[i].drawcallList;
|
||||
|
||||
SetupDrawcallPointers(fr[i].frameInfo, m_FrameRecord.back().m_DrawCallList, NULL, NULL);
|
||||
SetupDrawcallPointers(&m_Drawcalls, fr[i].frameInfo.immContextId, m_FrameRecord.back().m_DrawCallList, NULL, NULL);
|
||||
}
|
||||
|
||||
return eReplayCreate_Success;
|
||||
}
|
||||
|
||||
FetchDrawcall *ReplayRenderer::SetupDrawcallPointers(FetchFrameInfo frame, rdctype::array<FetchDrawcall> &draws, FetchDrawcall *parent, FetchDrawcall *previous)
|
||||
{
|
||||
FetchDrawcall *ret = NULL;
|
||||
|
||||
for(int32_t i=0; i < draws.count; i++)
|
||||
{
|
||||
FetchDrawcall *draw = &draws[i];
|
||||
|
||||
draw->parent = parent ? parent->eventID : 0;
|
||||
|
||||
if(draw->children.count > 0)
|
||||
{
|
||||
ret = previous = SetupDrawcallPointers(frame, draw->children, draw, previous);
|
||||
}
|
||||
else if(draw->flags & (eDraw_PushMarker|eDraw_SetMarker|eDraw_Present|eDraw_MultiDraw))
|
||||
{
|
||||
// don't want to set up previous/next links for markers
|
||||
}
|
||||
else
|
||||
{
|
||||
if(previous != NULL)
|
||||
previous->next = draw->eventID;
|
||||
draw->previous = previous ? previous->eventID : 0;
|
||||
|
||||
RDCASSERT(m_Drawcalls.empty() || draw->eventID > m_Drawcalls.back()->eventID || draw->context != frame.immContextId);
|
||||
m_Drawcalls.resize(RDCMAX(m_Drawcalls.size(), size_t(draw->eventID+1)));
|
||||
m_Drawcalls[draw->eventID] = draw;
|
||||
|
||||
ret = previous = draw;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ReplayRenderer::FileChanged()
|
||||
{
|
||||
m_pDevice->FileChanged();
|
||||
|
||||
@@ -197,7 +197,6 @@ struct ReplayRenderer : public IReplayRenderer
|
||||
ReplayCreateStatus PostCreateInit(IReplayDriver *device);
|
||||
|
||||
FetchDrawcall *GetDrawcallByEID(uint32_t eventID, uint32_t defEventID);
|
||||
FetchDrawcall *SetupDrawcallPointers(FetchFrameInfo frame, rdctype::array<FetchDrawcall> &draws, FetchDrawcall *parent, FetchDrawcall *previous);
|
||||
|
||||
IReplayDriver *GetDevice() { return m_pDevice; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user