-static void
-handle_3dstate_cc_state_pointers(struct gen_spec *spec, uint32_t *p)
-{
- uint64_t start;
- struct gen_group *cc_state;
-
- cc_state = gen_spec_find_struct(spec, "COLOR_CALC_STATE");
-
- start = dynamic_state_base + (p[1] & ~0x3fu);
- decode_structure(spec, cc_state, gtt + start);
-}
-
-static void
-handle_3dstate_scissor_state_pointers(struct gen_spec *spec, uint32_t *p)
-{
- uint64_t start;
- struct gen_group *scissor_rect;
-
- scissor_rect = gen_spec_find_struct(spec, "SCISSOR_RECT");
-
- start = dynamic_state_base + (p[1] & ~0x1fu);
- decode_structure(spec, scissor_rect, gtt + start);
-}
-
-#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
-
-#define STATE_BASE_ADDRESS 0x61010000
-
-#define MEDIA_INTERFACE_DESCRIPTOR_LOAD 0x70020000
-
-#define _3DSTATE_INDEX_BUFFER 0x780a0000
-#define _3DSTATE_VERTEX_BUFFERS 0x78080000
-
-#define _3DSTATE_VS 0x78100000
-#define _3DSTATE_GS 0x78110000
-#define _3DSTATE_HS 0x781b0000
-#define _3DSTATE_DS 0x781d0000
-
-#define _3DSTATE_CONSTANT_VS 0x78150000
-#define _3DSTATE_CONSTANT_GS 0x78160000
-#define _3DSTATE_CONSTANT_PS 0x78170000
-#define _3DSTATE_CONSTANT_HS 0x78190000
-#define _3DSTATE_CONSTANT_DS 0x781A0000
-
-#define _3DSTATE_PS 0x78200000
-
-#define _3DSTATE_BINDING_TABLE_POINTERS_VS 0x78260000
-#define _3DSTATE_BINDING_TABLE_POINTERS_HS 0x78270000
-#define _3DSTATE_BINDING_TABLE_POINTERS_DS 0x78280000
-#define _3DSTATE_BINDING_TABLE_POINTERS_GS 0x78290000
-#define _3DSTATE_BINDING_TABLE_POINTERS_PS 0x782a0000
-
-#define _3DSTATE_SAMPLER_STATE_POINTERS_VS 0x782b0000
-#define _3DSTATE_SAMPLER_STATE_POINTERS_GS 0x782e0000
-#define _3DSTATE_SAMPLER_STATE_POINTERS_PS 0x782f0000
-
-#define _3DSTATE_VIEWPORT_STATE_POINTERS_CC 0x78230000
-#define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP 0x78210000
-#define _3DSTATE_BLEND_STATE_POINTERS 0x78240000
-#define _3DSTATE_CC_STATE_POINTERS 0x780e0000
-#define _3DSTATE_SCISSOR_STATE_POINTERS 0x780f0000
-
-struct custom_handler {
- uint32_t opcode;
- void (*handle)(struct gen_spec *spec, uint32_t *p);
-} custom_handlers[] = {
- { STATE_BASE_ADDRESS, handle_state_base_address },
- { MEDIA_INTERFACE_DESCRIPTOR_LOAD, handle_media_interface_descriptor_load },
- { _3DSTATE_VERTEX_BUFFERS, handle_3dstate_vertex_buffers },
- { _3DSTATE_INDEX_BUFFER, handle_3dstate_index_buffer },
- { _3DSTATE_VS, handle_3dstate_vs },
- { _3DSTATE_GS, handle_3dstate_vs },
- { _3DSTATE_DS, handle_3dstate_vs },
- { _3DSTATE_HS, handle_3dstate_hs },
- { _3DSTATE_CONSTANT_VS, handle_3dstate_constant },
- { _3DSTATE_CONSTANT_GS, handle_3dstate_constant },
- { _3DSTATE_CONSTANT_PS, handle_3dstate_constant },
- { _3DSTATE_CONSTANT_HS, handle_3dstate_constant },
- { _3DSTATE_CONSTANT_DS, handle_3dstate_constant },
- { _3DSTATE_PS, handle_3dstate_ps },
-
- { _3DSTATE_BINDING_TABLE_POINTERS_VS, handle_3dstate_binding_table_pointers },
- { _3DSTATE_BINDING_TABLE_POINTERS_HS, handle_3dstate_binding_table_pointers },
- { _3DSTATE_BINDING_TABLE_POINTERS_DS, handle_3dstate_binding_table_pointers },
- { _3DSTATE_BINDING_TABLE_POINTERS_GS, handle_3dstate_binding_table_pointers },
- { _3DSTATE_BINDING_TABLE_POINTERS_PS, handle_3dstate_binding_table_pointers },
-
- { _3DSTATE_SAMPLER_STATE_POINTERS_VS, handle_3dstate_sampler_state_pointers },
- { _3DSTATE_SAMPLER_STATE_POINTERS_GS, handle_3dstate_sampler_state_pointers },
- { _3DSTATE_SAMPLER_STATE_POINTERS_PS, handle_3dstate_sampler_state_pointers },
-
- { _3DSTATE_VIEWPORT_STATE_POINTERS_CC, handle_3dstate_viewport_state_pointers_cc },
- { _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, handle_3dstate_viewport_state_pointers_sf_clip },
- { _3DSTATE_BLEND_STATE_POINTERS, handle_3dstate_blend_state_pointers },
- { _3DSTATE_CC_STATE_POINTERS, handle_3dstate_cc_state_pointers },
- { _3DSTATE_SCISSOR_STATE_POINTERS, handle_3dstate_scissor_state_pointers }
-};
-
-static void
-parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine)
-{
- uint32_t *p, *end = cmds + size / 4;
- unsigned int length, i;
- struct gen_group *inst;
-
- for (p = cmds; p < end; p += length) {
- inst = gen_spec_find_instruction(spec, p);
- if (inst == NULL) {
- printf("unknown instruction %08x\n", p[0]);
- length = (p[0] & 0xff) + 2;
- continue;
- }
- length = gen_group_get_length(inst, p);
-
- const char *color, *reset_color = CLEAR_TO_EOL NORMAL;
- uint64_t offset;
-
- if (option_full_decode)
- color = HEADER;
- else
- color = NORMAL;
-
- if (option_color == COLOR_NEVER) {
- color = "";
- reset_color = "";
- }
-
- if (option_print_offsets)
- offset = (void *) p - gtt;
- else
- offset = 0;
-
- printf("%s0x%08lx: 0x%08x: %s%s\n",
- color, offset, p[0],
- gen_group_get_name(inst), reset_color);
-
- if (option_full_decode) {
- struct gen_field_iterator iter;
- char *token = NULL;
- int idx = 0, dword_num = 0;
- gen_field_iterator_init(&iter, inst, p);
- while (gen_field_iterator_next(&iter)) {
- idx = 0;
- print_dword_val(&iter, offset, &dword_num);
- if (dword_num > 0)
- token = print_iterator_values(&iter, &idx);
- if (token != NULL) {
- printf("0x%08lx: 0x%08x : Dword %d\n",
- offset + 4 * idx, p[idx], idx);
- handle_struct_decode(spec,token, &p[idx]);
- token = NULL;
- }
- }
-
- for (i = 0; i < ARRAY_LENGTH(custom_handlers); i++) {
- if (gen_group_get_opcode(inst) ==
- custom_handlers[i].opcode)
- custom_handlers[i].handle(spec, p);
- }
- }
-
- if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_START) {
- uint64_t start;
- if (gen_spec_get_gen(spec) >= gen_make_gen(8,0))
- start = get_qword(&p[1]);
- else
- start = p[1];
-
- parse_commands(spec, gtt + start, 1 << 20, engine);
- } else if ((p[0] & 0xffff0000) == AUB_MI_BATCH_BUFFER_END) {
- break;
- }
- }