+static const char *v3d_counter_names[] = {
+ "FEP-valid-primitives-no-rendered-pixels",
+ "FEP-valid-primitives-rendered-pixels",
+ "FEP-clipped-quads",
+ "FEP-valid-quads",
+ "TLB-quads-not-passing-stencil-test",
+ "TLB-quads-not-passing-z-and-stencil-test",
+ "TLB-quads-passing-z-and-stencil-test",
+ "TLB-quads-with-zero-coverage",
+ "TLB-quads-with-non-zero-coverage",
+ "TLB-quads-written-to-color-buffer",
+ "PTB-primitives-discarded-outside-viewport",
+ "PTB-primitives-need-clipping",
+ "PTB-primitives-discared-reversed",
+ "QPU-total-idle-clk-cycles",
+ "QPU-total-clk-cycles-vertex-coord-shading",
+ "QPU-total-clk-cycles-fragment-shading",
+ "QPU-total-clk-cycles-executing-valid-instr",
+ "QPU-total-clk-cycles-waiting-TMU",
+ "QPU-total-clk-cycles-waiting-scoreboard",
+ "QPU-total-clk-cycles-waiting-varyings",
+ "QPU-total-instr-cache-hit",
+ "QPU-total-instr-cache-miss",
+ "QPU-total-uniform-cache-hit",
+ "QPU-total-uniform-cache-miss",
+ "TMU-total-text-quads-processed",
+ "TMU-total-text-cache-miss",
+ "VPM-total-clk-cycles-VDW-stalled",
+ "VPM-total-clk-cycles-VCD-stalled",
+ "L2C-total-cache-hit",
+ "L2C-total-cache-miss",
+};
+
+int vc4_get_driver_query_group_info(struct pipe_screen *pscreen,
+ unsigned index,
+ struct pipe_driver_query_group_info *info)
+{
+ struct vc4_screen *screen = vc4_screen(pscreen);
+
+ if (!screen->has_perfmon_ioctl)
+ return 0;
+
+ if (!info)
+ return 1;
+
+ if (index > 0)
+ return 0;
+
+ info->name = "V3D counters";
+ info->max_active_queries = DRM_VC4_MAX_PERF_COUNTERS;
+ info->num_queries = ARRAY_SIZE(v3d_counter_names);
+ return 1;
+}
+
+int vc4_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
+ struct pipe_driver_query_info *info)
+{
+ struct vc4_screen *screen = vc4_screen(pscreen);
+
+ if (!screen->has_perfmon_ioctl)
+ return 0;
+
+ if (!info)
+ return ARRAY_SIZE(v3d_counter_names);
+
+ if (index >= ARRAY_SIZE(v3d_counter_names))
+ return 0;
+
+ info->group_id = 0;
+ info->name = v3d_counter_names[index];
+ info->query_type = PIPE_QUERY_DRIVER_SPECIFIC + index;
+ info->result_type = PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE;
+ info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
+ info->flags = PIPE_DRIVER_QUERY_FLAG_BATCH;
+ return 1;
+}
+