summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/glthread.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-06-21 20:45:38 +0200
committerMarek Olšák <[email protected]>2017-06-26 02:17:03 +0200
commit5fa69be3c8894a6f313080c3afec7063d5356395 (patch)
treea90448a576095e0102b7d04452ffb41da9075789 /src/mesa/main/glthread.c
parent833f3c1c31b1c4dc7742d83eb2db63dcc9b42e1b (diff)
mesa/glthread: add glthread "perf" counters and pass them to gallium HUD
for HUD integration in following commits. This valuable profiling data will allow us to see on the HUD how well glthread is able to utilize parallelism. This is better than benchmarking, because you can see exactly what's happening and you don't have to be CPU-bound. u_threaded_context has the same counters. Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/glthread.c')
-rw-r--r--src/mesa/main/glthread.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index d467298b639..c71c03778aa 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -36,6 +36,7 @@
#include "main/glthread.h"
#include "main/marshal.h"
#include "main/marshal_generated.h"
+#include "util/u_atomic.h"
#include "util/u_thread.h"
@@ -60,7 +61,7 @@ glthread_thread_initialization(void *job, int thread_index)
{
struct gl_context *ctx = (struct gl_context*)job;
- ctx->Driver.SetBackgroundContext(ctx);
+ ctx->Driver.SetBackgroundContext(ctx, &ctx->GLThread->stats);
_glapi_set_context(ctx);
}
@@ -90,6 +91,7 @@ _mesa_glthread_init(struct gl_context *ctx)
util_queue_fence_init(&glthread->batches[i].fence);
}
+ glthread->stats.queue = &glthread->queue;
ctx->CurrentClientDispatch = ctx->MarshalExec;
ctx->GLThread = glthread;
@@ -159,6 +161,8 @@ _mesa_glthread_flush_batch(struct gl_context *ctx)
return;
}
+ p_atomic_add(&glthread->stats.num_offloaded_items, next->used);
+
util_queue_add_job(&glthread->queue, next, &next->fence,
glthread_unmarshal_batch, NULL);
glthread->last = glthread->next;
@@ -188,16 +192,29 @@ _mesa_glthread_finish(struct gl_context *ctx)
struct glthread_batch *last = &glthread->batches[glthread->last];
struct glthread_batch *next = &glthread->batches[glthread->next];
+ bool synced = false;
- if (!util_queue_fence_is_signalled(&last->fence))
+ if (!util_queue_fence_is_signalled(&last->fence)) {
util_queue_fence_wait(&last->fence);
+ synced = true;
+ }
if (next->used) {
+ p_atomic_add(&glthread->stats.num_direct_items, next->used);
+
/* Since glthread_unmarshal_batch changes the dispatch to direct,
* restore it after it's done.
*/
struct _glapi_table *dispatch = _glapi_get_dispatch();
glthread_unmarshal_batch(next, 0);
_glapi_set_dispatch(dispatch);
+
+ /* It's not a sync because we don't enqueue partial batches, but
+ * it would be a sync if we did. So count it anyway.
+ */
+ synced = true;
}
+
+ if (synced)
+ p_atomic_inc(&glthread->stats.num_syncs);
}