Disable implicit sync for non-wsi bos
cover Disable implicit sync for non-wsi bos
This is a reference patch series for the kernel series:
"drm/amdgpu: introduce AMDGPU_GEM_CREATE_EXPLICIT_SYNC v2"
Andres Rodriguez (2):
radv: factor out radv_alloc_memory
radv: disable implicit sync for radv allocated bos v2
src/amd/vulkan/radv_device.c | 22 +++++++++++++++++----- src/amd/vulkan/radv_private.h | 11 +++++++++++ src/amd/vulkan/radv_radeon_winsys.h | 1 + src/amd/vulkan/radv_wsi.c | 3 ++- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c | 2 ++ 5 files changed, 33 insertions(+), 6 deletions(-)
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170919154912.29916-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/2 radv: factor out radv_alloc_memory
This allows us to pass extra parameters to the memory allocation operation that are not defined in the vulkan spec. This is useful for internal usage.
--- src/amd/vulkan/radv_device.c | 19 ++++++++++++++----- src/amd/vulkan/radv_private.h | 11 +++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-)
src/amd/vulkan/radv_device.c +14 -5
@@ -2242,11 +2242,11 @@ bool radv_get_memory_fd(struct radv_device *device, pFD); } -VkResult radv_AllocateMemory ( -VkDevice _device, -const VkMemoryAllocateInfo * pAllocateInfo, -const VkAllocationCallbacks * pAllocator, -VkDeviceMemory * pMem) +VkResult radv_alloc_memory (VkDevice _device, +const VkMemoryAllocateInfo * pAllocateInfo, +const VkAllocationCallbacks * pAllocator, +enum radv_mem_flags_bits mem_flags, +VkDeviceMemory * pMem) {RADV_FROM_HANDLE (radv_device, device, _device);struct radv_device_memory *mem;
@@ -2328,6 +2328,15 @@ fail:return result; } +VkResult radv_AllocateMemory ( +VkDevice _device, +const VkMemoryAllocateInfo * pAllocateInfo, +const VkAllocationCallbacks * pAllocator, +VkDeviceMemory * pMem) +{ +return radv_alloc_memory (_device, pAllocateInfo, pAllocator,0 , pMem); +} + void radv_FreeMemory( VkDevice _device, VkDeviceMemory _mem,
src/amd/vulkan/radv_private.h +11 -0
@@ -105,6 +105,11 @@ enum radv_mem_type {RADV_MEM_TYPE_COUNT }; +enum radv_mem_flags_bits { +/* enable implicit synchronization when accessing the underlying bo */ +RADV_MEM_IMPLICIT_SYNC =1 <<0 , +}; +#define radv_printflike (a, b) __attribute__((__format__(__printf__, a, b))) static inline uint32_t
@@ -935,6 +940,12 @@ void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer *cmd_buffer);bool radv_get_memory_fd (struct radv_device *device,struct radv_device_memory *memory,int *pFD); +VkResult radv_alloc_memory (VkDevice _device, +const VkMemoryAllocateInfo * pAllocateInfo, +const VkAllocationCallbacks * pAllocator, +enum radv_mem_flags_bits flags, +VkDeviceMemory * pMem); +/* * Takes x,y,z as exact numbers of invocations, instead of blocks. *
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 radv: disable implicit sync for radv allocated bos v2
In reply to a message not in the archiveImplicit 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
--- src/amd/vulkan/radv_device.c | 3 +++ src/amd/vulkan/radv_radeon_winsys.h | 1 + src/amd/vulkan/radv_wsi.c | 3 ++- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)
src/amd/vulkan/radv_device.c +3 -0
@@ -2309,6 +2309,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);
src/amd/vulkan/radv_radeon_winsys.h +1 -0
@@ -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 */
src/amd/vulkan/radv_wsi.c +2 -1
@@ -193,7 +193,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,
@@ -201,6 +201,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;
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c +2 -0
@@ -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 )) + request.flags |=AMDGPU_GEM_CREATE_EXPLICIT_SYNC ; r =amdgpu_bo_alloc (ws->dev, &request, &buf_handle);if (r) {
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx