Module: Mesa
Branch: 17.1
Commit: 15bc6d4d210eee051407a816811012eba0a3be3b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=15bc6d4d210eee051407a816811012eba0a3be3b

Author: Jason Ekstrand <jason.ekstr...@intel.com>
Date:   Wed May 17 11:13:01 2017 -0700

anv: Determine the type of mapping based on type metadata

Before, we were just comparing the type index to 0.  Now we actually
look the type up in the table and check its properties to determine what
kind of mapping we want to do.

Reviewed-by: Nanley Chery <nanley.g.ch...@intel.com>
Cc: "17.1" <mesa-sta...@lists.freedesktop.org>
(cherry picked from commit 92325a7efc769c32e03031323e21700dc55171e4)
[Juan A. Suarez: resolve trivial conflicts]
Signed-off-by: Juan A. Suarez Romero <jasua...@igalia.com>

Conflicts:
        src/intel/vulkan/anv_device.c
        src/intel/vulkan/anv_private.h

---

 src/intel/vulkan/anv_device.c  | 12 ++++++------
 src/intel/vulkan/anv_private.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index d22da8be0b..0add7812ab 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1575,6 +1575,7 @@ VkResult anv_AllocateMemory(
     VkDeviceMemory*                             pMem)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
+   struct anv_physical_device *pdevice = &device->instance->physicalDevice;
    struct anv_device_memory *mem;
    VkResult result;
 
@@ -1583,10 +1584,6 @@ VkResult anv_AllocateMemory(
    /* The Vulkan 1.0.33 spec says "allocationSize must be greater than 0". */
    assert(pAllocateInfo->allocationSize > 0);
 
-   /* We support exactly one memory heap. */
-   assert(pAllocateInfo->memoryTypeIndex == 0 ||
-          (!device->info.has_llc && pAllocateInfo->memoryTypeIndex < 2));
-
    /* The kernel relocation API has a limitation of a 32-bit delta value
     * applied to the address before it is written which, in spite of it being
     * unsigned, is treated as signed .  Because of the way that this maps to
@@ -1621,7 +1618,8 @@ VkResult anv_AllocateMemory(
    if (result != VK_SUCCESS)
       goto fail;
 
-   mem->type_index = pAllocateInfo->memoryTypeIndex;
+   assert(pAllocateInfo->memoryTypeIndex < pdevice->memory.type_count);
+   mem->type = &pdevice->memory.types[pAllocateInfo->memoryTypeIndex];
 
    mem->map = NULL;
    mem->map_size = 0;
@@ -1695,7 +1693,9 @@ VkResult anv_MapMemory(
     * userspace. */
 
    uint32_t gem_flags = 0;
-   if (!device->info.has_llc && mem->type_index == 0)
+
+   if (!device->info.has_llc &&
+       (mem->type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
       gem_flags |= I915_MMAP_WC;
 
    /* GEM will fail to map if the offset isn't 4k-aligned.  Round down. */
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 599badedfd..21432b4c35 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -971,7 +971,7 @@ _anv_combine_address(struct anv_batch *batch, void 
*location,
 
 struct anv_device_memory {
    struct anv_bo                                bo;
-   uint32_t                                     type_index;
+   VkMemoryType *                               type;
    VkDeviceSize                                 map_size;
    void *                                       map;
 };

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to