From 95d06343c693aa12b4cda5cda31d81fae138b0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Tue, 10 Jan 2023 20:34:27 +0100 Subject: [PATCH] radv: Don't place CS in VRAM when bandwidth is too low. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit People who use RADV on eGPU have reported poor performance by default. They also noted that the "nosam" option helps. This commit disables placing CS objects in VRAM when the bandwidth is below that of PCIe 3.0 x8. Note that eGPUs are typically PCIe 3.0 x4. Contributes-to: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7340 Signed-off-by: Timur Kristóf Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c index b24cf814cec..38007160bc8 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c @@ -217,8 +217,14 @@ radv_amdgpu_cs_domain(const struct radeon_winsys *_ws) bool enough_vram = ws->info.all_vram_visible || p_atomic_read_relaxed(&ws->allocated_vram_vis) * 2 <= (uint64_t)ws->info.vram_vis_size_kb * 1024; + + /* Bandwidth should be equivalent to at least PCIe 3.0 x8. + * If there is no PCIe info, assume there is enough bandwidth. + */ + bool enough_bandwidth = !ws->info.has_pcie_bandwidth_info || ws->info.pcie_bandwidth_mbps >= 8 * 0.985 * 1024; + bool use_sam = - (enough_vram && ws->info.has_dedicated_vram && !(ws->perftest & RADV_PERFTEST_NO_SAM)) || + (enough_vram && enough_bandwidth && ws->info.has_dedicated_vram && !(ws->perftest & RADV_PERFTEST_NO_SAM)) || (ws->perftest & RADV_PERFTEST_SAM); return use_sam ? RADEON_DOMAIN_VRAM : RADEON_DOMAIN_GTT; }