From 194993875252941e5f2b1083c0b5406ef234dc0b Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Thu, 23 Oct 2025 13:28:34 +0200 Subject: [PATCH] Tie max bindless texture slots to a CVar, as a workaround for some issues. --- .../vulkan/descriptorsets/vk_descriptorset.cpp | 11 ++++++++++- .../vulkan/descriptorsets/vk_descriptorset.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.cpp b/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.cpp index 5f89cc24b..5d5166472 100644 --- a/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.cpp +++ b/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.cpp @@ -38,6 +38,12 @@ #include "hw_viewpointuniforms.h" #include "v_2ddrawer.h" #include "fcolormap.h" +#include "printf.h" + +CUSTOM_CVAR(Int, vk_max_bindless_textures, 16536, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} VkDescriptorSetManager::VkDescriptorSetManager(VulkanRenderDevice* fb) : fb(fb) { @@ -381,6 +387,9 @@ void VkDescriptorSetManager::CreateFixedPool() void VkDescriptorSetManager::CreateBindlessSet() { + // [MK] ensure this value remains unchanged until next restart + MaxBindlessTextures = vk_max_bindless_textures; + Bindless.Pool = DescriptorPoolBuilder() .Flags(VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT) .AddPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MaxBindlessTextures) @@ -435,7 +444,7 @@ int VkDescriptorSetManager::AllocBindlessSlot(int count) else { if (Bindless.NextIndex + count > MaxBindlessTextures) - I_FatalError("Out of bindless texture slots!"); + I_FatalError("Out of bindless texture slots. Try raising the value of vk_max_bindless_textures."); int index = Bindless.NextIndex; if (Bindless.AllocSizes.size() < index + count) Bindless.AllocSizes.resize(index + count, 0); diff --git a/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.h b/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.h index 62197163d..728648acc 100644 --- a/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.h +++ b/src/common/rendering/vulkan/descriptorsets/vk_descriptorset.h @@ -73,7 +73,7 @@ private: VulkanRenderDevice* fb = nullptr; static const int MaxFixedSets = 100; - static const int MaxBindlessTextures = 16536; + int MaxBindlessTextures; static const int FixedBindlessSlots = 3; static const int MaxLightmaps = 128;