anv/slice_hash: Don't allocate more than once with multiple queues

emit_slice_hashing_state gets called once per queue, meaning
device->slice_hash can get allocated multiple times. This can be
reproduced by setting the env-var ANV_QUEUE_OVERRIDE=gc=2.

Reworks:
 * Only pack the struct once (s-b Lionel, Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13114>
This commit is contained in:
Jordan Justen 2021-09-29 18:49:59 -07:00 committed by Marge Bot
parent bfeb0983d3
commit 51338a1177
1 changed files with 10 additions and 9 deletions

View File

@ -79,24 +79,24 @@ static void
genX(emit_slice_hashing_state)(struct anv_device *device,
struct anv_batch *batch)
{
device->slice_hash = (struct anv_state) { 0 };
#if GFX_VER == 11
assert(device->info.ppipe_subslices[2] == 0);
if (device->info.ppipe_subslices[0] == device->info.ppipe_subslices[1])
return;
unsigned size = GENX(SLICE_HASH_TABLE_length) * 4;
device->slice_hash =
anv_state_pool_alloc(&device->dynamic_state_pool, size, 64);
if (!device->slice_hash.alloc_size) {
unsigned size = GENX(SLICE_HASH_TABLE_length) * 4;
device->slice_hash =
anv_state_pool_alloc(&device->dynamic_state_pool, size, 64);
const bool flip = device->info.ppipe_subslices[0] <
const bool flip = device->info.ppipe_subslices[0] <
device->info.ppipe_subslices[1];
struct GENX(SLICE_HASH_TABLE) table;
calculate_pixel_hashing_table(16, 16, 3, 3, flip, table.Entry[0]);
struct GENX(SLICE_HASH_TABLE) table;
calculate_pixel_hashing_table(16, 16, 3, 3, flip, table.Entry[0]);
GENX(SLICE_HASH_TABLE_pack)(NULL, device->slice_hash.map, &table);
GENX(SLICE_HASH_TABLE_pack)(NULL, device->slice_hash.map, &table);
}
anv_batch_emit(batch, GENX(3DSTATE_SLICE_TABLE_STATE_POINTERS), ptr) {
ptr.SliceHashStatePointerValid = true;
@ -333,6 +333,7 @@ genX(init_device_state)(struct anv_device *device)
{
VkResult res;
device->slice_hash = (struct anv_state) { 0 };
for (uint32_t i = 0; i < device->queue_count; i++) {
struct anv_queue *queue = &device->queues[i];
switch (queue->family->engine_class) {