summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/Makefile.am1
-rw-r--r--src/intel/tools/aubinator_viewer.cpp75
-rw-r--r--src/intel/tools/aubinator_viewer_urb.h96
3 files changed, 172 insertions, 0 deletions
diff --git a/src/intel/Makefile.am b/src/intel/Makefile.am
index cc43669d6be..95764b82da7 100644
--- a/src/intel/Makefile.am
+++ b/src/intel/Makefile.am
@@ -72,6 +72,7 @@ EXTRA_DIST = \
tools/aubinator_viewer.cpp \
tools/aubinator_viewer.h \
tools/aubinator_viewer_decoder.cpp \
+ tools/aubinator_viewer_urb.h \
tools/imgui/README \
tools/imgui/stb_textedit.h \
tools/imgui/meson.build \
diff --git a/src/intel/tools/aubinator_viewer.cpp b/src/intel/tools/aubinator_viewer.cpp
index 7ef56aa035f..e29bccb192a 100644
--- a/src/intel/tools/aubinator_viewer.cpp
+++ b/src/intel/tools/aubinator_viewer.cpp
@@ -226,6 +226,7 @@ update_mem_for_exec(struct aub_mem *mem, struct aub_file *file, int exec_idx)
#include "imgui_impl_opengl3.h"
#include "aubinator_viewer.h"
+#include "aubinator_viewer_urb.h"
#include "imgui_memory_editor.h"
struct window {
@@ -274,6 +275,15 @@ struct shader_window {
size_t shader_size;
};
+struct urb_window {
+ struct window base;
+
+ uint32_t end_urb_offset;
+ struct aub_decode_urb_stage_state urb_stages[AUB_DECODE_N_STAGE];
+
+ AubinatorViewerUrb urb_view;
+};
+
struct batch_window {
struct window base;
@@ -396,6 +406,61 @@ new_shader_window(struct aub_mem *mem, uint64_t address, const char *desc)
return window;
}
+/* URB windows */
+
+static void
+display_urb_window(struct window *win)
+{
+ struct urb_window *window = (struct urb_window *) win;
+ static const char *stages[] = {
+ [AUB_DECODE_STAGE_VS] = "VS",
+ [AUB_DECODE_STAGE_HS] = "HS",
+ [AUB_DECODE_STAGE_DS] = "DS",
+ [AUB_DECODE_STAGE_GS] = "GS",
+ [AUB_DECODE_STAGE_PS] = "PS",
+ [AUB_DECODE_STAGE_CS] = "CS",
+ };
+
+ ImGui::Text("URB allocation:");
+ window->urb_view.DrawAllocation("##urb",
+ ARRAY_SIZE(window->urb_stages),
+ window->end_urb_offset,
+ stages,
+ &window->urb_stages[0]);
+}
+
+static void
+destroy_urb_window(struct window *win)
+{
+ struct urb_window *window = (struct urb_window *) win;
+
+ free(window);
+}
+
+static struct urb_window *
+new_urb_window(struct aub_viewer_decode_ctx *decode_ctx, uint64_t address)
+{
+ struct urb_window *window = xtzalloc(*window);
+
+ snprintf(window->base.name, sizeof(window->base.name),
+ "URB view (0x%lx)##%p", address, window);
+
+ list_inithead(&window->base.parent_link);
+ window->base.position = ImVec2(-1, -1);
+ window->base.size = ImVec2(700, 300);
+ window->base.opened = true;
+ window->base.display = display_urb_window;
+ window->base.destroy = destroy_urb_window;
+
+ window->end_urb_offset = decode_ctx->end_urb_offset;
+ memcpy(window->urb_stages, decode_ctx->urb_stages, sizeof(window->urb_stages));
+ window->urb_view = AubinatorViewerUrb();
+
+ list_addtail(&window->base.link, &context.windows);
+
+ return window;
+}
+
/* Memory editor windows */
static uint8_t
@@ -589,6 +654,15 @@ batch_display_shader(void *user_data, const char *shader_desc, uint64_t address)
}
static void
+batch_display_urb(void *user_data, const struct aub_decode_urb_stage_state *stages)
+{
+ struct batch_window *window = (struct batch_window *) user_data;
+ struct urb_window *urb_window = new_urb_window(&window->decode_ctx, 0);
+
+ list_add(&urb_window->base.parent_link, &window->base.children_windows);
+}
+
+static void
batch_edit_address(void *user_data, uint64_t address, uint32_t len)
{
struct batch_window *window = (struct batch_window *) user_data;
@@ -747,6 +821,7 @@ new_batch_window(int exec_idx)
NULL,
window);
window->decode_ctx.display_shader = batch_display_shader;
+ window->decode_ctx.display_urb = batch_display_urb;
window->decode_ctx.edit_address = batch_edit_address;
update_batch_window(window, false, exec_idx);
diff --git a/src/intel/tools/aubinator_viewer_urb.h b/src/intel/tools/aubinator_viewer_urb.h
new file mode 100644
index 00000000000..ef7412e540c
--- /dev/null
+++ b/src/intel/tools/aubinator_viewer_urb.h
@@ -0,0 +1,96 @@
+#ifndef AUBINATOR_VIEWER_URB_H
+#define AUBINATOR_VIEWER_URB_H
+
+#include "aubinator_viewer.h"
+
+#include "imgui.h"
+
+struct AubinatorViewerUrb {
+
+ float RowHeight;
+
+ AubinatorViewerUrb() {
+ RowHeight = 10.0f;
+ }
+
+ bool _Hovered(const ImVec2& mouse, bool window_hovered,
+ const ImVec2& tl, const ImVec2& br) {
+ return window_hovered &&
+ tl.x <= mouse.x && tl.y <= mouse.y &&
+ br.x > mouse.x && br.y > mouse.y;
+ }
+
+ void DrawAllocation(const char *label,
+ int n_stages,
+ int end_urb_offset,
+ const char *stage_names[],
+ const struct aub_decode_urb_stage_state *stages) {
+ const ImVec2 label_size = ImGui::CalcTextSize("VS entry: ", NULL, true);
+ ImVec2 graph_size(ImGui::CalcItemWidth(), 2 * n_stages * label_size.y);
+
+ ImGui::BeginChild(label, ImVec2(0, graph_size.y), false);
+
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+
+ const float row_height = MAX2(RowHeight, label_size.y);
+ const float width = ImGui::GetContentRegionAvailWidth() - label_size.x;
+ const float alloc_delta = width / end_urb_offset;
+ const ImVec2 window_pos = ImGui::GetWindowPos();
+ const ImVec2 mouse_pos = ImGui::GetMousePos();
+ const bool window_hovered = ImGui::IsWindowHovered();
+
+ int const_idx = 0;
+ for (int s = 0; s < n_stages; s++) {
+ const float x = window_pos.x + label_size.x;
+ const float y = window_pos.y + s * row_height;
+
+ ImVec2 alloc_pos(window_pos.x, y);
+ ImVec2 alloc_tl(x + stages[s].start * alloc_delta, y);
+ ImVec2 alloc_br(x + (stages[s].start +
+ stages[s].n_entries * stages[s].size) * alloc_delta,
+ y + row_height);
+ ImVec2 const_tl(x + const_idx * alloc_delta, y);
+ ImVec2 const_br(x + (const_idx + stages[s].const_rd_length) * alloc_delta,
+ y + row_height);
+
+ char label[40];
+ snprintf(label, sizeof(label), "%s: ", stage_names[s]);
+ draw_list->AddText(alloc_pos, ImGui::GetColorU32(ImGuiCol_Text), label);
+
+ float r, g, b;
+ bool hovered;
+
+ /* URB allocation */
+ hovered = _Hovered(mouse_pos, window_hovered, alloc_tl, alloc_br);
+ ImGui::ColorConvertHSVtoRGB((2 * s) * 1.0f / (2 * n_stages),
+ 1.0f, hovered ? 1.0f : 0.8f,
+ r, g, b);
+ draw_list->AddRectFilled(alloc_tl, alloc_br, ImColor(r, g, b));
+ if (hovered) {
+ ImGui::SetTooltip("%s: start=%u end=%u",
+ stage_names[s],
+ stages[s].start,
+ stages[s].start + stages[s].n_entries * stages[s].size);
+ }
+
+ /* Constant URB input */
+ hovered = _Hovered(mouse_pos, window_hovered, const_tl, const_br);
+ ImGui::ColorConvertHSVtoRGB((2 * s + 1) * 1.0f / (2 * n_stages),
+ 1.0f, hovered ? 1.0f : 0.8f,
+ r, g, b);
+ draw_list->AddRectFilled(const_tl, const_br, ImColor(r, g, b));
+ if (hovered) {
+ ImGui::SetTooltip("%s constant: start=%u end=%u",
+ stage_names[s],
+ stages[s].rd_offset,
+ stages[s].rd_offset + stages[s].rd_length);
+ }
+
+ const_idx += stages[s].const_rd_length;
+ }
+
+ ImGui::EndChild();
+ }
+};
+
+#endif /* AUBINATOR_VIEWER_URB_H */