From 655150918b7ac934603e3ea7a86003d6bcd40a50 Mon Sep 17 00:00:00 2001 From: Lina Versace Date: Thu, 23 Mar 2023 13:57:08 -0700 Subject: [PATCH] venus: Enable VK_EXT_memory_budget Tested dEQP-VK.info.device_memory_budget on Intel with vtest. When the test is ran at approximately the same time on the native driver and on vtest, the qpa result files each report approximately the same memory budget. Signed-off-by: Lina Versace Reviewed-by: Yiwei Zhang Reviewed-by: Ryan Neph Part-of: --- src/virtio/vulkan/vn_physical_device.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 19ac85b2981..cb30f093cc5 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -1123,6 +1123,7 @@ vn_physical_device_get_passthrough_extensions( .EXT_image_view_min_lod = true, .EXT_index_type_uint8 = true, .EXT_line_rasterization = true, + .EXT_memory_budget = true, .EXT_multi_draw = true, .EXT_mutable_descriptor_type = true, .EXT_primitive_topology_list_restart = true, @@ -1900,7 +1901,29 @@ vn_GetPhysicalDeviceMemoryProperties2( { struct vn_physical_device *physical_dev = vn_physical_device_from_handle(physicalDevice); + struct vn_instance *instance = physical_dev->instance; + VkPhysicalDeviceMemoryBudgetPropertiesEXT *memory_budget = NULL; + /* Don't waste time searching for unsupported structs. */ + if (physical_dev->base.base.supported_extensions.EXT_memory_budget) { + memory_budget = + vk_find_struct(pMemoryProperties->pNext, + PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT); + } + + /* When the app queries invariant memory properties, we return a cached + * copy. For dynamic properties, we must query the server. + */ + if (memory_budget) { + vn_call_vkGetPhysicalDeviceMemoryProperties2(instance, physicalDevice, + pMemoryProperties); + } + + /* Even when we query the server for memory properties, we must still + * overwrite the invariant memory properties returned from the server with + * our cached version. Our cached version may differ from the server's + * version due to workarounds. + */ pMemoryProperties->memoryProperties = physical_dev->memory_properties.memoryProperties; }