zink: determine whether the gpu has a resizable BAR at startup
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 30 Jul 2021 13:18:54 +0000 (09:18 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 30 Aug 2021 13:46:04 +0000 (13:46 +0000)
this can be used to make different allocation and mapping decisions

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12579>

src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_screen.h

index 3df9edf..915673a 100644 (file)
@@ -1907,6 +1907,14 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
          screen->heap_map[i] = screen->heap_map[ZINK_HEAP_HOST_VISIBLE_ANY];
       }
    }
+   {
+      unsigned vis_vram = screen->heap_map[ZINK_HEAP_DEVICE_LOCAL_VISIBLE];
+      unsigned vram = screen->heap_map[ZINK_HEAP_DEVICE_LOCAL];
+      /* determine if vis vram is roughly equal to total vram */
+      if (screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[vis_vram].heapIndex].size >
+          screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[vram].heapIndex].size * 0.9)
+         screen->resizable_bar = true;
+   }
 
    simple_mtx_init(&screen->surface_mtx, mtx_plain);
    simple_mtx_init(&screen->bufferview_mtx, mtx_plain);
index feeb80c..4f7a220 100644 (file)
@@ -109,6 +109,7 @@ struct zink_screen {
       uint32_t next_bo_unique_id;
    } pb;
    uint8_t heap_map[VK_MAX_MEMORY_TYPES];
+   bool resizable_bar;
 
    uint64_t total_video_mem;
    uint64_t clamp_video_mem;