vk/0.130: Update vkAllocMemory to use VkMemoryType
authorChad Versace <chad.versace@intel.com>
Fri, 10 Jul 2015 02:59:44 +0000 (19:59 -0700)
committerChad Versace <chad.versace@intel.com>
Sat, 11 Jul 2015 00:35:52 +0000 (17:35 -0700)
include/vulkan/vulkan.h
src/vulkan/device.c
src/vulkan/x11.c

index 72eef2ade08835e73c5e48b3e11943e95f855e30..805e03680e73189e4a715f6ac4fe139fe88577fe 100644 (file)
@@ -1319,7 +1319,7 @@ typedef struct {
     VkStructureType                             sType;
     const void*                                 pNext;
     VkDeviceSize                                allocationSize;
-    VkMemoryPropertyFlags                       memProps;
+    uint32_t                                    memoryTypeIndex;
 } VkMemoryAllocInfo;
 
 typedef struct {
@@ -1334,8 +1334,7 @@ typedef struct {
     VkDeviceSize                                size;
     VkDeviceSize                                alignment;
     VkDeviceSize                                granularity;
-    VkMemoryPropertyFlags                       memPropsAllowed;
-    VkMemoryPropertyFlags                       memPropsRequired;
+    uint32_t                                    memoryTypeBits;
 } VkMemoryRequirements;
 
 typedef struct {
index 15cdc1dca832bc3ae892d0b0dcb6e83100a927fa..43202a0867ffe0d6b86b543ab548621c8794183b 100644 (file)
@@ -1077,6 +1077,13 @@ VkResult anv_AllocMemory(
 
    assert(pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO);
 
+   if (pAllocInfo->memoryTypeIndex != 0) {
+      /* We support exactly one memory heap. */
+      return vk_error(VK_ERROR_INVALID_VALUE);
+   }
+
+   /* FINISHME: Fail if allocation request exceeds heap size. */
+
    mem = anv_device_alloc(device, sizeof(*mem), 8,
                           VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
    if (mem == NULL)
@@ -1254,13 +1261,17 @@ VkResult anv_GetObjectMemoryRequirements(
     VkObject                                    object,
     VkMemoryRequirements*                       pMemoryRequirements)
 {
-   pMemoryRequirements->memPropsAllowed =
-      VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
-      /* VK_MEMORY_PROPERTY_HOST_NON_COHERENT_BIT | */
-      /* VK_MEMORY_PROPERTY_HOST_UNCACHED_BIT | */
-      VK_MEMORY_PROPERTY_HOST_WRITE_COMBINED_BIT;
 
-   pMemoryRequirements->memPropsRequired = 0;
+   /* The Vulkan spec (git aaed022) says:
+    *
+    *    memoryTypeBits is a bitfield and contains one bit set for every
+    *    supported memory type for the resource. The bit `1<<i` is set if and
+    *    only if the memory type `i` in the VkPhysicalDeviceMemoryProperties
+    *    structure for the physical device is supported.
+    *
+    * We support exactly one memory type.
+    */
+   pMemoryRequirements->memoryTypeBits = 1;
 
    switch (objType) {
    case VK_OBJECT_TYPE_BUFFER: {
index ee9cdcdd51c0b4d164d089562fbf8a8dbc4309a2..7b6cee011a4e77dae66efd972b621632a0109727 100644 (file)
@@ -144,6 +144,7 @@ VkResult anv_CreateSwapChainWSI(
                       &(VkMemoryAllocInfo) {
                          .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO,
                          .allocationSize = image->size,
+                         .memoryTypeIndex = 0,
                       },
                       (VkDeviceMemory *) &memory);