From 2caca8b68de7ba9110f6e4d7b6cd4e3114b50840 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Wed, 8 Jan 2025 19:19:45 -0800 Subject: [PATCH] renderer_vulkan: Remove need for empty bindVertexBuffers2EXT. --- src/video_core/buffer_cache/buffer_cache.cpp | 17 +++-------------- .../renderer_vulkan/vk_graphics_pipeline.cpp | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/video_core/buffer_cache/buffer_cache.cpp b/src/video_core/buffer_cache/buffer_cache.cpp index 4d7d63d77..487544a21 100644 --- a/src/video_core/buffer_cache/buffer_cache.cpp +++ b/src/video_core/buffer_cache/buffer_cache.cpp @@ -95,26 +95,13 @@ void BufferCache::BindVertexBuffers(const Vulkan::GraphicsPipeline& pipeline) { Vulkan::VertexInputs guest_buffers; pipeline.GetVertexInputs(attributes, bindings, guest_buffers); - const auto dynamic_input = instance.IsVertexInputDynamicState(); - if (dynamic_input) { + if (instance.IsVertexInputDynamicState()) { // Update current vertex inputs. const auto cmdbuf = scheduler.CommandBuffer(); cmdbuf.setVertexInputEXT(bindings, attributes); } - const auto null_buffer = - instance.IsNullDescriptorSupported() ? VK_NULL_HANDLE : GetBuffer(NULL_BUFFER_ID).Handle(); if (bindings.empty()) { - if (!dynamic_input) { - // Required to call bindVertexBuffers2EXT at least once in the current command buffer - // with non-null strides without a non-dynamic stride pipeline in between. Thus even - // when nothing is bound we still need to make a dummy call. Non-null strides in turn - // requires a count greater than 0. - const auto cmdbuf = scheduler.CommandBuffer(); - const std::array null_buffers = {null_buffer}; - constexpr std::array null_offsets = {static_cast(0)}; - cmdbuf.bindVertexBuffers2EXT(0, null_buffers, null_offsets, null_offsets, null_offsets); - } // If there are no bindings, there is nothing further to do. return; } @@ -167,6 +154,8 @@ void BufferCache::BindVertexBuffers(const Vulkan::GraphicsPipeline& pipeline) { Vulkan::VertexInputs host_offsets; Vulkan::VertexInputs host_sizes; Vulkan::VertexInputs host_strides; + const auto null_buffer = + instance.IsNullDescriptorSupported() ? VK_NULL_HANDLE : GetBuffer(NULL_BUFFER_ID).Handle(); for (const auto& buffer : guest_buffers) { if (buffer.GetSize() > 0) { const auto host_buffer_info = diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 440b67b6c..2d0b19bbe 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -137,7 +137,7 @@ GraphicsPipeline::GraphicsPipeline( } if (instance.IsVertexInputDynamicState()) { dynamic_states.push_back(vk::DynamicState::eVertexInputEXT); - } else { + } else if (!vertex_bindings.empty()) { dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStrideEXT); }