From f95134468aba58b4cb9a28bcafb0c3098913124c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 25 Aug 2023 12:54:19 -0400 Subject: [PATCH] zink: move mem type detection up in file no functional changes Part-of: --- src/gallium/drivers/zink/zink_screen.c | 74 +++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 935bf17da29..c49254d46cc 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -3098,6 +3098,43 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev goto fail; } + memset(&screen->heap_map, UINT8_MAX, sizeof(screen->heap_map)); + for (enum zink_heap i = 0; i < ZINK_HEAP_MAX; i++) { + for (unsigned j = 0; j < screen->info.mem_props.memoryTypeCount; j++) { + VkMemoryPropertyFlags domains = vk_domain_from_heap(i); + if ((screen->info.mem_props.memoryTypes[j].propertyFlags & domains) == domains) { + screen->heap_map[i][screen->heap_count[i]++] = j; + } + } + } + /* iterate again to check for missing heaps */ + for (enum zink_heap i = 0; i < ZINK_HEAP_MAX; i++) { + /* not found: use compatible heap */ + if (screen->heap_map[i][0] == UINT8_MAX) { + /* only cached mem has a failure case for now */ + assert(i == ZINK_HEAP_HOST_VISIBLE_COHERENT_CACHED || i == ZINK_HEAP_DEVICE_LOCAL_LAZY || + i == ZINK_HEAP_DEVICE_LOCAL_VISIBLE); + if (i == ZINK_HEAP_HOST_VISIBLE_COHERENT_CACHED) { + memcpy(screen->heap_map[i], screen->heap_map[ZINK_HEAP_HOST_VISIBLE_COHERENT], screen->heap_count[ZINK_HEAP_HOST_VISIBLE_COHERENT]); + screen->heap_count[i] = screen->heap_count[ZINK_HEAP_HOST_VISIBLE_COHERENT]; + } else { + memcpy(screen->heap_map[i], screen->heap_map[ZINK_HEAP_DEVICE_LOCAL], screen->heap_count[ZINK_HEAP_DEVICE_LOCAL]); + screen->heap_count[i] = screen->heap_count[ZINK_HEAP_DEVICE_LOCAL]; + } + } + } + { + 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); + 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); + /* determine if vis vram is roughly equal to total vram */ + if (biggest_vis_vram > biggest_vram * 0.9) + screen->resizable_bar = true; + } + setup_renderdoc(screen); if (screen->threaded_submit && !util_queue_init(&screen->flush_queue, "zfq", 8, 1, UTIL_QUEUE_INIT_RESIZE_IF_FULL, screen)) { mesa_loge("zink: Failed to create flush queue.\n"); @@ -3261,43 +3298,6 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev goto fail; } - memset(&screen->heap_map, UINT8_MAX, sizeof(screen->heap_map)); - for (enum zink_heap i = 0; i < ZINK_HEAP_MAX; i++) { - for (unsigned j = 0; j < screen->info.mem_props.memoryTypeCount; j++) { - VkMemoryPropertyFlags domains = vk_domain_from_heap(i); - if ((screen->info.mem_props.memoryTypes[j].propertyFlags & domains) == domains) { - screen->heap_map[i][screen->heap_count[i]++] = j; - } - } - } - /* iterate again to check for missing heaps */ - for (enum zink_heap i = 0; i < ZINK_HEAP_MAX; i++) { - /* not found: use compatible heap */ - if (screen->heap_map[i][0] == UINT8_MAX) { - /* only cached mem has a failure case for now */ - assert(i == ZINK_HEAP_HOST_VISIBLE_COHERENT_CACHED || i == ZINK_HEAP_DEVICE_LOCAL_LAZY || - i == ZINK_HEAP_DEVICE_LOCAL_VISIBLE); - if (i == ZINK_HEAP_HOST_VISIBLE_COHERENT_CACHED) { - memcpy(screen->heap_map[i], screen->heap_map[ZINK_HEAP_HOST_VISIBLE_COHERENT], screen->heap_count[ZINK_HEAP_HOST_VISIBLE_COHERENT]); - screen->heap_count[i] = screen->heap_count[ZINK_HEAP_HOST_VISIBLE_COHERENT]; - } else { - memcpy(screen->heap_map[i], screen->heap_map[ZINK_HEAP_DEVICE_LOCAL], screen->heap_count[ZINK_HEAP_DEVICE_LOCAL]); - screen->heap_count[i] = screen->heap_count[ZINK_HEAP_DEVICE_LOCAL]; - } - } - } - { - 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); - 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); - /* determine if vis vram is roughly equal to total vram */ - if (biggest_vis_vram > biggest_vram * 0.9) - screen->resizable_bar = true; - } - bool can_db = true; { if (!screen->info.have_EXT_descriptor_buffer) {