@@ -127,13 +127,24 @@ uint32_t g_vkComputeDeviceDriverVer;
127127 */
128128vk::raii::PhysicalDevice* g_vkComputePhysicalDevice;
129129
130+ /* *
131+ @brief Heap from which g_vkPinnedMemoryType is allocated
132+ */
133+ uint32_t g_vkPinnedMemoryHeap = 0 ;
134+
135+ /* *
136+ @brief Heap from which g_vkLocalMemoryType is allocated
137+ */
138+ uint32_t g_vkLocalMemoryHeap = 0 ;
139+
130140bool IsDevicePreferred (const vk::PhysicalDeviceProperties& a, const vk::PhysicalDeviceProperties& b);
131141
132142// Feature flags indicating that we have support for specific data types / features on the GPU
133143bool g_hasShaderInt64 = false ;
134144bool g_hasShaderInt16 = false ;
135145bool g_hasShaderInt8 = false ;
136146bool g_hasDebugUtils = false ;
147+ bool g_hasMemoryBudget = false ;
137148
138149// Feature flags indicating specific drivers, for bug workarounds
139150bool g_vulkanDeviceIsIntelMesa = false ;
@@ -690,7 +701,18 @@ bool VulkanInit(bool skipGLFW)
690701 if (!strcmp (&ext.extensionName [0 ], " VK_KHR_shader_non_semantic_info" ))
691702 {
692703 hasNonSemanticInfo = true ;
693- LogDebug (" Device has KHR_shader_non_semantic_info, requesting it\n " );
704+ LogDebug (" Device has VK_KHR_shader_non_semantic_info, requesting it\n " );
705+ }
706+
707+ if (!strcmp (&ext.extensionName [0 ], " VK_EXT_memory_budget" ))
708+ {
709+ if (!hasPhysicalDeviceProperties2)
710+ LogWarning (" VK_EXT_memory_budget is supported, but not VK_KHR_get_physical_device_properties2 so it's useless\n " );
711+ else
712+ {
713+ LogDebug (" Device has VK_EXT_memory_budget, requesting it\n " );
714+ g_hasMemoryBudget = true ;
715+ }
694716 }
695717 }
696718
@@ -701,6 +723,8 @@ bool VulkanInit(bool skipGLFW)
701723 devextensions.push_back (" VK_KHR_portability_subset" );
702724 if (hasNonSemanticInfo)
703725 devextensions.push_back (" VK_KHR_shader_non_semantic_info" );
726+ if (g_hasMemoryBudget)
727+ devextensions.push_back (" VK_EXT_memory_budget" );
704728 vk::DeviceCreateInfo devinfo (
705729 {},
706730 qinfo,
@@ -715,6 +739,8 @@ bool VulkanInit(bool skipGLFW)
715739 bool foundLocalType = false ;
716740 g_vkPinnedMemoryType = 0 ;
717741 g_vkLocalMemoryType = 0 ;
742+ g_vkPinnedMemoryType = 0 ;
743+ g_vkLocalMemoryType = 0 ;
718744 auto memProperties = device.getMemoryProperties ();
719745 auto devtype = device.getProperties ().deviceType ;
720746 for (size_t j=0 ; j<memProperties.memoryTypeCount ; j++)
@@ -743,6 +769,7 @@ bool VulkanInit(bool skipGLFW)
743769 {
744770 foundPinnedType = true ;
745771 g_vkPinnedMemoryType = j;
772+ g_vkPinnedMemoryHeap = mtype.heapIndex ;
746773 }
747774 }
748775
@@ -762,6 +789,7 @@ bool VulkanInit(bool skipGLFW)
762789 {
763790 foundLocalType = true ;
764791 g_vkLocalMemoryType = j;
792+ g_vkLocalMemoryHeap = mtype.heapIndex ;
765793 }
766794 }
767795 }
0 commit comments