Mesa (master): radv: split the device local memory heap into two

Dave Airlie airlied at kemper.freedesktop.org
Fri Oct 28 02:29:00 UTC 2016


Module: Mesa
Branch: master
Commit: 044ef54d65e5f64126755503eefa411b1bdb8816
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=044ef54d65e5f64126755503eefa411b1bdb8816

Author: Fredrik Höglund <fredrik at kde.org>
Date:   Thu Oct 27 02:49:59 2016 +0200

radv: split the device local memory heap into two

Advertise two device local memory heaps; one that is host visible
and one that is not.

This makes it possible for clients to tell how much host visible
vs. non-host visible memory is available.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_device.c                      | 15 ++++++++++-----
 src/amd/vulkan/radv_radeon_winsys.h               |  1 +
 src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c | 10 +++++++++-
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 86505f4..512d366 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -530,27 +530,32 @@ void radv_GetPhysicalDeviceMemoryProperties(
 	pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
 		.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-		.heapIndex = 1,
+		.heapIndex = 2,
 	};
 	pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
 		.propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-		.heapIndex = 0,
+		.heapIndex = 1,
 	};
 	pMemoryProperties->memoryTypes[3] = (VkMemoryType) {
 		.propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 		VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
 		VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-		.heapIndex = 1,
+		.heapIndex = 2,
 	};
 
-	pMemoryProperties->memoryHeapCount = 2;
+	pMemoryProperties->memoryHeapCount = 3;
 	pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) {
-		.size = physical_device->rad_info.vram_size,
+		.size = physical_device->rad_info.vram_size -
+				physical_device->rad_info.visible_vram_size,
 		.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
 	};
 	pMemoryProperties->memoryHeaps[1] = (VkMemoryHeap) {
+		.size = physical_device->rad_info.visible_vram_size,
+		.flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
+	};
+	pMemoryProperties->memoryHeaps[2] = (VkMemoryHeap) {
 		.size = physical_device->rad_info.gart_size,
 		.flags = 0,
 	};
diff --git a/src/amd/vulkan/radv_radeon_winsys.h b/src/amd/vulkan/radv_radeon_winsys.h
index 6370f3d..76363a3 100644
--- a/src/amd/vulkan/radv_radeon_winsys.h
+++ b/src/amd/vulkan/radv_radeon_winsys.h
@@ -85,6 +85,7 @@ struct radeon_info {
 	uint32_t                    gart_page_size;
 	uint64_t                    gart_size;
 	uint64_t                    vram_size;
+	uint64_t                    visible_vram_size;
 	bool                        has_dedicated_vram;
 	bool                     has_virtual_memory;
 	bool                        gfx_ib_pad_with_type2;
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
index 0456100..b2e171a 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
@@ -116,7 +116,7 @@ static bool
 do_winsys_init(struct radv_amdgpu_winsys *ws, int fd)
 {
 	struct amdgpu_buffer_size_alignments alignment_info = {};
-	struct amdgpu_heap_info vram, gtt;
+	struct amdgpu_heap_info vram, visible_vram, gtt;
 	struct drm_amdgpu_info_hw_ip dma = {};
 	drmDevicePtr devinfo;
 	int r;
@@ -152,6 +152,13 @@ do_winsys_init(struct radv_amdgpu_winsys *ws, int fd)
 		goto fail;
 	}
 
+	r = amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM,
+	                           AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, &visible_vram);
+	if (r) {
+		fprintf(stderr, "amdgpu: amdgpu_query_heap_info(visible_vram) failed.\n");
+		goto fail;
+	}
+
 	r = amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_GTT, 0, &gtt);
 	if (r) {
 		fprintf(stderr, "amdgpu: amdgpu_query_heap_info(gtt) failed.\n");
@@ -270,6 +277,7 @@ do_winsys_init(struct radv_amdgpu_winsys *ws, int fd)
 	ws->info.name = get_chip_name(ws->info.family);
 	ws->info.gart_size = gtt.heap_size;
 	ws->info.vram_size = vram.heap_size;
+	ws->info.visible_vram_size = visible_vram.heap_size;
 	/* convert the shader clock from KHz to MHz */
 	ws->info.max_shader_clock = ws->amdinfo.max_engine_clk / 1000;
 	ws->info.max_se = ws->amdinfo.num_shader_engines;




More information about the mesa-commit mailing list