From f5cb1eed26ff809e732400c69c09d9dae4a34dee Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 16 Feb 2024 16:02:38 -0600 Subject: [PATCH] nvk: Upload shaders on the CPU when we have ReBAR Without without resizable BAR, we're limited as to how much VRAM we can map and we sometimes run out of maps for games with large numbers of shaders. We keep using the DMA engine fallback in that case. Part-of: --- src/nouveau/vulkan/nvk_device.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/nouveau/vulkan/nvk_device.c b/src/nouveau/vulkan/nvk_device.c index dbe891ff5ea..f2c266e89f3 100644 --- a/src/nouveau/vulkan/nvk_device.c +++ b/src/nouveau/vulkan/nvk_device.c @@ -191,12 +191,18 @@ nvk_CreateDevice(VkPhysicalDevice physicalDevice, if (result != VK_SUCCESS) goto fail_images; - /* The I-cache pre-fetches and we don't really know by how much. Over- - * allocate shader BOs by 4K to ensure we don't run past. + /* If we have a full BAR, go ahead and do shader uploads on the CPU. + * Otherwise, we fall back to doing shader uploads via the upload queue. + * + * Also, the I-cache pre-fetches and we don't really know by how much. + * Over-allocating shader BOs by 4K ensures we don't run past. */ + enum nouveau_ws_bo_map_flags shader_map_flags = 0; + if (pdev->info.bar_size_B >= pdev->info.vram_size_B) + shader_map_flags = NOUVEAU_WS_BO_WR; result = nvk_heap_init(dev, &dev->shader_heap, NOUVEAU_WS_BO_LOCAL | NOUVEAU_WS_BO_NO_SHARE, - 0 /* map_flags */, + shader_map_flags, 4096 /* overalloc */, dev->pdev->info.cls_eng3d < VOLTA_A); if (result != VK_SUCCESS)