Fix crash when postvs cache is cleared if old buffers are referenced

This commit is contained in:
baldurk
2026-02-11 13:30:21 +00:00
parent deb0a4935c
commit c14a4807ba
5 changed files with 20 additions and 13 deletions
+7 -4
View File
@@ -49,7 +49,10 @@ static uint32_t VisModeToMeshDisplayFormat(const MeshDisplay &cfg)
void D3D11Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secondaryDraws,
const MeshDisplay &cfg)
{
if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0)
if(cfg.position.vertexResourceId == ResourceId() ||
WrappedID3D11Buffer::m_BufferList.find(cfg.position.vertexResourceId) ==
WrappedID3D11Buffer::m_BufferList.end() ||
cfg.position.numIndices == 0)
return;
D3D11MarkerRegion renderMesh(
@@ -199,7 +202,9 @@ void D3D11Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
{
const MeshFormat &fmt = secondaryDraws[i];
if(fmt.vertexResourceId != ResourceId())
auto it = WrappedID3D11Buffer::m_BufferList.find(fmt.vertexResourceId);
if(fmt.vertexResourceId != ResourceId() && it != WrappedID3D11Buffer::m_BufferList.end())
{
pixelData.MeshColour = Vec3f(fmt.meshColor.x, fmt.meshColor.y, fmt.meshColor.z);
GetDebugManager()->FillCBuffer(psCBuf, &pixelData, sizeof(pixelData));
@@ -207,8 +212,6 @@ void D3D11Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
m_pImmediateContext->IASetPrimitiveTopology(MakeD3DPrimitiveTopology(fmt.topology));
auto it = WrappedID3D11Buffer::m_BufferList.find(fmt.vertexResourceId);
ID3D11Buffer *buf = it->second.m_Buffer;
m_pImmediateContext->IASetVertexBuffers(0, 1, &buf, (UINT *)&fmt.vertexByteStride,
(UINT *)&fmt.vertexByteOffset);
+5 -2
View File
@@ -246,7 +246,9 @@ MeshDisplayPipelines D3D12DebugManager::CacheMeshDisplayPipelines(const MeshForm
void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secondaryDraws,
const MeshDisplay &cfg)
{
if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0)
if(cfg.position.vertexResourceId == ResourceId() ||
!m_pDevice->GetResourceManager()->HasResource(cfg.position.vertexResourceId) ||
cfg.position.numIndices == 0)
return;
auto it = m_OutputWindows.find(m_CurrentOutputWindow);
@@ -348,7 +350,8 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
{
const MeshFormat &fmt = secondaryDraws[i];
if(fmt.vertexResourceId != ResourceId())
if(fmt.vertexResourceId != ResourceId() &&
m_pDevice->GetResourceManager()->HasResource(fmt.vertexResourceId))
{
MeshDisplayPipelines secondaryCache =
GetDebugManager()->CacheMeshDisplayPipelines(secondaryDraws[i], secondaryDraws[i]);
+3 -1
View File
@@ -48,7 +48,9 @@ void GLReplay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secondar
{
WrappedOpenGL &drv = *m_pDriver;
if(cfg.position.vertexResourceId == ResourceId())
if(cfg.position.vertexResourceId == ResourceId() ||
!m_pDriver->GetResourceManager()->HasResource(cfg.position.vertexResourceId) ||
cfg.position.numIndices == 0)
return;
MakeCurrentReplayContext(m_DebugCtx);
+5 -2
View File
@@ -459,7 +459,9 @@ VKMeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(VkPipelineL
void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secondaryDraws,
const MeshDisplay &cfg)
{
if(cfg.position.vertexResourceId == ResourceId() || cfg.position.numIndices == 0)
if(cfg.position.vertexResourceId == ResourceId() ||
!m_pDriver->GetResourceManager()->HasResource(cfg.position.vertexResourceId) ||
cfg.position.numIndices == 0)
return;
auto it = m_OutputWindows.find(m_ActiveWinID);
@@ -576,7 +578,8 @@ void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &seco
{
const MeshFormat &fmt = secondaryDraws[i];
if(fmt.vertexResourceId != ResourceId())
if(fmt.vertexResourceId != ResourceId() &&
m_pDriver->GetResourceManager()->HasResource(fmt.vertexResourceId))
{
// TODO should move the color to a push constant so we don't have to map all the time
MeshUBOData *data = (MeshUBOData *)m_MeshRender.UBO.Map(&dynOffs[0]);
-4
View File
@@ -1031,10 +1031,6 @@ void ReplayOutput::DisplayMesh()
m_pController->FatalErrorCheck();
MeshDisplay mesh = m_RenderData.meshDisplay;
mesh.position.vertexResourceId = mesh.position.vertexResourceId;
mesh.position.indexResourceId = mesh.position.indexResourceId;
mesh.second.vertexResourceId = mesh.second.vertexResourceId;
mesh.second.indexResourceId = mesh.second.indexResourceId;
rdcarray<MeshFormat> secondaryDraws;