Mesa (main): radv/amdgpu: make sure to reset the number of BO when there is no ranges
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 20 07:07:30 UTC 2022
Module: Mesa
Branch: main
Commit: b4cc10b3427bdf1f172094f991c38c6ec94bbc19
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4cc10b3427bdf1f172094f991c38c6ec94bbc19
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Fri Jun 17 09:10:00 2022 +0200
radv/amdgpu: make sure to reset the number of BO when there is no ranges
If an application binds a sparse resource and then unbind it with NULL,
the number of "real" BOs in the virtual BO list should be reset to 0.
Otherwise, it might use a dangling BO reference if it's destroyed just
after being unbound.
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17085>
---
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
index c29dd153494..1c3b466a910 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
@@ -93,12 +93,16 @@ radv_amdgpu_winsys_rebuild_bo_list(struct radv_amdgpu_winsys_bo *bo)
qsort(bo->bos, temp_bo_count, sizeof(struct radv_amdgpu_winsys_bo *), &bo_comparator);
- uint32_t final_bo_count = 1;
- for (uint32_t i = 1; i < temp_bo_count; ++i)
- if (bo->bos[i] != bo->bos[i - 1])
- bo->bos[final_bo_count++] = bo->bos[i];
+ if (!temp_bo_count) {
+ bo->bo_count = 0;
+ } else {
+ uint32_t final_bo_count = 1;
+ for (uint32_t i = 1; i < temp_bo_count; ++i)
+ if (bo->bos[i] != bo->bos[i - 1])
+ bo->bos[final_bo_count++] = bo->bos[i];
- bo->bo_count = final_bo_count;
+ bo->bo_count = final_bo_count;
+ }
return VK_SUCCESS;
}
More information about the mesa-commit
mailing list