From a39569e950f01341cd029abb778eba8f554ac2f6 Mon Sep 17 00:00:00 2001 From: Benson Joeris Date: Fri, 28 Feb 2020 11:24:16 -0500 Subject: [PATCH] Fix image ref state when loading old captures This fixes a performance regression when loading captures from <=v1.6 (before the new image state code went in). The code to import the old image state information was incorrectly discarding the frame ref information, forcing the images to be reinitialized on every replay. In old captures `ImageRefs` chunk is processed, creating `ImageState` objects that only contain `refType`; then `BeginCaptureFrame` processes the `ImageLayouts` info, to construct a new `ImageState` object, containing the layout information. This `ImageState` was overwriting the `ImageState` from the `ImageRefs` chunk, discarding the `refType` info. This change merges the `ImageState`s from `ImageRefs`, where each field of the merged image state comes from whichever `ImageState` had a non-undefined value for that field. For new captures, this change should be safe, since the image state should be undefined when the `BeginCaptureFrame` chunk is processed, so the `MergCaptureBeginState` call will just take all the state fields from the `ImageState` stored in the `BeginCaptureFrame` chunk. Change-Id: Id2252edb6382bd02bc0236b77c7cca667e97bf29 --- renderdoc/driver/vulkan/vk_image_states.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renderdoc/driver/vulkan/vk_image_states.cpp b/renderdoc/driver/vulkan/vk_image_states.cpp index 7860242d6..045c8731c 100644 --- a/renderdoc/driver/vulkan/vk_image_states.cpp +++ b/renderdoc/driver/vulkan/vk_image_states.cpp @@ -941,7 +941,7 @@ void ImageState::Merge(const ImageState &other, ImageTransitionInfo info) void ImageState::MergeCaptureBeginState(const ImageState &initialState) { oldQueueFamilyTransfers = initialState.oldQueueFamilyTransfers; - subresourceStates = initialState.subresourceStates; + subresourceStates.Merge(initialState.subresourceStates, ComposeFrameRefsFirstKnown); maxRefType = initialState.maxRefType; }