[vulkan] Another take for BindingStride

This commit is contained in:
CamilleLaVey
2026-02-02 20:18:42 -04:00
parent 06a179fb2a
commit 705090c8da
3 changed files with 10 additions and 11 deletions

View File

@@ -555,9 +555,7 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset
if (index >= device.GetMaxVertexInputBindings()) {
return;
}
const bool use_stride_dynamic = device.IsExtExtendedDynamicStateSupported() &&
!(device.IsExtVertexInputDynamicStateSupported() &&
Settings::values.vertex_input_dynamic_state.GetValue());
const bool use_stride_dynamic = use_dynamic_vertex_binding_stride;
if (use_stride_dynamic) {
scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) {
const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0;
@@ -598,14 +596,8 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bi
if (binding_count == 0) {
return;
}
// Use BindVertexBuffers2EXT (with stride) only if:
// 1. VK_EXT_extended_dynamic_state is supported (provides VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT)
// 2. AND VK_EXT_vertex_input_dynamic_state is NOT active (supported + enabled by toggle)
// Because VIDS and BINDING_STRIDE are mutually exclusive in the pipeline
const bool use_stride_dynamic = device.IsExtExtendedDynamicStateSupported() &&
!(device.IsExtVertexInputDynamicStateSupported() &&
Settings::values.vertex_input_dynamic_state.GetValue());
if (use_stride_dynamic) {
const bool use_stride_dynamic = use_dynamic_vertex_binding_stride;
if (use_stride_dynamic) {
scheduler.Record([bindings_ = std::move(bindings),
buffer_handles_ = std::move(buffer_handles),
binding_count](vk::CommandBuffer cmdbuf) {

View File

@@ -127,6 +127,10 @@ public:
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
void SetUseDynamicVertexBindingStride(bool enabled) noexcept {
use_dynamic_vertex_binding_stride = enabled;
}
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
void BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings);
@@ -185,6 +189,7 @@ private:
bool limit_dynamic_storage_buffers = false;
u32 max_dynamic_storage_buffers = (std::numeric_limits<u32>::max)();
bool use_dynamic_vertex_binding_stride = false;
};
struct BufferCacheParams {

View File

@@ -223,6 +223,8 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
return;
}
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
buffer_cache_runtime.SetUseDynamicVertexBindingStride(
pipeline->UsesExtendedDynamicState() && !pipeline->HasDynamicVertexInput());
// update engine as channel may be different.
pipeline->SetEngine(maxwell3d, gpu_memory);
if (!pipeline->Configure(is_indexed))