radv: add support for using addrlib max alignment.
authorDave Airlie <airlied@redhat.com>
Sun, 9 Jul 2017 19:34:04 +0000 (20:34 +0100)
committerDave Airlie <airlied@redhat.com>
Sun, 9 Jul 2017 21:17:59 +0000 (22:17 +0100)
Rather than using 64k, use what addrlib returns as the base
alignment for vulkan allocations.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_gpu_info.h
src/amd/common/ac_surface.c
src/amd/common/ac_surface.h
src/amd/vulkan/radv_device.c
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c

index 3091fed6a434fa34c05133721a579e0b6ebd0645..72a850624668db5f2f71eef4495d65ca53ed48bf 100644 (file)
@@ -95,6 +95,7 @@ struct radeon_info {
        uint32_t                    pipe_interleave_bytes;
        uint32_t                    enabled_rb_mask; /* GCN harvest config */
 
+       uint64_t                    max_alignment; /* from addrlib */
        /* Tile modes. */
        uint32_t                    si_tile_mode_array[32];
        uint32_t                    cik_macrotile_mode_array[16];
index 877d592ab81862f098b3e8178e9cc3229703a9b0..a4df595653b4e63322ca8863dad1230b0c77379b 100644 (file)
@@ -150,12 +150,14 @@ static ADDR_E_RETURNCODE ADDR_API freeSysMem(const ADDR_FREESYSMEM_INPUT * pInpu
 }
 
 ADDR_HANDLE amdgpu_addr_create(const struct radeon_info *info,
-                              const struct amdgpu_gpu_info *amdinfo)
+                              const struct amdgpu_gpu_info *amdinfo,
+                              uint64_t *max_alignment)
 {
        ADDR_CREATE_INPUT addrCreateInput = {0};
        ADDR_CREATE_OUTPUT addrCreateOutput = {0};
        ADDR_REGISTER_VALUE regValue = {0};
        ADDR_CREATE_FLAGS createFlags = {{0}};
+       ADDR_GET_MAX_ALINGMENTS_OUTPUT addrGetMaxAlignmentsOutput = {0};
        ADDR_E_RETURNCODE addrRet;
 
        addrCreateInput.size = sizeof(ADDR_CREATE_INPUT);
@@ -202,6 +204,12 @@ ADDR_HANDLE amdgpu_addr_create(const struct radeon_info *info,
        if (addrRet != ADDR_OK)
                return NULL;
 
+       if (max_alignment) {
+               addrRet = AddrGetMaxAlignments(addrCreateOutput.hLib, &addrGetMaxAlignmentsOutput);
+               if (addrRet == ADDR_OK){
+                       *max_alignment = addrGetMaxAlignmentsOutput.baseAlign;
+               }
+       }
        return addrCreateOutput.hLib;
 }
 
index 582a67193f8f79d50a0aed0e3cb45825c0510e2a..4d893ff5009e372b8525eb321b68a836b0dd4321 100644 (file)
@@ -206,7 +206,8 @@ struct ac_surf_config {
 };
 
 ADDR_HANDLE amdgpu_addr_create(const struct radeon_info *info,
-                              const struct amdgpu_gpu_info *amdinfo);
+                              const struct amdgpu_gpu_info *amdinfo,
+                              uint64_t *max_alignment);
 
 int ac_compute_surface(ADDR_HANDLE addrlib, const struct radeon_info *info,
                       const struct ac_surf_config * config,
index d1c519a1b7afce07cd3458b097daaefbb48985c3..c31a687cbd25d4418afd5331bfd54809a4d0d59d 100644 (file)
@@ -2134,7 +2134,7 @@ VkResult radv_AllocateMemory(
        if (pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_WRITE_COMBINE)
                flags |= RADEON_FLAG_GTT_WC;
 
-       mem->bo = device->ws->buffer_create(device->ws, alloc_size, 65536,
+       mem->bo = device->ws->buffer_create(device->ws, alloc_size, device->physical_device->rad_info.max_alignment,
                                               domain, flags);
 
        if (!mem->bo) {
index c7688cf4c9bda5aeb8d5942ac06bfa6b02017859..2503489588340c5f29ca756f7133ebd86e864a9b 100644 (file)
@@ -53,7 +53,7 @@ do_winsys_init(struct radv_amdgpu_winsys *ws, int fd)
                return false;
        }
 
-       ws->addrlib = amdgpu_addr_create(&ws->info, &ws->amdinfo);
+       ws->addrlib = amdgpu_addr_create(&ws->info, &ws->amdinfo, &ws->info.max_alignment);
        if (!ws->addrlib) {
                fprintf(stderr, "amdgpu: Cannot create addrlib.\n");
                return false;
index ef7b04aa5fe82179d59696a7b90c14f120c911a0..30f4dfb769d7b9f780cb3561ca261daf3152fe6c 100644 (file)
@@ -63,7 +63,7 @@ static bool do_winsys_init(struct amdgpu_winsys *ws, int fd)
       goto fail;
    }
 
-   ws->addrlib = amdgpu_addr_create(&ws->info, &ws->amdinfo);
+   ws->addrlib = amdgpu_addr_create(&ws->info, &ws->amdinfo, NULL);
    if (!ws->addrlib) {
       fprintf(stderr, "amdgpu: Cannot create addrlib.\n");
       goto fail;