From a6740ee7a4de17ce05fa10c872d6a6f08b39b77c Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 7 Jul 2023 09:00:19 -0700 Subject: [PATCH] d3d12: Fix indexing of local_reference_state Instead of manually indexing a single-dimensional array as 2-dimensional (and using the wrong stride for the outer array) just actually make it a 2-dimensional array. Fixes: 7edae456 ("d3d12: Track up to 16 contexts worth of batch references locally in bos") Part-of: --- src/gallium/drivers/d3d12/d3d12_batch.cpp | 6 +++--- src/gallium/drivers/d3d12/d3d12_bufmgr.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_batch.cpp b/src/gallium/drivers/d3d12/d3d12_batch.cpp index 75ce88f4faf..6f578994ac6 100644 --- a/src/gallium/drivers/d3d12/d3d12_batch.cpp +++ b/src/gallium/drivers/d3d12/d3d12_batch.cpp @@ -284,7 +284,7 @@ d3d12_batch_get_reference(struct d3d12_batch *batch, { if (batch->ctx_id != D3D12_CONTEXT_NO_ID) { if ((bo->local_reference_mask[batch->ctx_id] & (1 << batch->ctx_index)) != 0) { - return &bo->local_reference_state[(batch->ctx_id * 16) + batch->ctx_index]; + return &bo->local_reference_state[batch->ctx_id][batch->ctx_index]; } else return NULL; @@ -307,9 +307,9 @@ d3d12_batch_acquire_reference(struct d3d12_batch *batch, d3d12_bo_reference(bo); util_dynarray_append(&batch->local_bos, d3d12_bo*, bo); bo->local_reference_mask[batch->ctx_id] |= (1 << batch->ctx_index); - bo->local_reference_state[(batch->ctx_id * 16) + batch->ctx_index] = batch_bo_reference_none; + bo->local_reference_state[batch->ctx_id][batch->ctx_index] = batch_bo_reference_none; } - return &bo->local_reference_state[(batch->ctx_id * 16) + batch->ctx_index]; + return &bo->local_reference_state[batch->ctx_id][batch->ctx_index]; } else { hash_entry* entry = _mesa_hash_table_search(batch->bos, bo); diff --git a/src/gallium/drivers/d3d12/d3d12_bufmgr.h b/src/gallium/drivers/d3d12/d3d12_bufmgr.h index 96d68bfd3b3..ee70fa6bde0 100644 --- a/src/gallium/drivers/d3d12/d3d12_bufmgr.h +++ b/src/gallium/drivers/d3d12/d3d12_bufmgr.h @@ -71,7 +71,7 @@ struct d3d12_bo { uint8_t local_reference_mask[16]; d3d12_context_state_table_entry local_context_states[16]; - uint8_t local_reference_state[128]; + uint8_t local_reference_state[8][16]; }; struct d3d12_buffer {