Path: blob/21.2-virgl/src/intel/tools/aubinator_viewer_urb.h
4547 views
#ifndef AUBINATOR_VIEWER_URB_H1#define AUBINATOR_VIEWER_URB_H23#include "aubinator_viewer.h"45#include "imgui/imgui.h"67struct AubinatorViewerUrb {89float RowHeight;1011AubinatorViewerUrb() {12RowHeight = 10.0f;13}1415bool _Hovered(const ImVec2& mouse, bool window_hovered,16const ImVec2& tl, const ImVec2& br) {17return window_hovered &&18tl.x <= mouse.x && tl.y <= mouse.y &&19br.x > mouse.x && br.y > mouse.y;20}2122void DrawAllocation(const char *label,23int n_stages,24int end_urb_offset,25const char *stage_names[],26const struct aub_decode_urb_stage_state *stages) {27const ImVec2 label_size = ImGui::CalcTextSize("VS entry: ", NULL, true);28ImVec2 graph_size(ImGui::CalcItemWidth(), 2 * n_stages * label_size.y);2930ImGui::BeginChild(label, ImVec2(0, graph_size.y), false);3132ImDrawList* draw_list = ImGui::GetWindowDrawList();3334const float row_height = MAX2(RowHeight, label_size.y);35const float width = ImGui::GetContentRegionAvailWidth() - label_size.x;36const float alloc_delta = width / end_urb_offset;37const ImVec2 window_pos = ImGui::GetWindowPos();38const ImVec2 mouse_pos = ImGui::GetMousePos();39const bool window_hovered = ImGui::IsWindowHovered();4041int const_idx = 0;42for (int s = 0; s < n_stages; s++) {43const float x = window_pos.x + label_size.x;44const float y = window_pos.y + s * row_height;4546ImVec2 alloc_pos(window_pos.x, y);47ImVec2 alloc_tl(x + stages[s].start * alloc_delta, y);48ImVec2 alloc_br(x + (stages[s].start +49stages[s].n_entries * stages[s].size) * alloc_delta,50y + row_height);51ImVec2 const_tl(x + const_idx * alloc_delta, y);52ImVec2 const_br(x + (const_idx + stages[s].const_rd_length) * alloc_delta,53y + row_height);5455char label[40];56snprintf(label, sizeof(label), "%s: ", stage_names[s]);57draw_list->AddText(alloc_pos, ImGui::GetColorU32(ImGuiCol_Text), label);5859float r, g, b;60bool hovered;6162/* URB allocation */63hovered = _Hovered(mouse_pos, window_hovered, alloc_tl, alloc_br);64ImGui::ColorConvertHSVtoRGB((2 * s) * 1.0f / (2 * n_stages),651.0f, hovered ? 1.0f : 0.8f,66r, g, b);67draw_list->AddRectFilled(alloc_tl, alloc_br, ImColor(r, g, b));68if (hovered) {69ImGui::SetTooltip("%s: start=%u end=%u",70stage_names[s],71stages[s].start,72stages[s].start + stages[s].n_entries * stages[s].size);73}7475/* Constant URB input */76hovered = _Hovered(mouse_pos, window_hovered, const_tl, const_br);77ImGui::ColorConvertHSVtoRGB((2 * s + 1) * 1.0f / (2 * n_stages),781.0f, hovered ? 1.0f : 0.8f,79r, g, b);80draw_list->AddRectFilled(const_tl, const_br, ImColor(r, g, b));81if (hovered) {82ImGui::SetTooltip("%s constant: start=%u end=%u",83stage_names[s],84stages[s].rd_offset,85stages[s].rd_offset + stages[s].rd_length);86}8788const_idx += stages[s].const_rd_length;89}9091ImGui::EndChild();92}93};9495#endif /* AUBINATOR_VIEWER_URB_H */969798