Mesa (main): tu,freedreno: Refactored START/STOP events for pipeline stats

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 8 08:40:22 UTC 2022


Module: Mesa
Branch: main
Commit: 465e7c303be9f2b767ceb80599ebe80184e8fa7a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=465e7c303be9f2b767ceb80599ebe80184e8fa7a

Author: Danylo Piliaiev <dpiliaiev at igalia.com>
Date:   Tue Jun 21 14:37:00 2022 +0300

tu,freedreno: Refactored START/STOP events for pipeline stats

For a5xx+ renamed:
- RST_PIX_CNT -> START_FRAGMENT_CTRS
- RST_VTX_CNT -> STOP_FRAGMENT_CTRS
- TILE_FLUSH  -> START_COMPUTE_CTRS
- STAT_EVENT  -> STOP_COMPUTE_CTRS
I'm not sure about a5xx itself but I'll take a chance of it being
similar to a6xx in this regard.

Knowing this emit_begin_stat_query/emit_end_stat_query can now emit
only events that are needed for the pool's flags.

Also primitive generated query clearly doesn't need fragment and
compute counters.

Passes tests:
 dEQP-VK.query_pool.statistics_query.*
 dEQP-VK.transform_feedback.primitives_generated_query.*

Signed-off-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17163>

---

 src/freedreno/registers/adreno/adreno_pm4.xml | 13 ++++--
 src/freedreno/vulkan/tu_query.c               | 61 ++++++++++++++++++++++-----
 2 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/src/freedreno/registers/adreno/adreno_pm4.xml b/src/freedreno/registers/adreno/adreno_pm4.xml
index 5926a4c515d..54f0665faa0 100644
--- a/src/freedreno/registers/adreno/adreno_pm4.xml
+++ b/src/freedreno/registers/adreno/adreno_pm4.xml
@@ -18,10 +18,11 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 	<value name="WRITE_PRIMITIVE_COUNTS" value="9" varset="chip" variants="A6XX"/>
 	<value name="START_PRIMITIVE_CTRS" value="11" varset="chip" variants="A6XX"/>
 	<value name="STOP_PRIMITIVE_CTRS" value="12" varset="chip" variants="A6XX"/>
-	<value name="RST_PIX_CNT" value="13"/>
-	<value name="RST_VTX_CNT" value="14"/>
-	<value name="TILE_FLUSH" value="15"/>
-	<value name="STAT_EVENT" value="16"/>
+	<!-- Not sure that these 4 events don't have the same meaning as on A5XX+ -->
+	<value name="RST_PIX_CNT" value="13" varset="chip" variants="A2XX-A4XX"/>
+	<value name="RST_VTX_CNT" value="14" varset="chip" variants="A2XX-A4XX"/>
+	<value name="TILE_FLUSH" value="15" varset="chip" variants="A2XX-A4XX"/>
+	<value name="STAT_EVENT" value="16" varset="chip" variants="A2XX-A4XX"/>
 	<value name="CACHE_FLUSH_AND_INV_TS_EVENT" value="20" varset="chip" variants="A2XX-A4XX"/>
 	<value name="ZPASS_DONE" value="21"/>
 	<value name="CACHE_FLUSH_AND_INV_EVENT" value="22" varset="chip" variants="A2XX"/>
@@ -33,6 +34,10 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
 
 	<!-- a5xx events -->
 	<value name="WT_DONE_TS" value="8" varset="chip" variants="A5XX-"/>
+	<value name="START_FRAGMENT_CTRS" value="13" varset="chip" variants="A5XX-"/>
+	<value name="STOP_FRAGMENT_CTRS" value="14" varset="chip" variants="A5XX-"/>
+	<value name="START_COMPUTE_CTRS" value="15" varset="chip" variants="A5XX-"/>
+	<value name="STOP_COMPUTE_CTRS" value="16" varset="chip" variants="A5XX-"/>
 	<value name="FLUSH_SO_0" value="17" varset="chip" variants="A5XX-"/>
 	<value name="FLUSH_SO_1" value="18" varset="chip" variants="A5XX-"/>
 	<value name="FLUSH_SO_2" value="19" varset="chip" variants="A5XX-"/>
