Remove redundant callstack member in APIEvent

* We already link to the chunk index and the chunk metadata contains the
  callstack, there's no need for a duplicate copy when there may be many
  APIEvents in a capture
This commit is contained in:
baldurk
2021-02-24 13:52:07 +00:00
parent 728fa34acc
commit d6e88ae4fa
8 changed files with 30 additions and 27 deletions
+20 -10
View File
@@ -25,8 +25,6 @@
#include "APIInspector.h"
#include "ui_APIInspector.h"
Q_DECLARE_METATYPE(APIEvent);
APIInspector::APIInspector(ICaptureContext &ctx, QWidget *parent)
: QFrame(parent), ui(new Ui::APIInspector), m_Ctx(ctx)
{
@@ -159,17 +157,27 @@ void APIInspector::on_apiEvents_itemSelectionChanged()
{
RDTreeWidgetItem *node = ui->apiEvents->selectedItem();
if(!node)
return;
SDChunk *chunk = NULL;
// search up the tree to find the next parent with a chunk tag
while(node)
{
chunk = (SDChunk *)node->tag().value<quintptr>();
APIEvent ev = node->tag().value<APIEvent>();
// if we found one, break
if(chunk)
break;
if(!ev.callstack.isEmpty())
// move to the parent
node = node->parent();
}
if(chunk && !chunk->metadata.callstack.isEmpty())
{
if(m_Ctx.Replay().GetCaptureAccess())
{
m_Ctx.Replay().AsyncInvoke([this, ev](IReplayController *) {
rdcarray<rdcstr> stack = m_Ctx.Replay().GetCaptureAccess()->GetResolve(ev.callstack);
m_Ctx.Replay().AsyncInvoke([this, chunk](IReplayController *) {
rdcarray<rdcstr> stack =
m_Ctx.Replay().GetCaptureAccess()->GetResolve(chunk->metadata.callstack);
GUIInvoke::call(this, [this, stack]() { addCallstack(stack); });
});
@@ -207,9 +215,11 @@ void APIInspector::fillAPIView()
{
RDTreeWidgetItem *root = new RDTreeWidgetItem({QString::number(ev.eventId), QString()});
SDChunk *chunk = NULL;
if(ev.chunkIndex < file.chunks.size())
{
SDChunk *chunk = file.chunks[ev.chunkIndex];
chunk = file.chunks[ev.chunkIndex];
m_Chunks.push_back(chunk);
@@ -225,7 +235,7 @@ void APIInspector::fillAPIView()
if(ev.eventId == draw->eventId)
root->setBold(true);
root->setTag(QVariant::fromValue(ev));
root->setTag(QVariant::fromValue((quintptr)(void *)chunk));
ui->apiEvents->addTopLevelItem(root);
-6
View File
@@ -723,12 +723,6 @@ of results part way through the multi draw.
)");
uint32_t eventId = 0;
DOCUMENT(R"(The addresses in the CPU callstack where this function was called.
:type: List[int]
)");
rdcarray<uint64_t> callstack;
DOCUMENT("The chunk index for this function call in the structured file.");
uint32_t chunkIndex = 0;
-2
View File
@@ -1173,8 +1173,6 @@ void WrappedID3D11DeviceContext::AddEvent()
apievent.chunkIndex = uint32_t(m_StructuredFile->chunks.size() - 1);
apievent.callstack = m_ChunkMetadata.callstack;
m_CurEvents.push_back(apievent);
if(IsLoading(m_State))
@@ -1612,8 +1612,6 @@ void D3D12CommandData::AddEvent()
apievent.chunkIndex = uint32_t(m_StructuredFile->chunks.size() - 1);
apievent.callstack = m_ChunkMetadata.callstack;
// if we're using replay-time debug messages, fetch them now since we can do better to correlate
// to events on replay
if(m_pDevice->GetReplayOptions().apiValidation)
-2
View File
@@ -5620,8 +5620,6 @@ void WrappedOpenGL::AddEvent()
apievent.chunkIndex = uint32_t(m_StructuredFile->chunks.size() - 1);
apievent.callstack = m_ChunkMetadata.callstack;
m_CurEvents.push_back(apievent);
if(IsLoading(m_State))
-2
View File
@@ -4393,8 +4393,6 @@ void WrappedVulkan::AddEvent()
apievent.chunkIndex = uint32_t(m_StructuredFile->chunks.size() - 1);
apievent.callstack = m_ChunkMetadata.callstack;
for(size_t i = 0; i < m_EventMessages.size(); i++)
m_EventMessages[i].eventId = apievent.eventId;
+1 -2
View File
@@ -537,11 +537,10 @@ template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, APIEvent &el)
{
SERIALISE_MEMBER(eventId);
SERIALISE_MEMBER(callstack);
SERIALISE_MEMBER(chunkIndex);
SERIALISE_MEMBER(fileOffset);
SIZE_CHECK(48);
SIZE_CHECK(16);
}
template <typename SerialiserType>
+9 -1
View File
@@ -51,7 +51,15 @@ class GL_Callstacks(rdtest.TestCase):
8002
]
callstack = cap.GetResolve(list(event.callstack))
sdfile = self.controller.GetStructuredFile()
if event.chunkIndex < 0 or event.chunkIndex > len(sdfile.chunks):
raise rdtest.TestFailureException("Event {} has invalid chunk index {}"
.format(event.eventId, event.chunkIndex))
chunk = sdfile.chunks[event.chunkIndex]
callstack = cap.GetResolve(list(chunk.metadata.callstack))
if len(callstack) < len(expected_funcs):
raise rdtest.TestFailureException("Resolved callstack isn't long enough ({} stack frames), expected at least {}".format(len(event.callstack), len(expected_funcs)))