From afd3e5219141d189d849a4bdc857b9ddb1e66e6e Mon Sep 17 00:00:00 2001 From: Mark Young Date: Mon, 18 Dec 2023 13:49:16 -0700 Subject: [PATCH] Fix Aztec swapchain replay count Fix the swapchain replay count for Aztec by checking the swapchain requirements of the replay system. --- framework/decode/vulkan_cpp_consumer_base.cpp | 29 +++++++++++++++++++ framework/decode/vulkan_cpp_structs.cpp | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/framework/decode/vulkan_cpp_consumer_base.cpp b/framework/decode/vulkan_cpp_consumer_base.cpp index 021c928128..218f992f7f 100644 --- a/framework/decode/vulkan_cpp_consumer_base.cpp +++ b/framework/decode/vulkan_cpp_consumer_base.cpp @@ -582,6 +582,7 @@ void VulkanCppConsumerBase::Generate_vkCreateSwapchainKHR( FILE* file = GetFrameFile(); fprintf(file, "\t{\n"); + // device // pCreateInfo std::stringstream stream_pcreate_info; @@ -602,6 +603,34 @@ void VulkanCppConsumerBase::Generate_vkCreateSwapchainKHR( { this->AddHandles(pswapchain_name, pSwapchain->GetPointer()); } + + DeviceInfo* dev_info = nullptr; + if (device_info_map_.find(device) != device_info_map_.end()) + { + dev_info = device_info_map_[device]; + + fprintf(file, "\t\tVkSurfaceCapabilitiesKHR surface_caps;\n"); + fprintf(file, + "\t\tif (VK_SUCCESS == loaded_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(%s, %s, &surface_caps)) {\n", + this->GetHandle(dev_info->parent).c_str(), + this->GetHandle(pCreateInfo->GetMetaStructPointer()->surface).c_str()); + + // VkSwapchainCreateInfoKHR modified_create_info = *create_info; + // modified_create_info.imageUsage = + // modified_create_info.imageUsage | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + + fprintf(file, "\t\t\tif (%s.minImageCount < surface_caps.minImageCount) {\n", pcreate_info_struct.c_str()); + fprintf(file, "\t\t\t\t%s.minImageCount = surface_caps.minImageCount;\n", pcreate_info_struct.c_str()); + fprintf(file, "\t\t\t}\n"); + fprintf(file, + "\t\t\tif ((surface_caps.maxImageCount > 0) && (%s.minImageCount > surface_caps.maxImageCount)) {\n", + pcreate_info_struct.c_str()); + fprintf(file, "\t\t\t\t%s.minImageCount = surface_caps.maxImageCount;\n", pcreate_info_struct.c_str()); + fprintf(file, "\t\t\t}\n"); + + fprintf(file, "\t\t}\n"); + } + pfn_loader_.AddMethodName("vkCreateSwapchainKHR"); fprintf(file, "\t\tVK_CALL_CHECK(loaded_vkCreateSwapchainKHR(%s, &%s, %s, &%s), %s);\n", diff --git a/framework/decode/vulkan_cpp_structs.cpp b/framework/decode/vulkan_cpp_structs.cpp index 4ee17779b4..c07ffcafc6 100644 --- a/framework/decode/vulkan_cpp_structs.cpp +++ b/framework/decode/vulkan_cpp_structs.cpp @@ -640,7 +640,7 @@ std::string GenerateStruct_VkSwapchainCreateInfoKHR(std::ostream& // surface struct_body << "\t\t\t" << consumer.GetHandle(metaInfo->surface) << "," << std::endl; // minImageCount - struct_body << "\t\t\t3,\n"; // structInfo->minImageCount << "," << std::endl; + struct_body << "\t\t\t" << structInfo->minImageCount << "," << std::endl; // imageFormat struct_body << "\t\t\t" << "VkFormat(" << structInfo->imageFormat << ")"