From 929db0a818d651cd77a0330f1d3697d62afcf6e2 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 15 Sep 2021 13:07:46 +1000 Subject: [PATCH] intel/decode/gfx6: add support for gfx6 CC/VIEWPORT pointers. These have 3 sub states encoded and valid fields on SNB. Acked-by: Jason Ekstrand Part-of: --- src/intel/common/intel_batch_decoder.c | 103 +++++++++++++++++++++---- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/src/intel/common/intel_batch_decoder.c b/src/intel/common/intel_batch_decoder.c index 61b9053356a..4c3482852e4 100644 --- a/src/intel/common/intel_batch_decoder.c +++ b/src/intel/common/intel_batch_decoder.c @@ -851,23 +851,10 @@ str_ends_with(const char *str, const char *end) } static void -decode_dynamic_state_pointers(struct intel_batch_decode_ctx *ctx, - const char *struct_type, const uint32_t *p, - int count) +decode_dynamic_state(struct intel_batch_decode_ctx *ctx, + const char *struct_type, uint32_t state_offset, + int count) { - struct intel_group *inst = intel_ctx_find_instruction(ctx, p); - - uint32_t state_offset = 0; - - struct intel_field_iterator iter; - intel_field_iterator_init(&iter, inst, p, 0, false); - while (intel_field_iterator_next(&iter)) { - if (str_ends_with(iter.name, "Pointer") || !strncmp(iter.name, "Pointer", 7)) { - state_offset = iter.raw_value; - break; - } - } - uint64_t state_addr = ctx->dynamic_base + state_offset; struct intel_batch_decode_bo bo = ctx_get_bo(ctx, true, state_addr); const void *state_map = bo.map; @@ -905,6 +892,57 @@ decode_dynamic_state_pointers(struct intel_batch_decode_ctx *ctx, } } +static void +decode_dynamic_state_pointers(struct intel_batch_decode_ctx *ctx, + const char *struct_type, const uint32_t *p, + int count) +{ + struct intel_group *inst = intel_ctx_find_instruction(ctx, p); + + uint32_t state_offset = 0; + + struct intel_field_iterator iter; + intel_field_iterator_init(&iter, inst, p, 0, false); + while (intel_field_iterator_next(&iter)) { + if (str_ends_with(iter.name, "Pointer") || !strncmp(iter.name, "Pointer", 7)) { + state_offset = iter.raw_value; + break; + } + } + decode_dynamic_state(ctx, struct_type, state_offset, count); +} + +static void +decode_3dstate_viewport_state_pointers(struct intel_batch_decode_ctx *ctx, + const uint32_t *p) +{ + struct intel_group *inst = intel_ctx_find_instruction(ctx, p); + uint32_t state_offset = 0; + bool clip = false, sf = false, cc = false; + struct intel_field_iterator iter; + intel_field_iterator_init(&iter, inst, p, 0, false); + while (intel_field_iterator_next(&iter)) { + if (!strcmp(iter.name, "CLIP Viewport State Change")) + clip = iter.raw_value; + if (!strcmp(iter.name, "SF Viewport State Change")) + sf = iter.raw_value; + if (!strcmp(iter.name, "CC Viewport State Change")) + cc = iter.raw_value; + else if (!strcmp(iter.name, "Pointer to CLIP_VIEWPORT") && clip) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "CLIP_VIEWPORT", state_offset, 1); + } + else if (!strcmp(iter.name, "Pointer to SF_VIEWPORT") && sf) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "SF_VIEWPORT", state_offset, 1); + } + else if (!strcmp(iter.name, "Pointer to CC_VIEWPORT") && cc) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "CC_VIEWPORT", state_offset, 1); + } + } +} + static void decode_3dstate_viewport_state_pointers_cc(struct intel_batch_decode_ctx *ctx, const uint32_t *p) @@ -930,7 +968,37 @@ static void decode_3dstate_cc_state_pointers(struct intel_batch_decode_ctx *ctx, const uint32_t *p) { - decode_dynamic_state_pointers(ctx, "COLOR_CALC_STATE", p, 1); + if (ctx->devinfo.ver != 6) { + decode_dynamic_state_pointers(ctx, "COLOR_CALC_STATE", p, 1); + return; + } + + struct intel_group *inst = intel_ctx_find_instruction(ctx, p); + + uint32_t state_offset = 0; + bool blend_change = false, ds_change = false, cc_change = false; + struct intel_field_iterator iter; + intel_field_iterator_init(&iter, inst, p, 0, false); + while (intel_field_iterator_next(&iter)) { + if (!strcmp(iter.name, "BLEND_STATE Change")) + blend_change = iter.raw_value; + else if (!strcmp(iter.name, "DEPTH_STENCIL_STATE Change")) + ds_change = iter.raw_value; + else if (!strcmp(iter.name, "Color Calc State Pointer Valid")) + cc_change = iter.raw_value; + else if (!strcmp(iter.name, "Pointer to DEPTH_STENCIL_STATE") && ds_change) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "DEPTH_STENCIL_STATE", state_offset, 1); + } + else if (!strcmp(iter.name, "Pointer to BLEND_STATE") && blend_change) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "BLEND_STATE", state_offset, 1); + } + else if (!strcmp(iter.name, "Color Calc State Pointer") && cc_change) { + state_offset = iter.raw_value; + decode_dynamic_state(ctx, "COLOR_CALC_STATE", state_offset, 1); + } + } } static void @@ -1262,6 +1330,7 @@ struct custom_decoder { { "3DSTATE_SAMPLER_STATE_POINTERS_PS", decode_3dstate_sampler_state_pointers }, { "3DSTATE_SAMPLER_STATE_POINTERS", decode_3dstate_sampler_state_pointers_gfx6 }, + { "3DSTATE_VIEWPORT_STATE_POINTERS", decode_3dstate_viewport_state_pointers }, { "3DSTATE_VIEWPORT_STATE_POINTERS_CC", decode_3dstate_viewport_state_pointers_cc }, { "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP", decode_3dstate_viewport_state_pointers_sf_clip }, { "3DSTATE_BLEND_STATE_POINTERS", decode_3dstate_blend_state_pointers },