diff options
author | Lionel Landwerlin <[email protected]> | 2019-02-23 23:27:17 +0000 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2019-03-02 12:53:21 +0000 |
commit | 32ffd90002b04bff20a587e5d2f31fe79af1a4f2 (patch) | |
tree | b2da0fe62833ae74ca0d72434b4a2de444bad6a8 | |
parent | f1122f78b765ecbb5702b5c2e2bf4a03fb83d778 (diff) |
anv: add support for INTEL_DEBUG=bat
As requested by Ken ;)
v2: Also decode simple batches (Caio)
Fix u_vector usage issues (Lionel)
v3: Make binding/instruction/state/surface available (Lionel)
v4: Going through device pools for simple batches (Lionel)
Centralize search BO callbacks into anv_device.c (Lionel)
v5: Clear decoded batch buffer var after use (Caio)
Signed-off-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
-rw-r--r-- | src/intel/vulkan/anv_batch_chain.c | 14 | ||||
-rw-r--r-- | src/intel/vulkan/anv_device.c | 70 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 8 | ||||
-rw-r--r-- | src/intel/vulkan/anv_queue.c | 3 |
4 files changed, 93 insertions, 2 deletions
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index ff713d529af..9c7f96873a8 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1729,10 +1729,20 @@ anv_cmd_buffer_execbuf(struct anv_device *device, } } - if (cmd_buffer) + if (cmd_buffer) { + if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) { + struct anv_batch_bo **bo = u_vector_head(&cmd_buffer->seen_bbos); + + device->cmd_buffer_being_decoded = cmd_buffer; + gen_print_batch(&device->decoder_ctx, (*bo)->bo.map, + (*bo)->bo.size, (*bo)->bo.offset); + device->cmd_buffer_being_decoded = NULL; + } + result = setup_execbuf_for_cmd_buffer(&execbuf, cmd_buffer); - else + } else { result = setup_empty_execbuf(&execbuf, device); + } if (result != VK_SUCCESS) return result; diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 95224407318..ed7b7b0f0a0 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1735,6 +1735,63 @@ anv_device_init_hiz_clear_value_bo(struct anv_device *device) anv_gem_munmap(map, device->hiz_clear_bo.size); } +static bool +get_bo_from_pool(struct gen_batch_decode_bo *ret, + struct anv_block_pool *pool, + uint64_t address) +{ + for (uint32_t i = 0; i < pool->nbos; i++) { + uint64_t bo_address = pool->bos[i].offset & (~0ull >> 16); + uint32_t bo_size = pool->bos[i].size; + if (address >= bo_address && address < (bo_address + bo_size)) { + *ret = (struct gen_batch_decode_bo) { + .addr = bo_address, + .size = bo_size, + .map = pool->bos[i].map, + }; + return true; + } + } + return false; +} + +/* Finding a buffer for batch decoding */ +static struct gen_batch_decode_bo +decode_get_bo(void *v_batch, uint64_t address) +{ + struct anv_device *device = v_batch; + struct gen_batch_decode_bo ret_bo = {}; + + if (get_bo_from_pool(&ret_bo, &device->dynamic_state_pool.block_pool, address)) + return ret_bo; + if (get_bo_from_pool(&ret_bo, &device->instruction_state_pool.block_pool, address)) + return ret_bo; + if (get_bo_from_pool(&ret_bo, &device->binding_table_pool.block_pool, address)) + return ret_bo; + if (get_bo_from_pool(&ret_bo, &device->surface_state_pool.block_pool, address)) + return ret_bo; + + if (!device->cmd_buffer_being_decoded) + return (struct gen_batch_decode_bo) { }; + + struct anv_batch_bo **bo; + + u_vector_foreach(bo, &device->cmd_buffer_being_decoded->seen_bbos) { + /* The decoder zeroes out the top 16 bits, so we need to as well */ + uint64_t bo_address = (*bo)->bo.offset & (~0ull >> 16); + + if (address >= bo_address && address < bo_address + (*bo)->bo.size) { + return (struct gen_batch_decode_bo) { + .addr = bo_address, + .size = (*bo)->bo.size, + .map = (*bo)->bo.map, + }; + } + } + + return (struct gen_batch_decode_bo) { }; +} + VkResult anv_CreateDevice( VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, @@ -1802,6 +1859,17 @@ VkResult anv_CreateDevice( if (!device) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + const unsigned decode_flags = + GEN_BATCH_DECODE_FULL | + ((INTEL_DEBUG & DEBUG_COLOR) ? GEN_BATCH_DECODE_IN_COLOR : 0) | + GEN_BATCH_DECODE_OFFSETS | + GEN_BATCH_DECODE_FLOATS; + + gen_batch_decode_ctx_init(&device->decoder_ctx, + &physical_device->info, + stderr, decode_flags, NULL, + decode_get_bo, NULL, device); + device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = physical_device->instance; device->chipset_id = physical_device->chipset_id; @@ -2089,6 +2157,8 @@ void anv_DestroyDevice( anv_gem_destroy_context(device, device->context_id); + gen_batch_decode_ctx_finish(&device->decoder_ctx); + close(device->fd); vk_free(&device->alloc, device); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 7624aace593..7b040a2b962 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -44,6 +44,7 @@ #endif #include "common/gen_clflush.h" +#include "common/gen_decoder.h" #include "common/gen_gem.h" #include "dev/gen_device_info.h" #include "blorp/blorp.h" @@ -1120,6 +1121,13 @@ struct anv_device { pthread_mutex_t mutex; pthread_cond_t queue_submit; bool _lost; + + struct gen_batch_decode_ctx decoder_ctx; + /* + * When decoding a anv_cmd_buffer, we might need to search for BOs through + * the cmd_buffer's list. + */ + struct anv_cmd_buffer *cmd_buffer_being_decoded; }; static inline struct anv_state_pool * diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index 55465c5ebe2..54e848fd15c 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -100,6 +100,9 @@ anv_device_submit_simple_batch(struct anv_device *device, execbuf.rsvd1 = device->context_id; execbuf.rsvd2 = 0; + if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) + gen_print_batch(&device->decoder_ctx, bo.map, bo.size, bo.offset); + result = anv_device_execbuf(device, &execbuf, exec_bos); if (result != VK_SUCCESS) goto fail; |