Module: Mesa
Branch: main
Commit: 8f97af050e510b042701111d97f1267ba8765873
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f97af050e510b042701111d97f1267ba8765873

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Nov 17 16:47:16 2021 -0500

zink: set zink_resource_object::host_visible based on actual bo placement

the properties determined before allocation may not be the same as what gets
allocated

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13849>

---

 src/gallium/drivers/zink/zink_resource.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index a8cd4f5e058..818952268a1 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -647,11 +647,6 @@ resource_object_create(struct zink_screen *screen, const 
struct pipe_resource *t
       assert(reqs.memoryTypeBits & BITFIELD_BIT(mai.memoryTypeIndex));
    }
 
-   VkMemoryType mem_type = 
screen->info.mem_props.memoryTypes[mai.memoryTypeIndex];
-   obj->coherent = mem_type.propertyFlags & 
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
-   if (!(templ->flags & PIPE_RESOURCE_FLAG_SPARSE))
-      obj->host_visible = mem_type.propertyFlags & 
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
-
    VkMemoryDedicatedAllocateInfo ded_alloc_info = {
       .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
       .pNext = mai.pNext,
@@ -717,6 +712,11 @@ resource_object_create(struct zink_screen *screen, const 
struct pipe_resource *t
       obj->size = zink_bo_get_size(obj->bo);
    }
 
+   obj->coherent = obj->bo->base.placement & 
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
+   if (!(templ->flags & PIPE_RESOURCE_FLAG_SPARSE)) {
+      obj->host_visible = obj->bo->base.placement & 
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
+   }
+
    if (templ->target == PIPE_BUFFER) {
       if (!(templ->flags & PIPE_RESOURCE_FLAG_SPARSE))
          if (VKSCR(BindBufferMemory)(screen->dev, obj->buffer, 
zink_bo_get_mem(obj->bo), obj->offset) != VK_SUCCESS)

Reply via email to