[Mesa-dev] [PATCH] radv: add support for using addrlib max alignment.

Dave Airlie airlied at gmail.com
Sun Jul 9 19:41:20 UTC 2017


From: Dave Airlie <airlied at redhat.com>

Rather than using 64k, use what addrlib returns as the base
alignment for vulkan allocations.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/amd/common/ac_gpu_info.h                      |  1 +
 src/amd/common/ac_surface.c                       | 11 ++++++++++-
 src/amd/common/ac_surface.h                       |  3 ++-
 src/amd/vulkan/radv_device.c                      |  2 +-
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c |  2 +-
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c     |  2 +-
 6 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_gpu_info.h b/src/amd/common/ac_gpu_info.h
index 3091fed..72a8506 100644
--- a/src/amd/common/ac_gpu_info.h
+++ b/src/amd/common/ac_gpu_info.h
@@ -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];
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index c936426..370dc7d 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -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_ALIGNMENTS_OUTPUT addrGetMaxAlignmentsOutput = {0};
 	ADDR_E_RETURNCODE addrRet;
 
 	addrCreateInput.size = sizeof(ADDR_CREATE_INPUT);
@@ -202,6 +204,13 @@ 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;
+			fprintf(stderr, "max alignment is %d\n", *max_alignment);
+		}
+	}
 	return addrCreateOutput.hLib;
 }
 
diff --git a/src/amd/common/ac_surface.h b/src/amd/common/ac_surface.h
index ecba4c8..7901b86 100644
--- a/src/amd/common/ac_surface.h
+++ b/src/amd/common/ac_surface.h
@@ -208,7 +208,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,
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 0cf0d57..663f82c 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2138,7 +2138,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) {
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
index c7688cf..2503489 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
@@ -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;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index ef7b04a..30f4dfb 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -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;
-- 
2.9.4



More information about the mesa-dev mailing list