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 <lionel.g.landwerlin@intel.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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 *
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user