From be411b37d4580f927693c5ea552e5bf6937e46c9 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:51:08 -0700 Subject: [PATCH] vulkan: Fix dynamic vertex binding stride validation errors. (#1229) --- src/video_core/buffer_cache/buffer_cache.cpp | 9 +++++++++ src/video_core/renderer_vulkan/vk_instance.cpp | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/video_core/buffer_cache/buffer_cache.cpp b/src/video_core/buffer_cache/buffer_cache.cpp index 607543a52..43dc2fdc9 100644 --- a/src/video_core/buffer_cache/buffer_cache.cpp +++ b/src/video_core/buffer_cache/buffer_cache.cpp @@ -105,6 +105,15 @@ bool BufferCache::BindVertexBuffers(const Shader::Info& vs_info) { if (instance.IsVertexInputDynamicState()) { const auto cmdbuf = scheduler.CommandBuffer(); cmdbuf.setVertexInputEXT(bindings, attributes); + } else if (bindings.empty()) { + // 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 = {GetBuffer(NULL_BUFFER_ID).buffer.buffer}; + constexpr std::array null_offsets = {static_cast(0)}; + cmdbuf.bindVertexBuffers2EXT(0, null_buffers, null_offsets, null_offsets, null_offsets); } }; diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index 022ef16c5..3f874ff88 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -366,6 +366,9 @@ bool Instance::CreateDevice() { vk::PhysicalDeviceColorWriteEnableFeaturesEXT{ .colorWriteEnable = true, }, + vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT{ + .extendedDynamicState = true, + }, vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT{ .extendedDynamicState3ColorWriteMask = true, },