diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-06-10 14:23:34 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-06-12 15:57:16 -0700 |
commit | 608257cf82f49109c8f1a2bab1d6e30fa14f9ba7 (patch) | |
tree | 7ada03a436109d63f7338c1b222225edac1f122a | |
parent | eb41ce1b012f24fc7cba664dcc12129342e26843 (diff) |
i965: Fix INTEL_DEBUG=bat
Use hash_table_u64 instead of hash_table directly, since the former
will also handle the special keys (deleted and freed) and allow use
the whole u64 space.
Fixes crash in INTEL_DEBUG=bat when using a key with value 0 -- the
current value for a freed key.
Fixes: b38dab101ca "util/hash_table: Assert that keys are not reserved pointers"
Reviewed-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_batchbuffer.c | 30 | ||||
-rw-r--r-- | src/util/hash_table.c | 15 | ||||
-rw-r--r-- | src/util/hash_table.h | 4 |
4 files changed, 26 insertions, 25 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 46791c7d2c8..25ae25e06ff 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -524,7 +524,7 @@ struct intel_batchbuffer { } saved; /** Map from batch offset to brw_state_batch data (with DEBUG_BATCH) */ - struct hash_table *state_batch_sizes; + struct hash_table_u64 *state_batch_sizes; struct gen_batch_decode_ctx decoder; }; diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index a701f3bd353..af076f65f0b 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -108,22 +108,9 @@ decode_get_state_size(void *v_brw, uint32_t offset_from_dsba) { struct brw_context *brw = v_brw; struct intel_batchbuffer *batch = &brw->batch; - struct hash_entry *entry = - _mesa_hash_table_search(batch->state_batch_sizes, - (void *) (uintptr_t) offset_from_dsba); - return entry ? (uintptr_t) entry->data : 0; -} - -static bool -uint_key_compare(const void *a, const void *b) -{ - return a == b; -} - -static uint32_t -uint_key_hash(const void *key) -{ - return (uintptr_t) key; + unsigned size = (uintptr_t) _mesa_hash_table_u64_search( + batch->state_batch_sizes, offset_from_dsba); + return size; } static void @@ -158,7 +145,7 @@ intel_batchbuffer_init(struct brw_context *brw) if (INTEL_DEBUG & DEBUG_BATCH) { batch->state_batch_sizes = - _mesa_hash_table_create(NULL, uint_key_hash, uint_key_compare); + _mesa_hash_table_u64_create(NULL); const unsigned decode_flags = GEN_BATCH_DECODE_FULL | @@ -284,7 +271,7 @@ intel_batchbuffer_reset(struct brw_context *brw) batch->state_base_address_emitted = false; if (batch->state_batch_sizes) - _mesa_hash_table_clear(batch->state_batch_sizes, NULL); + _mesa_hash_table_u64_clear(batch->state_batch_sizes, NULL); } static void @@ -346,7 +333,7 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch) brw_bo_unreference(batch->batch.bo); brw_bo_unreference(batch->state.bo); if (batch->state_batch_sizes) { - _mesa_hash_table_destroy(batch->state_batch_sizes, NULL); + _mesa_hash_table_u64_destroy(batch->state_batch_sizes, NULL); gen_batch_decode_ctx_finish(&batch->decoder); } } @@ -1052,9 +1039,8 @@ brw_state_batch(struct brw_context *brw, } if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) { - _mesa_hash_table_insert(batch->state_batch_sizes, - (void *) (uintptr_t) offset, - (void *) (uintptr_t) size); + _mesa_hash_table_u64_insert(batch->state_batch_sizes, + offset, (void *) (uintptr_t) size); } batch->state_used = offset + size; diff --git a/src/util/hash_table.c b/src/util/hash_table.c index 58104abd739..f58575de558 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -655,8 +655,8 @@ _mesa_hash_table_u64_create(void *mem_ctx) } void -_mesa_hash_table_u64_destroy(struct hash_table_u64 *ht, - void (*delete_function)(struct hash_entry *entry)) +_mesa_hash_table_u64_clear(struct hash_table_u64 *ht, + void (*delete_function)(struct hash_entry *entry)) { if (!ht) return; @@ -691,6 +691,17 @@ _mesa_hash_table_u64_destroy(struct hash_table_u64 *ht, ht->freed_key_data = NULL; } + _mesa_hash_table_clear(ht->table, delete_function); +} + +void +_mesa_hash_table_u64_destroy(struct hash_table_u64 *ht, + void (*delete_function)(struct hash_entry *entry)) +{ + if (!ht) + return; + + _mesa_hash_table_u64_clear(ht, delete_function); _mesa_hash_table_destroy(ht->table, delete_function); free(ht); } diff --git a/src/util/hash_table.h b/src/util/hash_table.h index be7b50ff1fe..87b1409c457 100644 --- a/src/util/hash_table.h +++ b/src/util/hash_table.h @@ -194,6 +194,10 @@ _mesa_hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key); void _mesa_hash_table_u64_remove(struct hash_table_u64 *ht, uint64_t key); +void +_mesa_hash_table_u64_clear(struct hash_table_u64 *ht, + void (*delete_function)(struct hash_entry *entry)); + #ifdef __cplusplus } /* extern C */ #endif |