From 3c740cbecebe2fc209596711f07263a2d9b5e123 Mon Sep 17 00:00:00 2001 From: AWoloszyn Date: Fri, 4 Jan 2019 10:13:25 -0500 Subject: [PATCH] Handle the case where we destroy an ImageView attached to a framebuffer. --- gapis/api/vulkan/state.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gapis/api/vulkan/state.go b/gapis/api/vulkan/state.go index 421daee474..0fa9745aec 100644 --- a/gapis/api/vulkan/state.go +++ b/gapis/api/vulkan/state.go @@ -54,19 +54,26 @@ func (st *State) getSubmitAttachmentInfo(attachment api.FramebufferAttachment) ( attachmentIndex := uint32(attachment - api.FramebufferAttachment_Color0) if attRef, ok := subpassDesc.ColorAttachments().Lookup(attachmentIndex); ok { if ca, ok := lastDrawInfo.Framebuffer().ImageAttachments().Lookup(attRef.Attachment()); ok { - return ca.Image().Info().Extent().Width(), - ca.Image().Info().Extent().Height(), - ca.Image().Info().Fmt(), - attRef.Attachment(), true, nil + // This can occur if we destroy the image-view, we remove it from the framebuffer, + // but may not unbind the framebuffer. + if !ca.Image().IsNil() { + return ca.Image().Info().Extent().Width(), + ca.Image().Info().Extent().Height(), + ca.Image().Info().Fmt(), + attRef.Attachment(), true, nil + } } - } case api.FramebufferAttachment_Depth: if !subpassDesc.DepthStencilAttachment().IsNil() && !lastDrawInfo.Framebuffer().IsNil() { attRef := subpassDesc.DepthStencilAttachment() if attachment, ok := lastDrawInfo.Framebuffer().ImageAttachments().Lookup(attRef.Attachment()); ok { depthImg := attachment.Image() - return depthImg.Info().Extent().Width(), depthImg.Info().Extent().Height(), depthImg.Info().Fmt(), attRef.Attachment(), true, nil + // This can occur if we destroy the image-view, we remove it from the framebuffer, + // but may not unbind the framebuffer. + if !depthImg.IsNil() { + return depthImg.Info().Extent().Width(), depthImg.Info().Extent().Height(), depthImg.Info().Fmt(), attRef.Attachment(), true, nil + } } } case api.FramebufferAttachment_Stencil: