From 79caf8a44b682f731c0fd3b941f38cc1869efe2d Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 30 Jan 2023 14:46:26 -0800 Subject: [PATCH] anv: Make a batch decoder for each queue family The decoder context needs to know what engine it's associated with. Nowadays, we have render, compute, blitter, even video engines being used from the same driver. Rather than trying to have a single decoder and thwacking the engine field back and forth between calls, we make one per queue family, and stash a pointer in anv_queue for easy access. Part-of: --- src/intel/vulkan/anv_batch_chain.c | 8 +++--- src/intel/vulkan/anv_device.c | 40 ++++++++++++++++++------------ src/intel/vulkan/anv_private.h | 4 ++- src/intel/vulkan/anv_queue.c | 2 ++ 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index fd57f7493cb..b4b1ce4fa57 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1177,7 +1177,7 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, uint64_t pass_batch_offset = khr_perf_query_preamble_offset(perf_query_pool, perf_query_pass); - intel_print_batch(&device->decoder_ctx, + intel_print_batch(queue->decoder, pass_batch_bo->map + pass_batch_offset, 64, pass_batch_bo->offset + pass_batch_offset, false); } @@ -1185,12 +1185,12 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, for (uint32_t i = 0; i < cmd_buffer_count; i++) { struct anv_batch_bo **bo = u_vector_tail(&cmd_buffers[i]->seen_bbos); device->cmd_buffer_being_decoded = cmd_buffers[i]; - intel_print_batch(&device->decoder_ctx, (*bo)->bo->map, + intel_print_batch(queue->decoder, (*bo)->bo->map, (*bo)->bo->size, (*bo)->bo->offset, false); device->cmd_buffer_being_decoded = NULL; } } else { - intel_print_batch(&device->decoder_ctx, device->trivial_batch_bo->map, + intel_print_batch(queue->decoder, device->trivial_batch_bo->map, device->trivial_batch_bo->size, device->trivial_batch_bo->offset, false); } @@ -1383,7 +1383,7 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, #endif if (INTEL_DEBUG(DEBUG_BATCH)) { - intel_print_batch(&device->decoder_ctx, + intel_print_batch(queue->decoder, batch_bo->map, batch_bo->size, batch_bo->offset, false); diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 3541209d076..71d4c462f67 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3200,22 +3200,26 @@ VkResult anv_CreateDevice( goto fail_alloc; if (INTEL_DEBUG(DEBUG_BATCH)) { - const unsigned decode_flags = - INTEL_BATCH_DECODE_FULL | - (INTEL_DEBUG(DEBUG_COLOR) ? INTEL_BATCH_DECODE_IN_COLOR : 0) | - INTEL_BATCH_DECODE_OFFSETS | - INTEL_BATCH_DECODE_FLOATS; + for (unsigned i = 0; i < physical_device->queue.family_count; i++) { + struct intel_batch_decode_ctx *decoder = &device->decoder[i]; - intel_batch_decode_ctx_init(&device->decoder_ctx, - &physical_device->compiler->isa, - &physical_device->info, - stderr, decode_flags, NULL, - decode_get_bo, NULL, device); + const unsigned decode_flags = + INTEL_BATCH_DECODE_FULL | + (INTEL_DEBUG(DEBUG_COLOR) ? INTEL_BATCH_DECODE_IN_COLOR : 0) | + INTEL_BATCH_DECODE_OFFSETS | + INTEL_BATCH_DECODE_FLOATS; - device->decoder_ctx.dynamic_base = DYNAMIC_STATE_POOL_MIN_ADDRESS; - device->decoder_ctx.surface_base = INTERNAL_SURFACE_STATE_POOL_MIN_ADDRESS; - device->decoder_ctx.instruction_base = - INSTRUCTION_STATE_POOL_MIN_ADDRESS; + intel_batch_decode_ctx_init(decoder, + &physical_device->compiler->isa, + &physical_device->info, + stderr, decode_flags, NULL, + decode_get_bo, NULL, device); + + decoder->engine = physical_device->queue.families[i].engine_class; + decoder->dynamic_base = DYNAMIC_STATE_POOL_MIN_ADDRESS; + decoder->surface_base = INTERNAL_SURFACE_STATE_POOL_MIN_ADDRESS; + decoder->instruction_base = INSTRUCTION_STATE_POOL_MIN_ADDRESS; + } } anv_device_set_physical(device, physical_device); @@ -3635,6 +3639,8 @@ void anv_DestroyDevice( if (!device) return; + struct anv_physical_device *pdevice = device->physical; + anv_device_utrace_finish(device); anv_device_finish_blorp(device); @@ -3707,8 +3713,10 @@ void anv_DestroyDevice( intel_gem_destroy_context(device->fd, device->context_id); - if (INTEL_DEBUG(DEBUG_BATCH)) - intel_batch_decode_ctx_finish(&device->decoder_ctx); + if (INTEL_DEBUG(DEBUG_BATCH)) { + for (unsigned i = 0; i < pdevice->queue.family_count; i++) + intel_batch_decode_ctx_finish(&device->decoder[i]); + } close(device->fd); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 90f73c3606d..7efb4ab647d 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1050,6 +1050,8 @@ struct anv_queue { const struct anv_queue_family * family; + struct intel_batch_decode_ctx * decoder; + uint32_t exec_flags; /** Synchronization object for debug purposes (DEBUG_SYNC) */ @@ -1221,7 +1223,7 @@ struct anv_device { pthread_mutex_t mutex; pthread_cond_t queue_submit; - struct intel_batch_decode_ctx decoder_ctx; + struct intel_batch_decode_ctx decoder[ANV_MAX_QUEUE_FAMILIES]; /* * When decoding a anv_cmd_buffer, we might need to search for BOs through * the cmd_buffer's list. diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index d3999434422..1101c903975 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -59,6 +59,8 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue, queue->family = &pdevice->queue.families[queue->vk.queue_family_index]; queue->exec_flags = exec_flags; + queue->decoder = &device->decoder[queue->vk.queue_family_index]; + return VK_SUCCESS; }