intel/decoder: tools: Use engine for decoding batch instructions
[mesa.git] / src / intel / tools / aubinator_viewer.h
1 #ifndef AUBINATOR_VIEWER_H
2 #define AUBINATOR_VIEWER_H
3
4 #include "imgui.h"
5
6 #include "common/gen_decoder.h"
7 #include "common/gen_disasm.h"
8
9 struct aub_viewer_cfg {
10 ImColor clear_color;
11 ImColor dwords_color;
12 ImColor highlight_color;
13 ImColor error_color;
14 ImColor missing_color;
15
16 aub_viewer_cfg() :
17 clear_color(114, 144, 154),
18 dwords_color(29, 177, 194, 255),
19 highlight_color(0, 230, 0, 255),
20 error_color(236, 255, 0, 255),
21 missing_color(230, 0, 230, 255) {}
22 };
23
24 struct aub_viewer_decode_cfg {
25 struct ImGuiTextFilter command_filter;
26 struct ImGuiTextFilter field_filter;
27
28 bool drop_filtered;
29 bool show_dwords;
30
31 aub_viewer_decode_cfg() :
32 drop_filtered(false),
33 show_dwords(true) {}
34 };
35
36 enum aub_decode_stage {
37 AUB_DECODE_STAGE_VS,
38 AUB_DECODE_STAGE_HS,
39 AUB_DECODE_STAGE_DS,
40 AUB_DECODE_STAGE_GS,
41 AUB_DECODE_STAGE_PS,
42 AUB_DECODE_STAGE_CS,
43 AUB_DECODE_N_STAGE,
44 };
45
46 struct aub_decode_urb_stage_state {
47 uint32_t start;
48 uint32_t size;
49 uint32_t n_entries;
50
51 uint32_t const_rd_length;
52 uint32_t rd_offset;
53 uint32_t rd_length;
54 uint32_t wr_offset;
55 uint32_t wr_length;
56 };
57
58 struct aub_viewer_decode_ctx {
59 struct gen_batch_decode_bo (*get_bo)(void *user_data, uint64_t address);
60 unsigned (*get_state_size)(void *user_data,
61 uint32_t offset_from_dynamic_state_base_addr);
62
63 void (*display_shader)(void *user_data, const char *shader_desc, uint64_t address);
64 void (*display_urb)(void *user_data, const struct aub_decode_urb_stage_state *stages);
65 void (*edit_address)(void *user_data, uint64_t address, uint32_t length);
66
67 void *user_data;
68
69 struct gen_spec *spec;
70 struct gen_disasm *disasm;
71 enum drm_i915_gem_engine_class engine;
72
73 struct aub_viewer_cfg *cfg;
74 struct aub_viewer_decode_cfg *decode_cfg;
75
76 uint64_t surface_base;
77 uint64_t dynamic_base;
78 uint64_t instruction_base;
79
80 enum aub_decode_stage stage;
81 uint32_t end_urb_offset;
82 struct aub_decode_urb_stage_state urb_stages[AUB_DECODE_N_STAGE];
83 };
84
85 void aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx,
86 struct aub_viewer_cfg *cfg,
87 struct aub_viewer_decode_cfg *decode_cfg,
88 struct gen_spec *spec,
89 struct gen_disasm *disasm,
90 struct gen_batch_decode_bo (*get_bo)(void *, uint64_t),
91 unsigned (*get_state_size)(void *, uint32_t),
92 void *user_data);
93
94 void aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
95 const void *batch, uint32_t batch_size,
96 uint64_t batch_addr);
97
98 #endif /* AUBINATOR_VIEWER_H */