diff options
Diffstat (limited to 'src/intel/tools/aub_write.c')
-rw-r--r-- | src/intel/tools/aub_write.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c index f928094d350..f9fe8db24cb 100644 --- a/src/intel/tools/aub_write.c +++ b/src/intel/tools/aub_write.c @@ -188,6 +188,8 @@ aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, co "GGTT PT"); dword_out(aub, 1); dword_out(aub, 0); + + aub->next_context_handle = 1; } void @@ -611,6 +613,66 @@ aub_write_default_setup(struct aub_file *aub) aub->has_default_setup = true; } +static struct aub_context * +aub_context_new(struct aub_file *aub, uint32_t new_id) +{ + assert(aub->num_contexts < MAX_CONTEXT_COUNT); + + struct aub_context *ctx = &aub->contexts[aub->num_contexts++]; + + ctx->id = new_id; + memset(ctx, 0, sizeof(*ctx)); + + return ctx; +} + +uint32_t +aub_write_context_create(struct aub_file *aub, uint32_t *ctx_id) +{ + uint32_t new_id = ctx_id ? *ctx_id : aub->next_context_handle; + + aub_context_new(aub, new_id); + + if (!ctx_id) + aub->next_context_handle++; + + return new_id; +} + +static struct aub_context * +aub_context_find(struct aub_file *aub, uint32_t id) +{ + for (int i = 0; i < aub->num_contexts; i++) { + if (aub->contexts[i].id == id) + return &aub->contexts[i]; + } + + return NULL; +} + +static struct aub_hw_context * +aub_write_ensure_context(struct aub_file *aub, uint32_t ctx_id, + enum drm_i915_gem_engine_class engine_class) +{ + struct aub_context *ctx = aub_context_find(aub, ctx_id); + assert(ctx != NULL); + + struct aub_hw_context *hw_ctx = &ctx->hw_contexts[engine_class]; + if (!hw_ctx->initialized) { + /* TODO: initialize context here */ + } + + return hw_ctx; +} + +static uint64_t +get_context_descriptor(struct aub_file *aub, + const struct engine *cs, + struct aub_hw_context *hw_ctx) +{ + return cs->hw_class | hw_ctx->pphwsp_addr | CONTEXT_FLAGS; +} + /** * Break up large objects into multiple writes. Otherwise a 128kb VBO * would overflow the 16 bits of size field in the packet header and |