diff --git a/src/freedreno/vulkan/tu_query.c b/src/freedreno/vulkan/tu_query.c
index 18b8fec966e..20d5ee40294 100644
--- a/src/freedreno/vulkan/tu_query.c
+++ b/src/freedreno/vulkan/tu_query.c
@@ -425,6 +425,35 @@ statistics_index(uint32_t *statistics)
    }
 }
 
+static bool
+is_pipeline_query_with_vertex_stage(struct tu_query_pool *pool)
+{
+   return pool->pipeline_statistics &
+          (VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT |
+           VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT);
+}
+
+static bool
+is_pipeline_query_with_fragment_stage(struct tu_query_pool *pool)
+{
+   return pool->pipeline_statistics &
+          VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT;
+}
+
+static bool
+is_pipeline_query_with_compute_stage(struct tu_query_pool *pool)
+{
+   return pool->pipeline_statistics &
+          VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
+}
+
 /* Wait on the the availability status of a query up until a timeout. */
 static VkResult
 wait_for_available(struct tu_device *device, struct tu_query_pool *pool,
@@ -842,9 +871,17 @@ emit_begin_stat_query(struct tu_cmd_buffer *cmdbuf,
    struct tu_cs *cs = cmdbuf->state.pass ? &cmdbuf->draw_cs : &cmdbuf->cs;
    uint64_t begin_iova = pipeline_stat_query_iova(pool, query, begin);
 
-   tu6_emit_event_write(cmdbuf, cs, START_PRIMITIVE_CTRS);
-   tu6_emit_event_write(cmdbuf, cs, RST_PIX_CNT);
-   tu6_emit_event_write(cmdbuf, cs, TILE_FLUSH);
+   if (is_pipeline_query_with_vertex_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, START_PRIMITIVE_CTRS);
+   }
+
+   if (is_pipeline_query_with_fragment_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, START_FRAGMENT_CTRS);
+   }
+
+   if (is_pipeline_query_with_compute_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, START_COMPUTE_CTRS);
+   }
 
    tu_cs_emit_wfi(cs);
 
@@ -972,8 +1009,6 @@ emit_begin_prim_generated_query(struct tu_cmd_buffer *cmdbuf,
    }
 
    tu6_emit_event_write(cmdbuf, cs, START_PRIMITIVE_CTRS);
-   tu6_emit_event_write(cmdbuf, cs, RST_PIX_CNT);
-   tu6_emit_event_write(cmdbuf, cs, TILE_FLUSH);
 
    tu_cs_emit_wfi(cs);
 
@@ -1129,9 +1164,17 @@ emit_end_stat_query(struct tu_cmd_buffer *cmdbuf,
    uint64_t stat_start_iova;
    uint64_t stat_stop_iova;
 
-   tu6_emit_event_write(cmdbuf, cs, STOP_PRIMITIVE_CTRS);
-   tu6_emit_event_write(cmdbuf, cs, RST_VTX_CNT);
-   tu6_emit_event_write(cmdbuf, cs, STAT_EVENT);
+   if (is_pipeline_query_with_vertex_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, STOP_PRIMITIVE_CTRS);
+   }
+
+   if (is_pipeline_query_with_fragment_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, STOP_FRAGMENT_CTRS);
+   }
+
+   if (is_pipeline_query_with_compute_stage(pool)) {
+      tu6_emit_event_write(cmdbuf, cs, STOP_COMPUTE_CTRS);
+   }
 
    tu_cs_emit_wfi(cs);
 
@@ -1313,8 +1356,6 @@ emit_end_prim_generated_query(struct tu_cmd_buffer *cmdbuf,
    uint64_t available_iova = query_available_iova(pool, query);
 
    tu6_emit_event_write(cmdbuf, cs, STOP_PRIMITIVE_CTRS);
-   tu6_emit_event_write(cmdbuf, cs, RST_VTX_CNT);
-   tu6_emit_event_write(cmdbuf, cs, STAT_EVENT);
 
    tu_cs_emit_wfi(cs);
 



More information about the mesa-commit mailing list