Mesa (main): d3d12: Don't accumulate timestamp queries

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 5 00:54:54 UTC 2021


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Fri Sep 17 18:53:02 2021 -0700

d3d12: Don't accumulate timestamp queries

If an app re-issues a timestamp query a lot, but doesn't ever ask
for the results, we could end up running off the end of our query
heap. But we don't actually need to advance/accumulate, so just
use a single entry in the heap.

Reviewed By: Bill Kristiansen <billkris at microsoft.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12920>

---

 src/gallium/drivers/d3d12/d3d12_query.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_query.cpp b/src/gallium/drivers/d3d12/d3d12_query.cpp
index 0463d13f856..8cc8b723b2c 100644
--- a/src/gallium/drivers/d3d12/d3d12_query.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_query.cpp
@@ -117,9 +117,12 @@ d3d12_create_query(struct pipe_context *pctx,
    query->num_queries = 16;
 
    /* With timer queries we want a few more queries, especially since we need two slots
-    * per query for TIME_ELAPSED queries */
-   if (unlikely(query->d3d12qtype == D3D12_QUERY_TYPE_TIMESTAMP))
+    * per query for TIME_ELAPSED queries
+    * For TIMESTAMP, we don't need more than one slot, since there's nothing to accumulate */
+   if (unlikely(query_type == PIPE_QUERY_TIME_ELAPSED))
       query->num_queries = 64;
+   else if (query_type == PIPE_QUERY_TIMESTAMP)
+      query->num_queries = 1;
 
    query->curr_query = 0;
 
@@ -357,6 +360,10 @@ end_query(struct d3d12_context *ctx, struct d3d12_query *q)
    if (q->subquery)
       end_query(ctx, q->subquery);
 
+   /* For TIMESTAMP, there's only one slot */
+   if (q->type == PIPE_QUERY_TIMESTAMP)
+      q->curr_query = 0;
+
    /* With QUERY_TIME_ELAPSED we have recorded one value at
     * (2 * q->curr_query), and now we record a value at (2 * q->curr_query + 1)
     * and when resolving the query we subtract the latter from the former */



More information about the mesa-commit mailing list