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

Author: Mike Blumenkrantz <[email protected]>
Date:   Wed Oct  4 10:46:21 2023 -0400

tc: add non-definitive tracking for batch completion

this is useful as a hint for opportunistic optimizations

Acked-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624>

---

 src/gallium/auxiliary/util/u_threaded_context.c | 3 +++
 src/gallium/auxiliary/util/u_threaded_context.h | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
b/src/gallium/auxiliary/util/u_threaded_context.c
index 8a56df81768..5dc6e6be39a 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -474,6 +474,7 @@ tc_batch_execute(void *job, UNUSED void *gdata, int 
thread_index)
    batch->last_mergeable_call = NULL;
    batch->first_set_fb = false;
    batch->max_renderpass_info_idx = 0;
+   batch->tc->last_completed = batch->batch_idx;
 }
 
 static void
@@ -4991,11 +4992,13 @@ threaded_context_create(struct pipe_context *pipe,
    if (!util_queue_init(&tc->queue, "gdrv", TC_MAX_BATCHES - 2, 1, 0, NULL))
       goto fail;
 
+   tc->last_completed = -1;
    for (unsigned i = 0; i < TC_MAX_BATCHES; i++) {
 #if !defined(NDEBUG) && TC_DEBUG >= 1
       tc->batch_slots[i].sentinel = TC_SENTINEL;
 #endif
       tc->batch_slots[i].tc = tc;
+      tc->batch_slots[i].batch_idx = i;
       util_queue_fence_init(&tc->batch_slots[i].fence);
       tc->batch_slots[i].renderpass_info_idx = -1;
       if (tc->options.parse_renderpass_info) {
diff --git a/src/gallium/auxiliary/util/u_threaded_context.h 
b/src/gallium/auxiliary/util/u_threaded_context.h
index 5411da081e6..fe988195813 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.h
+++ b/src/gallium/auxiliary/util/u_threaded_context.h
@@ -504,6 +504,7 @@ struct tc_batch {
    struct util_queue_fence fence;
    /* whether the first set_framebuffer_state call has been seen by this batch 
*/
    bool first_set_fb;
+   uint8_t batch_idx;
    struct tc_unflushed_batch_token *token;
    uint64_t slots[TC_SLOTS_PER_BATCH];
    struct util_dynarray renderpass_infos;
@@ -600,6 +601,8 @@ struct threaded_context {
    bool seen_image_buffers[PIPE_SHADER_TYPES];
    bool seen_sampler_buffers[PIPE_SHADER_TYPES];
 
+   int8_t last_completed;
+
    unsigned max_vertex_buffers;
    unsigned max_const_buffers;
    unsigned max_shader_buffers;

Reply via email to