From cab8c4f649edb8da879b3255431d13aa55dc28a3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 25 Feb 2026 11:32:59 +0000 Subject: [PATCH] Only try to read annotations when capturing * This iterator will be invalid on replay --- renderdoc/driver/d3d11/d3d11_context.cpp | 13 +++++++++---- renderdoc/driver/d3d12/d3d12_device.cpp | 11 ++++++++--- renderdoc/driver/gl/gl_driver.cpp | 13 +++++++++---- renderdoc/driver/vulkan/vk_core.cpp | 11 ++++++++--- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 1c08deecc..0c34d1b56 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -473,18 +473,23 @@ bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(SerialiserType &ser for(uint32_t i = 0; i < numAnnotations; i++) { SERIALISE_ELEMENT_LOCAL(id, it->first); - SDObject *annotation = it->second; + SDObject *annotation = NULL; if(ser.IsReading()) + { annotation = new SDObject(""_lit, ""_lit); // will be overwritten below + } + else + { + annotation = it->second; + it++; + } ser.Serialise("annotation"_lit, *annotation); if(ser.IsReading() && IsLoading(m_State)) { m_Annotations[id] = annotation; - m_pDevice->GetReplay()->GetResourceDesc(id).annotations = annotation; + m_Replay->GetResourceDesc(id).annotations = annotation; } - - ++it; } if(numAnnotations > 0) diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 6a4529db5..5ba55cb20 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -2761,9 +2761,16 @@ bool WrappedID3D12Device::Serialise_BeginCaptureFrame(SerialiserType &ser) for(uint32_t i = 0; i < numAnnotations; i++) { SERIALISE_ELEMENT_LOCAL(id, it->first); - SDObject *annotation = it->second; + SDObject *annotation = NULL; if(ser.IsReading()) + { annotation = new SDObject(""_lit, ""_lit); // will be overwritten below + } + else + { + annotation = it->second; + it++; + } ser.Serialise("annotation"_lit, *annotation); if(ser.IsReading() && IsLoading(m_State)) @@ -2771,8 +2778,6 @@ bool WrappedID3D12Device::Serialise_BeginCaptureFrame(SerialiserType &ser) m_Annotations[id] = annotation; m_Replay->GetResourceDesc(id).annotations = annotation; } - - ++it; } if(numAnnotations > 0) diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index ae008be61..72c09ecb1 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -3142,18 +3142,23 @@ bool WrappedOpenGL::Serialise_BeginCaptureFrame(SerialiserType &ser) for(uint32_t i = 0; i < numAnnotations; i++) { SERIALISE_ELEMENT_LOCAL(id, it->first); - SDObject *annotation = it->second; + SDObject *annotation = NULL; if(ser.IsReading()) + { annotation = new SDObject(""_lit, ""_lit); // will be overwritten below + } + else + { + annotation = it->second; + it++; + } ser.Serialise("annotation"_lit, *annotation); if(ser.IsReading() && IsLoading(m_State)) { m_Annotations[id] = annotation; - GetReplay()->GetResourceDesc(id).annotations = annotation; + m_Replay->GetResourceDesc(id).annotations = annotation; } - - ++it; } if(numAnnotations > 0) diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index d90ac485b..37520b26d 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -2643,9 +2643,16 @@ bool WrappedVulkan::Serialise_BeginCaptureFrame(SerialiserType &ser) for(uint32_t i = 0; i < numAnnotations; i++) { SERIALISE_ELEMENT_LOCAL(id, it->first); - SDObject *annotation = it->second; + SDObject *annotation = NULL; if(ser.IsReading()) + { annotation = new SDObject(""_lit, ""_lit); // will be overwritten below + } + else + { + annotation = it->second; + it++; + } ser.Serialise("annotation"_lit, *annotation); if(ser.IsReading() && IsLoading(m_State)) @@ -2653,8 +2660,6 @@ bool WrappedVulkan::Serialise_BeginCaptureFrame(SerialiserType &ser) m_Annotations[id] = annotation; m_Replay->GetResourceDesc(id).annotations = annotation; } - - ++it; } if(numAnnotations > 0)