radv: Enable VK_EXT_memory_priority.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 28 Jan 2019 01:09:07 +0000 (02:09 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 29 Jan 2019 14:56:56 +0000 (15:56 +0100)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_extensions.py
src/amd/vulkan/radv_radeon_winsys.h

index fdf051bcce9ed80c5c2bb22bd821332212d0c4df..34d93b262f85563f70ba465cc75e095f3800cb18 100644 (file)
@@ -863,6 +863,12 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->scalarBlockLayout = pdevice->rad_info.chip_class >= CIK;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT: {
+                       VkPhysicalDeviceMemoryPriorityFeaturesEXT *features =
+                               (VkPhysicalDeviceMemoryPriorityFeaturesEXT *)ext;
+                       features->memoryPriority = VK_TRUE;
+                       break;
+               }
                default:
                        break;
                }
@@ -3086,6 +3092,16 @@ static VkResult radv_alloc_memory(struct radv_device *device,
                mem->buffer = NULL;
        }
 
+       float priority_float = 0.5;
+       const struct VkMemoryPriorityAllocateInfoEXT *priority_ext =
+               vk_find_struct_const(pAllocateInfo->pNext,
+                                    MEMORY_PRIORITY_ALLOCATE_INFO_EXT);
+       if (priority_ext)
+               priority_float = priority_ext->priority;
+
+       unsigned priority = MIN2(RADV_BO_PRIORITY_APPLICATION_MAX - 1,
+                                (int)(priority_float * RADV_BO_PRIORITY_APPLICATION_MAX));
+
        mem->user_ptr = NULL;
 
        if (import_info) {
@@ -3094,7 +3110,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
                       import_info->handleType ==
                       VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
                mem->bo = device->ws->buffer_from_fd(device->ws, import_info->fd,
-                                                    RADV_BO_PRIORITY_DEFAULT, NULL, NULL);
+                                                    priority, NULL, NULL);
                if (!mem->bo) {
                        result = VK_ERROR_INVALID_EXTERNAL_HANDLE;
                        goto fail;
@@ -3106,7 +3122,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
                assert(mem_type_index == RADV_MEM_TYPE_GTT_CACHED);
                mem->bo = device->ws->buffer_from_ptr(device->ws, host_ptr_info->pHostPointer,
                                                      pAllocateInfo->allocationSize,
-                                                     RADV_BO_PRIORITY_DEFAULT);
+                                                     priority);
                if (!mem->bo) {
                        result = VK_ERROR_INVALID_EXTERNAL_HANDLE;
                        goto fail;
@@ -3133,7 +3149,7 @@ static VkResult radv_alloc_memory(struct radv_device *device,
                        flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING;
 
                mem->bo = device->ws->buffer_create(device->ws, alloc_size, device->physical_device->rad_info.max_alignment,
-                                                   domain, flags, RADV_BO_PRIORITY_DEFAULT);
+                                                   domain, flags, priority);
 
                if (!mem->bo) {
                        result = VK_ERROR_OUT_OF_DEVICE_MEMORY;
index eb3743e9602dbe9708db7cd8b25855092fa8cf06..1bf56943f258bca92b8e71b44218156ba232bf40 100644 (file)
@@ -106,6 +106,7 @@ EXTENSIONS = [
     Extension('VK_EXT_external_memory_host',              1, 'device->rad_info.has_userptr'),
     Extension('VK_EXT_global_priority',                   1, 'device->rad_info.has_ctx_priority'),
     Extension('VK_EXT_memory_budget',                     1, True),
+    Extension('VK_EXT_memory_priority',                   1, True),
     Extension('VK_EXT_pci_bus_info',                      2, True),
     Extension('VK_EXT_sampler_filter_minmax',             1, 'device->rad_info.chip_class >= CIK'),
     Extension('VK_EXT_scalar_block_layout',               1, 'device->rad_info.chip_class >= CIK'),
index 2684aadc81fcf3aa415b58038ce7a9af69a6612b..73410efc252eb25649b1ac20ebec1181f04aee21 100644 (file)
@@ -191,8 +191,6 @@ struct radv_winsys_bo_list {
 /* Kernel effectively allows 0-31. This sets some priorities for fixed
  * functionality buffers */
 enum {
-       RADV_BO_PRIORITY_DEFAULT = 14,
-
        RADV_BO_PRIORITY_APPLICATION_MAX = 28,
 
        /* virtual buffers have 0 priority since the priority is not used. */