Module: Mesa
Branch: staging/23.3
Commit: 62161b7425492962e2b0f880b16f915d96e785f0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=62161b7425492962e2b0f880b16f915d96e785f0

Author: Alessandro Astone <ales.ast...@gmail.com>
Date:   Wed Jan 10 17:24:30 2024 +0100

zink: Fix resizable BAR detection logic

This was broken in two ways:
* When looking for the MAX biggest_ram it was actually comparing
  a candidate against biggest_vis_ram

* mem_props.memoryTypes[] should be accessed with the memory type
  index as found in heap_map

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10341
Cc: 23.3 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26979>
(cherry picked from commit a077c14f150f1c4f670dce381ac2eb548f1a4ac2)

---

 .pick_status.json                      | 2 +-
 src/gallium/drivers/zink/zink_screen.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 63d32d99729..a1d677d2073 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1324,7 +1324,7 @@
         "description": "zink: Fix resizable BAR detection logic",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
diff --git a/src/gallium/drivers/zink/zink_screen.c 
b/src/gallium/drivers/zink/zink_screen.c
index cccc901df8f..b7f0b2557b2 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -3256,10 +3256,10 @@ zink_internal_create_screen(const struct 
pipe_screen_config *config, int64_t dev
    {
       uint64_t biggest_vis_vram = 0;
       for (unsigned i = 0; i < 
screen->heap_count[ZINK_HEAP_DEVICE_LOCAL_VISIBLE]; i++)
-         biggest_vis_vram = MAX2(biggest_vis_vram, 
screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[i].heapIndex].size);
+         biggest_vis_vram = MAX2(biggest_vis_vram, 
screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[screen->heap_map[ZINK_HEAP_DEVICE_LOCAL_VISIBLE][i]].heapIndex].size);
       uint64_t biggest_vram = 0;
       for (unsigned i = 0; i < screen->heap_count[ZINK_HEAP_DEVICE_LOCAL]; i++)
-         biggest_vram = MAX2(biggest_vis_vram, 
screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[i].heapIndex].size);
+         biggest_vram = MAX2(biggest_vram, 
screen->info.mem_props.memoryHeaps[screen->info.mem_props.memoryTypes[screen->heap_map[ZINK_HEAP_DEVICE_LOCAL][i]].heapIndex].size);
       /* determine if vis vram is roughly equal to total vram */
       if (biggest_vis_vram > biggest_vram * 0.9)
          screen->resizable_bar = true;

Reply via email to