diff --git a/framework/decode/vulkan_replay_consumer_base.cpp b/framework/decode/vulkan_replay_consumer_base.cpp index 2588a4d718..27db8c7a43 100644 --- a/framework/decode/vulkan_replay_consumer_base.cpp +++ b/framework/decode/vulkan_replay_consumer_base.cpp @@ -2156,6 +2156,24 @@ void VulkanReplayConsumerBase::WriteScreenshots(const Decoded_VkPresentInfoKHR* } } +bool VulkanReplayConsumerBase::CheckCommandBufferInfoForFrameBoundary(const CommandBufferInfo* command_buffer_info) +{ + GFXRECON_ASSERT(command_buffer_info != nullptr); + if (command_buffer_info->is_frame_boundary) + { + if (screenshot_handler_->IsScreenshotFrame()) + { + GFXRECON_LOG_ERROR("Unable to take screenshot requested for frame %" PRIu32 + ". The frame ends with vkQueueSubmit* and screenshot requires frames to end with " + "vkQueuePresent.", + screenshot_handler_->GetCurrentFrame()); + } + screenshot_handler_->EndFrame(); + return true; + } + return false; +} + VkResult VulkanReplayConsumerBase::OverrideCreateInstance(VkResult original_result, const StructPointerDecoder* pCreateInfo, @@ -3207,28 +3225,13 @@ VkResult VulkanReplayConsumerBase::OverrideQueueSubmit(PFN_vkQueueSubmit func, for (uint32_t j = 0; j < command_buffer_count; ++j) { auto command_buffer_info = GetObjectInfoTable().GetCommandBufferInfo(command_buffer_ids[j]); - if (command_buffer_info != nullptr) + if (CheckCommandBufferInfoForFrameBoundary(command_buffer_info)) { - if (command_buffer_info->is_frame_boundary) - { - is_frame_boundary = true; - break; - } + break; } } } } - if (is_frame_boundary) - { - if (screenshot_handler_->IsScreenshotFrame()) - { - GFXRECON_LOG_ERROR( - "Unable to take screenshot requested for frame %" PRIu32 - ". The frame ends with vkQueueSubmit and screenshot requires frames to end with vkQueuePresent.", - screenshot_handler_->GetCurrentFrame()); - } - screenshot_handler_->EndFrame(); - } } return result; @@ -3380,28 +3383,13 @@ VkResult VulkanReplayConsumerBase::OverrideQueueSubmit2(PFN_vkQueueSubmit2 func, { auto command_buffer_info = GetObjectInfoTable().GetCommandBufferInfo(command_buffer_infos[j].commandBuffer); - if (command_buffer_info != nullptr) + if (CheckCommandBufferInfoForFrameBoundary(command_buffer_info)) { - if (command_buffer_info->is_frame_boundary) - { - is_frame_boundary = true; - break; - } + break; } } } } - if (is_frame_boundary) - { - if (screenshot_handler_->IsScreenshotFrame()) - { - GFXRECON_LOG_ERROR( - "Unable to take screenshot requested for frame %" PRIu32 - ". The frame ends with vkQueueSubmit2 and screenshot requires frames to end with vkQueuePresent.", - screenshot_handler_->GetCurrentFrame()); - } - screenshot_handler_->EndFrame(); - } } return result; @@ -6396,7 +6384,7 @@ void VulkanReplayConsumerBase::OverrideCmdDebugMarkerInsertEXT( func(command_buffer_info->handle, marker_info); // Look for the debug marker that identifies this command buffer as a VR frame boundary. - if (util::platform::StringContains(marker_info->pMarkerName, "vr-marker,frame_end,type,application")) + if (util::platform::StringContains(marker_info->pMarkerName, graphics::kVulkanVrFrameDelimiterString)) { command_buffer_info->is_frame_boundary = true; } diff --git a/framework/decode/vulkan_replay_consumer_base.h b/framework/decode/vulkan_replay_consumer_base.h index 7c51e1d998..31391c4b45 100644 --- a/framework/decode/vulkan_replay_consumer_base.h +++ b/framework/decode/vulkan_replay_consumer_base.h @@ -1,6 +1,6 @@ /* ** Copyright (c) 2018-2020 Valve Corporation -** Copyright (c) 2018-2022 LunarG, Inc. +** Copyright (c) 2018-2023 LunarG, Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the "Software"), @@ -1052,6 +1052,8 @@ class VulkanReplayConsumerBase : public VulkanConsumer void WriteScreenshots(const Decoded_VkPresentInfoKHR* meta_info) const; + bool CheckCommandBufferInfoForFrameBoundary(const CommandBufferInfo* command_buffer_info); + private: typedef std::unordered_set ActiveWindows; diff --git a/framework/encode/vulkan_capture_manager.cpp b/framework/encode/vulkan_capture_manager.cpp index 2c3976f6b5..1183192bf3 100644 --- a/framework/encode/vulkan_capture_manager.cpp +++ b/framework/encode/vulkan_capture_manager.cpp @@ -1,6 +1,6 @@ /* ** Copyright (c) 2018-2021 Valve Corporation -** Copyright (c) 2018-2021 LunarG, Inc. +** Copyright (c) 2018-2023 LunarG, Inc. ** Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved. ** ** Permission is hereby granted, free of charge, to any person obtaining a @@ -31,6 +31,7 @@ #include "format/format_util.h" #include "generated/generated_vulkan_struct_handle_wrappers.h" #include "graphics/vulkan_device_util.h" +#include "graphics/vulkan_util.h" #include "util/compressor.h" #include "util/logging.h" #include "util/page_guard_manager.h" @@ -2361,13 +2362,11 @@ void VulkanCaptureManager::PostProcess_vkCmdDebugMarkerInsertEXT(VkCommandBuffer if (pMarkerInfo != nullptr) { // Look for the debug marker that identifies this command buffer as a VR frame boundary. - if (util::platform::StringContains(pMarkerInfo->pMarkerName, "vr-marker,frame_end,type,application")) + if (util::platform::StringContains(pMarkerInfo->pMarkerName, graphics::kVulkanVrFrameDelimiterString)) { auto cmd_buffer_wrapper = GetWrapper(commandBuffer); - if (cmd_buffer_wrapper != nullptr) - { - cmd_buffer_wrapper->is_frame_boundary = true; - } + GFXRECON_ASSERT(cmd_buffer_wrapper != nullptr); + cmd_buffer_wrapper->is_frame_boundary = true; } } } @@ -2395,6 +2394,22 @@ bool VulkanCaptureManager::CheckBindAlignment(VkDeviceSize memoryOffset) return true; } +bool VulkanCaptureManager::CheckCommandBufferWrapperForFrameBoundary(const CommandBufferWrapper* command_buffer_wrapper) +{ + GFXRECON_ASSERT(command_buffer_wrapper != nullptr); + if (command_buffer_wrapper->is_frame_boundary) + { + // Because not all vkQueueSubmit calls are frame delimiters, add an end frame marker to the capture + // file for this vkQueueSubmit. + WriteFrameMarker(format::MarkerType::kEndMarker); + + // Do common capture manager end of frame processing. + EndFrame(); + return true; + } + return false; +} + void VulkanCaptureManager::PreProcess_vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, diff --git a/framework/encode/vulkan_capture_manager.h b/framework/encode/vulkan_capture_manager.h index b6bd977a5d..27a9b81328 100644 --- a/framework/encode/vulkan_capture_manager.h +++ b/framework/encode/vulkan_capture_manager.h @@ -1,6 +1,6 @@ /* ** Copyright (c) 2018-2021 Valve Corporation -** Copyright (c) 2018-2021 LunarG, Inc. +** Copyright (c) 2018-2023 LunarG, Inc. ** Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved. ** ** Permission is hereby granted, free of charge, to any person obtaining a @@ -920,15 +920,8 @@ class VulkanCaptureManager : public CaptureManager for (uint32_t j = 0; j < pSubmits[i].commandBufferCount; ++j) { auto cmd_buffer_wrapper = GetWrapper(pSubmits[i].pCommandBuffers[j]); - GFXRECON_ASSERT(cmd_buffer_wrapper != nullptr); - if (cmd_buffer_wrapper->is_frame_boundary) + if (CheckCommandBufferWrapperForFrameBoundary(cmd_buffer_wrapper)) { - // Because not all vkQueueSubmit calls are frame delimiters, add an end frame marker to the capture - // file for this vkQueueSubmit. - WriteFrameMarker(format::MarkerType::kEndMarker); - - // Do common capture manager end of frame processing. - EndFrame(); break; } } @@ -960,10 +953,8 @@ class VulkanCaptureManager : public CaptureManager { auto cmd_buffer_wrapper = GetWrapper(pSubmits[i].pCommandBufferInfos[j].commandBuffer); - GFXRECON_ASSERT(cmd_buffer_wrapper != nullptr); - if (cmd_buffer_wrapper->is_frame_boundary) + if (CheckCommandBufferWrapperForFrameBoundary(cmd_buffer_wrapper)) { - EndFrame(); break; } } @@ -1293,6 +1284,8 @@ class VulkanCaptureManager : public CaptureManager void ReleaseAndroidHardwareBuffer(AHardwareBuffer* hardware_buffer); bool CheckBindAlignment(VkDeviceSize memoryOffset); + bool CheckCommandBufferWrapperForFrameBoundary(const CommandBufferWrapper* command_buffer_wrapper); + private: void QueueSubmitWriteFillMemoryCmd(); diff --git a/framework/graphics/vulkan_util.h b/framework/graphics/vulkan_util.h index 20016e87a5..e016baa94e 100644 --- a/framework/graphics/vulkan_util.h +++ b/framework/graphics/vulkan_util.h @@ -1,5 +1,5 @@ /* -** Copyright (c) 2021 LunarG, Inc. +** Copyright (c) 2021-2023 LunarG, Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and associated documentation files (the "Software"), @@ -61,6 +61,8 @@ static T* GetPNextStruct(const Parent_T* parent, VkStructureType struct_type) return nullptr; } +static const char* kVulkanVrFrameDelimiterString = "vr-marker,frame_end,type,application"; + GFXRECON_END_NAMESPACE(graphics) GFXRECON_END_NAMESPACE(gfxrecon)