radv: disable implicit sync for radv allocated bos v3
authorAndres Rodriguez <andresx7@gmail.com>
Fri, 20 Oct 2017 22:42:13 +0000 (18:42 -0400)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 20 Oct 2017 23:15:54 +0000 (01:15 +0200)
Implicit sync kicks in when a buffer is used by two different amdgpu
contexts simultaneously. Jobs that use explicit synchronization
mechanisms end up needlessly waiting to be scheduled for long periods
of time in order to achieve serialized execution.

This patch disables implicit synchronization for all radv allocations
except for wsi bos. The only systems that require implicit
synchronization are DRI2/3 and PRIME.

v2: mark wsi bos as RADV_MEM_IMPLICIT_SYNC
v3: Add drm version check (Bas)

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_radeon_winsys.h
src/amd/vulkan/radv_wsi.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c

index 5e6e9dcdb588e3c0ae0fbeebf242261a86f61826..c4e25222eaff45a7a8afba19b72939c752d651ba 100644 (file)
@@ -2115,6 +2115,9 @@ VkResult radv_alloc_memory(VkDevice                        _device,
        if (pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_WRITE_COMBINE)
                flags |= RADEON_FLAG_GTT_WC;
 
+       if (mem_flags & RADV_MEM_IMPLICIT_SYNC)
+               flags |= RADEON_FLAG_IMPLICIT_SYNC;
+
        mem->bo = device->ws->buffer_create(device->ws, alloc_size, device->physical_device->rad_info.max_alignment,
                                               domain, flags);
 
index 328b8a19cc5414cc900fccecb688fb9e5a329ced..cf5a9e8f069469d875e5d40cb3561d3dcadc013c 100644 (file)
@@ -53,6 +53,7 @@ enum radeon_bo_flag { /* bitfield */
        RADEON_FLAG_NO_CPU_ACCESS = (1 << 2),
        RADEON_FLAG_VIRTUAL =       (1 << 3),
        RADEON_FLAG_VA_UNCACHED =   (1 << 4),
+       RADEON_FLAG_IMPLICIT_SYNC = (1 << 5),
 };
 
 enum radeon_bo_usage { /* bitfield */
index c9d4bbce8ba2322da265b0c912362837ae3a8920..b65ef27351d4f3b477c0b8cb2d030337b6864150 100644 (file)
@@ -194,7 +194,7 @@ radv_wsi_image_create(VkDevice device_h,
                .image = image_h
        };
 
-       result = radv_AllocateMemory(device_h,
+       result = radv_alloc_memory(device_h,
                                     &(VkMemoryAllocateInfo) {
                                             .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
                                             .pNext = &ded_alloc,
@@ -202,6 +202,7 @@ radv_wsi_image_create(VkDevice device_h,
                                             .memoryTypeIndex = linear ? 1 : 0,
                                     },
                                     NULL /* XXX: pAllocator */,
+                                    RADV_MEM_IMPLICIT_SYNC,
                                     &memory_h);
        if (result != VK_SUCCESS)
                goto fail_create_image;
index bffb76bb331788e696af25821bc05cb1adcbd165..15099b318e75353ea37aab61364cfef3876d9ddb 100644 (file)
@@ -330,6 +330,8 @@ radv_amdgpu_winsys_bo_create(struct radeon_winsys *_ws,
                request.flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
        if (flags & RADEON_FLAG_GTT_WC)
                request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+       if (!(flags & RADEON_FLAG_IMPLICIT_SYNC) && ws->info.drm_minor >= 22)
+               request.flags |= AMDGPU_GEM_CREATE_EXPLICIT_SYNC;
 
        /* this won't do anything on pre 4.9 kernels */
        if (ws->zero_all_vram_allocs && (initial_domain & RADEON_DOMAIN_VRAM))