Ensure annotations aren't deleted early on device lost

* Similar to the structured file, the ownership of these must pass to the dummy
  driver to be kept alive until it's deleted.
This commit is contained in:
baldurk
2026-08-25 23:20:28 +01:00
parent 7a84691cf0
commit e744863a06
13 changed files with 59 additions and 8 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ public:
}
IReplayDriver *MakeDummyDriver()
{
IReplayDriver *ret = new DummyDriver(this, {}, m_File);
IReplayDriver *ret = new DummyDriver(this, {}, m_File, {});
// lose our structured file reference
m_File = NULL;
return ret;
+1 -1
View File
@@ -3113,7 +3113,7 @@ IReplayDriver *ReplayProxy::MakeDummyDriver()
shaders.push_back(it.second);
m_PointerReflectionCache.clear();
IReplayDriver *dummy = new DummyDriver(this, shaders, m_StructuredFile);
IReplayDriver *dummy = new DummyDriver(this, shaders, m_StructuredFile, {});
// the dummy driver now owns the file, remove our reference
m_StructuredFile = NULL;
+10
View File
@@ -349,6 +349,16 @@ public:
void AttemptCapture();
void FinishCapture();
rdcarray<SDObject *> DetachAnnotations()
{
rdcarray<SDObject *> ret;
ret.swap(m_EventAnnotations);
for(auto it = m_Annotations.begin(); it != m_Annotations.end(); ++it)
ret.push_back(it->second);
m_Annotations.clear();
return ret;
}
D3D11RenderState *GetCurrentPipelineState() { return m_CurrentPipelineState; }
ResourceId GetResourceID() { return m_ResourceID; }
D3D11ResourceRecord *GetResourceRecord() { return m_ContextRecord; }
+2 -1
View File
@@ -97,7 +97,8 @@ IReplayDriver *D3D11Replay::MakeDummyDriver()
rdcarray<const ShaderReflection *> shaders;
WrappedID3D11Shader<ID3D11ComputeShader>::GetReflections(shaders);
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDevice->DetachStructuredFile());
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDevice->DetachStructuredFile(),
m_pDevice->GetImmediateContext()->DetachAnnotations());
return dummy;
}
+11
View File
@@ -4934,6 +4934,17 @@ void WrappedID3D12Device::DataUploadSync()
}
}
rdcarray<SDObject *> WrappedID3D12Device::DetachAnnotations()
{
rdcarray<SDObject *> ret;
if(m_Queue)
ret.swap(m_Queue->GetCommandData()->m_EventAnnotations);
for(auto it = m_Annotations.begin(); it != m_Annotations.end(); ++it)
ret.push_back(it->second);
m_Annotations.clear();
return ret;
}
void WrappedID3D12Device::InternalQueueWaitForIdle()
{
QueueWaitForIdle(GetQueue(), m_WFIFence);
+1
View File
@@ -1188,6 +1188,7 @@ public:
m_StoredStructuredData = m_StructuredFile = NULL;
return ret;
}
rdcarray<SDObject *> DetachAnnotations();
uint64_t GetTimeBase() { return m_TimeBase; }
double GetTimeFrequency() { return m_TimeFrequency; }
// interface for DXGI
+2 -1
View File
@@ -169,7 +169,8 @@ IReplayDriver *D3D12Replay::MakeDummyDriver()
rdcarray<const ShaderReflection *> shaders;
WrappedID3D12Shader::GetReflections(shaders);
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDevice->DetachStructuredFile());
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDevice->DetachStructuredFile(),
m_pDevice->DetachAnnotations());
return dummy;
}
+9
View File
@@ -668,6 +668,15 @@ public:
m_StoredStructuredData = m_StructuredFile = NULL;
return ret;
}
rdcarray<SDObject *> DetachAnnotations()
{
rdcarray<SDObject *> ret;
ret.swap(m_EventAnnotations);
for(auto it = m_Annotations.begin(); it != m_Annotations.end(); ++it)
ret.push_back(it->second);
m_Annotations.clear();
return ret;
}
void SetFetchCounters(bool in) { m_FetchCounters = in; };
void SetDebugMsgContext(const rdcstr &context) { m_DebugMsgContext = context; }
void AddDebugMessage(DebugMessage msg)
+2 -1
View File
@@ -106,7 +106,8 @@ IReplayDriver *GLReplay::MakeDummyDriver()
shaders.push_back(it->second.StealReflection());
}
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDriver->DetachStructuredFile());
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDriver->DetachStructuredFile(),
m_pDriver->DetachAnnotations());
return dummy;
}
+10
View File
@@ -1380,6 +1380,16 @@ public:
m_StoredStructuredData = m_StructuredFile = NULL;
return ret;
}
rdcarray<SDObject *> DetachAnnotations()
{
rdcarray<SDObject *> ret;
ret.swap(m_EventAnnotations);
for(auto it = m_Annotations.begin(); it != m_Annotations.end(); ++it)
ret.push_back(it->second);
m_Annotations.clear();
return ret;
}
const APIEvent &GetEvent(uint32_t eventId);
uint32_t GetMaxEID() { return m_Events.back().eventId; }
const ActionDescription *GetAction(uint32_t eventId);
+2 -1
View File
@@ -106,7 +106,8 @@ IReplayDriver *VulkanReplay::MakeDummyDriver()
}
}
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDriver->DetachStructuredFile());
IReplayDriver *dummy = new DummyDriver(this, shaders, m_pDriver->DetachStructuredFile(),
m_pDriver->DetachAnnotations());
return dummy;
}
+6 -1
View File
@@ -25,9 +25,10 @@
#include "dummy_driver.h"
DummyDriver::DummyDriver(IReplayDriver *original, const rdcarray<const ShaderReflection *> &shaders,
SDFile *sdfile)
SDFile *sdfile, const rdcarray<SDObject *> &annotations)
{
m_Shaders = shaders;
m_Annotations = annotations;
m_SDFile = sdfile;
m_Props = original->GetAPIProperties();
@@ -54,6 +55,10 @@ DummyDriver::~DummyDriver()
for(const ShaderReflection *refl : m_Shaders)
delete refl;
// and annotations
for(const SDObject *ann : m_Annotations)
delete ann;
// and we own the structured file
delete m_SDFile;
}
+2 -1
View File
@@ -34,7 +34,7 @@ class DummyDriver : public IReplayDriver
{
public:
DummyDriver(IReplayDriver *original, const rdcarray<const ShaderReflection *> &shaders,
SDFile *sdfile);
SDFile *sdfile, const rdcarray<SDObject *> &annotations);
void Shutdown();
@@ -193,6 +193,7 @@ private:
virtual ~DummyDriver();
rdcarray<const ShaderReflection *> m_Shaders;
rdcarray<SDObject *> m_Annotations;
SDFile *m_SDFile;
APIProperties m_Props;