Mesa (main): d3d12: Fix incorrect hash table usage
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 16 19:39:55 UTC 2021
Module: Mesa
Branch: main
Commit: a818f7b68676a08075ad314e13cc114306830525
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a818f7b68676a08075ad314e13cc114306830525
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Tue Nov 16 07:05:45 2021 -0800
d3d12: Fix incorrect hash table usage
I'd assumed that since insert didn't take a deleter, it was
find-or-insert, not insert-or-replace. This caused a bo reference
leak if the same bo was used more than once in a batch.
Fixes: fde36d79920 ("d3d12: Don't wait for GPU reads to do CPU reads")
Reviewed By: Bill Kristiansen <billkris at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13819>
---
src/gallium/drivers/d3d12/d3d12_batch.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_batch.cpp b/src/gallium/drivers/d3d12/d3d12_batch.cpp
index d45ba6e6b2d..9cb571a19e6 100644
--- a/src/gallium/drivers/d3d12/d3d12_batch.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_batch.cpp
@@ -230,9 +230,11 @@ d3d12_batch_reference_resource(struct d3d12_batch *batch,
struct d3d12_resource *res,
bool write)
{
- hash_entry *entry = _mesa_hash_table_insert(batch->bos, res->bo, NULL);
- if (entry->data == NULL)
+ hash_entry *entry = _mesa_hash_table_search(batch->bos, res->bo);
+ if (entry == NULL) {
d3d12_bo_reference(res->bo);
+ entry = _mesa_hash_table_insert(batch->bos, res->bo, NULL);
+ }
size_t new_data = write ? batch_bo_reference_written : batch_bo_reference_read;
size_t old_data = (size_t)entry->data;
entry->data = (void*)(old_data | new_data);
More information about the mesa-commit
mailing list