From 65073c221770121253d6ec8ac9a323a36fce3b10 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 6 Apr 2018 16:21:21 -0700 Subject: [PATCH] iris: hook up batch decoder --- src/gallium/drivers/iris/iris_batch.c | 44 +++++++++++++++++++++++---- src/gallium/drivers/iris/iris_batch.h | 5 +++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 171bc9aa6b5..85f585cbfa1 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -25,7 +25,6 @@ #include "iris_batch.h" #include "iris_bufmgr.h" #include "iris_context.h" -#include "common/gen_decoder.h" #include "drm-uapi/i915_drm.h" @@ -70,6 +69,25 @@ dump_validation_list(struct iris_batch *batch) } } +static struct gen_batch_decode_bo +decode_get_bo(void *v_batch, uint64_t address) +{ + struct iris_batch *batch = v_batch; + struct iris_bo *bo = NULL; + + for (int i = 0; i < batch->exec_count; i++) { + if (batch->exec_bos[i]->gtt_offset == address) { + return (struct gen_batch_decode_bo) { + .addr = address, + .size = batch->exec_bos[i]->size, + .map = iris_bo_map(batch->dbg, batch->exec_bos[i], MAP_READ), + }; + } + } + + return (struct gen_batch_decode_bo) { }; +} + static bool uint_key_compare(const void *a, const void *b) { @@ -117,6 +135,16 @@ iris_init_batch(struct iris_batch *batch, if (unlikely(INTEL_DEBUG)) { batch->state_sizes = _mesa_hash_table_create(NULL, uint_key_hash, uint_key_compare); + + 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(&batch->decoder, &screen->devinfo, + stderr, decode_flags, NULL, + decode_get_bo, NULL, batch); } iris_batch_reset(batch); @@ -216,8 +244,10 @@ iris_batch_free(struct iris_batch *batch) iris_bo_unreference(batch->last_cmd_bo); - if (batch->state_sizes) + if (batch->state_sizes) { _mesa_hash_table_destroy(batch->state_sizes, NULL); + gen_batch_decode_ctx_finish(&batch->decoder); + } } /** @@ -522,6 +552,9 @@ _iris_batch_flush_fence(struct iris_batch *batch, (float) batch->aperture_space / (1024 * 1024)); } + if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) + decode_batch(batch); + int ret = submit_batch(batch, in_fence_fd, out_fence_fd); //throttle(iris); @@ -529,9 +562,6 @@ _iris_batch_flush_fence(struct iris_batch *batch, if (ret < 0) return ret; - if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) - decode_batch(batch); - //if (iris->ctx.Const.ResetStrategy == GL_LOSE_CONTEXT_ON_RESET_ARB) //iris_check_for_reset(ice); @@ -584,5 +614,7 @@ iris_use_pinned_bo(struct iris_batch *batch, static void decode_batch(struct iris_batch *batch) { - // XXX: decode the batch + gen_print_batch(&batch->decoder, batch->cmdbuf.map, + buffer_bytes_used(&batch->cmdbuf), + batch->cmdbuf.bo->gtt_offset); } diff --git a/src/gallium/drivers/iris/iris_batch.h b/src/gallium/drivers/iris/iris_batch.h index 492d95e7c99..68a10741f32 100644 --- a/src/gallium/drivers/iris/iris_batch.h +++ b/src/gallium/drivers/iris/iris_batch.h @@ -26,6 +26,7 @@ #include #include +#include "common/gen_decoder.h" /* The kernel assumes batchbuffers are smaller than 256kB. */ #define MAX_BATCH_SIZE (256 * 1024) @@ -77,8 +78,12 @@ struct iris_batch { /** The amount of aperture space (in bytes) used by all exec_bos */ int aperture_space; +#if DEBUG /** Map from batch offset to iris_alloc_state data (with DEBUG_BATCH) */ + // XXX: unused struct hash_table *state_sizes; + struct gen_batch_decode_ctx decoder; +#endif void (*emit_state_base_address)(struct iris_batch *batch); }; -- 2.30.2