zink: only report device-local memory as video-memory
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 9 Jun 2020 19:54:23 +0000 (21:54 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 10 Jun 2020 08:58:09 +0000 (08:58 +0000)
While the definition of "video memory" isn't super clear, I think it's
pretty reasonable to assume host-memory isn't meant to be included. So
let's only count dedicated memory here.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3107
Reviewed-by: Witold Baryluk <witold.baryluk@gmail.com>
Tested-by: Witold Baryluk <witold.baryluk@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5409>

src/gallium/drivers/zink/zink_screen.c

index 6ec29da2fe0b3def64bd3d11f5122c13c7474bc1..5cb02587526d1441241360f1eb06ab057e6f9c3e 100644 (file)
@@ -80,8 +80,11 @@ static int
 get_video_mem(struct zink_screen *screen)
 {
    VkDeviceSize size = 0;
-   for (uint32_t i = 0; i < screen->mem_props.memoryHeapCount; ++i)
-      size += screen->mem_props.memoryHeaps[i].size;
+   for (uint32_t i = 0; i < screen->mem_props.memoryHeapCount; ++i) {
+      if (screen->mem_props.memoryHeaps[i].flags &
+          VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
+         size += screen->mem_props.memoryHeaps[i].size;
+   }
    return (int)(size >> 20);
 }