From a53b85ad93187311ce8bf6c04cc3dd6f13c36f0e Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 20 Sep 2026 08:21:24 -0400 Subject: [PATCH] [MG_Backend] (Disaggregated): memoize immutable wire vertex format capabilities --- .../DirectVulkan/Renderer/VertexInputStateFactory.cpp | 11 +++++++++++ .../DirectVulkan/Renderer/VertexInputStateFactory.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp index 1beb78ad..fda938d4 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp @@ -787,6 +787,17 @@ namespace MobileGL::MG_Backend::DirectVulkan { if (m_physicalDevice == VK_NULL_HANDLE || format == VK_FORMAT_UNDEFINED) { return false; } +#if MOBILEGL_BUILD_DISAGGREGATED + if (MG_Config::Transport != MG_Config::TransportMode::Monolith) { + const auto found = m_wireVertexFormatSupport.find(format); + if (found != m_wireVertexFormatSupport.end()) return found->second; + VkFormatProperties properties{}; + vkGetPhysicalDeviceFormatProperties(m_physicalDevice, format, &properties); + const Bool supported = (properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) != 0; + m_wireVertexFormatSupport.emplace(format, supported); + return supported; + } +#endif VkFormatProperties properties{}; vkGetPhysicalDeviceFormatProperties(m_physicalDevice, format, &properties); return (properties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) != 0; diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h b/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h index f974c02c..bb602cc4 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h @@ -183,6 +183,11 @@ namespace MobileGL::MG_Backend::DirectVulkan { const VulkanRendererConfig& m_config; VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE; +#if MOBILEGL_BUILD_DISAGGREGATED + // Physical-device format capabilities never change during this factory's + // lifetime. The wire path rebuilds layouts without the legacy VAO memo. + mutable UnorderedMap m_wireVertexFormatSupport; +#endif // Values are heap-allocated: UnorderedMap is open-addressing, so INSERT // invalidates references to stored values - and so does ERASE, which shifts // the rest of the probe cluster into the hole and therefore moves entries