OSDN Git Service

radv: Use enum for memory heaps.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 8 Dec 2016 21:28:21 +0000 (22:28 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 9 Dec 2016 07:53:05 +0000 (08:53 +0100)
Inspired by patches from Eric Engestrom.

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Cc: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index 0defc0f..7a253f6 100644 (file)
@@ -578,37 +578,39 @@ void radv_GetPhysicalDeviceMemoryProperties(
        pMemoryProperties->memoryTypeCount = 4;
        pMemoryProperties->memoryTypes[0] = (VkMemoryType) {
                .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-               .heapIndex = 0,
+               .heapIndex = RADV_MEM_HEAP_VRAM,
        };
        pMemoryProperties->memoryTypes[1] = (VkMemoryType) {
                .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
                VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-               .heapIndex = 2,
+               .heapIndex = RADV_MEM_HEAP_GTT,
        };
        pMemoryProperties->memoryTypes[2] = (VkMemoryType) {
                .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
                VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
                VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-               .heapIndex = 1,
+               .heapIndex = RADV_MEM_HEAP_VRAM_CPU_ACCESS,
        };
        pMemoryProperties->memoryTypes[3] = (VkMemoryType) {
                .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
                VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
                VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
-               .heapIndex = 2,
+               .heapIndex = RADV_MEM_HEAP_GTT,
        };
 
-       pMemoryProperties->memoryHeapCount = 3;
-       pMemoryProperties->memoryHeaps[0] = (VkMemoryHeap) {
+       STATIC_ASSERT(RADV_MEM_HEAP_COUNT <= VK_MAX_MEMORY_HEAPS);
+
+       pMemoryProperties->memoryHeapCount = RADV_MEM_HEAP_COUNT;
+       pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM] = (VkMemoryHeap) {
                .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) {
+       pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_VRAM_CPU_ACCESS] = (VkMemoryHeap) {
                .size = physical_device->rad_info.visible_vram_size,
                .flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT,
        };
-       pMemoryProperties->memoryHeaps[2] = (VkMemoryHeap) {
+       pMemoryProperties->memoryHeaps[RADV_MEM_HEAP_GTT] = (VkMemoryHeap) {
                .size = physical_device->rad_info.gart_size,
                .flags = 0,
        };
index 754cd00..f2b6bf4 100644 (file)
@@ -85,6 +85,13 @@ typedef uint32_t xcb_window_t;
 
 #define NUM_DEPTH_CLEAR_PIPELINES 3
 
+enum radv_mem_heap {
+       RADV_MEM_HEAP_VRAM,
+       RADV_MEM_HEAP_VRAM_CPU_ACCESS,
+       RADV_MEM_HEAP_GTT,
+       RADV_MEM_HEAP_COUNT
+};
+
 #define radv_noreturn __attribute__((__noreturn__))
 #define radv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))