zink: sum available memory heaps instead of assigning
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 4 Aug 2021 15:44:28 +0000 (11:44 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 4 Aug 2021 18:07:58 +0000 (14:07 -0400)
this is supposed to accumulate now

Fixes: 73f6bff07f1 ("zink: fix mem info query to be more permissive")

Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12199>

src/gallium/drivers/zink/zink_screen.c

index f077dca..8a86828 100644 (file)
@@ -1650,12 +1650,12 @@ zink_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *inf
       for (unsigned i = 0; i < mem.memoryProperties.memoryHeapCount; i++) {
          if (mem.memoryProperties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
             /* VRAM */
-            info->total_device_memory = mem.memoryProperties.memoryHeaps[i].size / 1024;
-            info->avail_device_memory = (budget.heapBudget[i] - budget.heapUsage[i]) / 1024;
+            info->total_device_memory += mem.memoryProperties.memoryHeaps[i].size / 1024;
+            info->avail_device_memory += (budget.heapBudget[i] - budget.heapUsage[i]) / 1024;
          } else if (mem.memoryProperties.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
             /* GART */
-            info->total_staging_memory = mem.memoryProperties.memoryHeaps[i].size / 1024;
-            info->avail_staging_memory = (budget.heapBudget[i] - budget.heapUsage[i]) / 1024;
+            info->total_staging_memory += mem.memoryProperties.memoryHeaps[i].size / 1024;
+            info->avail_staging_memory += (budget.heapBudget[i] - budget.heapUsage[i]) / 1024;
          }
       }
       /* evictions not yet supported in vulkan */
@@ -1663,14 +1663,14 @@ zink_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *inf
       for (unsigned i = 0; i < screen->info.mem_props.memoryHeapCount; i++) {
          if (screen->info.mem_props.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
             /* VRAM */
-            info->total_device_memory = screen->info.mem_props.memoryHeaps[i].size / 1024;
+            info->total_device_memory += screen->info.mem_props.memoryHeaps[i].size / 1024;
             /* free real estate! */
-            info->avail_device_memory = info->total_device_memory;
+            info->avail_device_memory += info->total_device_memory;
          } else if (screen->info.mem_props.memoryHeaps[i].flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
             /* GART */
-            info->total_staging_memory = screen->info.mem_props.memoryHeaps[i].size / 1024;
+            info->total_staging_memory += screen->info.mem_props.memoryHeaps[i].size / 1024;
             /* free real estate! */
-            info->avail_staging_memory = info->total_staging_memory;
+            info->avail_staging_memory += info->total_staging_memory;
          }
       }
    }