From ee57c2fd69ca0efca51b19eadbca21d0a7347c2b Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 5 Oct 2024 11:35:02 -0700 Subject: [PATCH] vulkan: Fix two more validation errors. (#1250) --- src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 5 +++-- src/video_core/renderer_vulkan/vk_swapchain.cpp | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 6a9eb246..3a54e0ff 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -392,8 +392,9 @@ void EmitContext::DefineBuffers() { const bool is_storage = desc.IsStorage(sharp); const auto* data_types = True(desc.used_types & IR::Type::F32) ? &F32 : &U32; const Id data_type = (*data_types)[1]; - const Id record_array_type{is_storage ? TypeRuntimeArray(data_type) - : TypeArray(data_type, ConstU32(sharp.NumDwords()))}; + const Id record_array_type{ + is_storage ? TypeRuntimeArray(data_type) + : TypeArray(data_type, ConstU32(std::max(sharp.NumDwords(), 1U)))}; const Id struct_type{define_struct(record_array_type, desc.is_instance_data)}; const auto storage_class = diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 8c268c9b..357cd504 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -197,6 +197,11 @@ void Swapchain::SetSurfaceProperties() { void Swapchain::Destroy() { vk::Device device = instance.GetDevice(); + const auto wait_result = device.waitIdle(); + if (wait_result != vk::Result::eSuccess) { + LOG_WARNING(Render_Vulkan, "Failed to wait for device to become idle: {}", + vk::to_string(wait_result)); + } if (swapchain) { device.destroySwapchainKHR(swapchain); }