summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/gl_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl/gl_utils.c')
-rw-r--r--video/out/opengl/gl_utils.c119
1 files changed, 0 insertions, 119 deletions
diff --git a/video/out/opengl/gl_utils.c b/video/out/opengl/gl_utils.c
index df6f0543ad..e042b56b4a 100644
--- a/video/out/opengl/gl_utils.c
+++ b/video/out/opengl/gl_utils.c
@@ -282,125 +282,6 @@ void gl_set_debug_logger(GL *gl, struct mp_log *log)
gl->DebugMessageCallback(log ? gl_debug_cb : NULL, log);
}
-// Maximum number of simultaneous query objects to keep around. Reducing this
-// number might cause rendering to block until the result of a previous query is
-// available
-#define QUERY_OBJECT_NUM 8
-
-struct gl_timer {
- GL *gl;
- GLuint query[QUERY_OBJECT_NUM];
- int query_idx;
-
- // these numbers are all in nanoseconds
- uint64_t samples[PERF_SAMPLE_COUNT];
- int sample_idx;
- int sample_count;
-
- uint64_t avg_sum;
- uint64_t peak;
-};
-
-struct mp_pass_perf gl_timer_measure(struct gl_timer *timer)
-{
- assert(timer);
- struct mp_pass_perf res = {
- .count = timer->sample_count,
- .index = (timer->sample_idx - timer->sample_count) % PERF_SAMPLE_COUNT,
- .peak = timer->peak,
- .samples = timer->samples,
- };
-
- res.last = timer->samples[(timer->sample_idx - 1) % PERF_SAMPLE_COUNT];
-
- if (timer->sample_count > 0) {
- res.avg = timer->avg_sum / timer->sample_count;
- }
-
- return res;
-}
-
-struct gl_timer *gl_timer_create(GL *gl)
-{
- struct gl_timer *timer = talloc_ptrtype(NULL, timer);
- *timer = (struct gl_timer){ .gl = gl };
-
- if (gl->GenQueries)
- gl->GenQueries(QUERY_OBJECT_NUM, timer->query);
-
- return timer;
-}
-
-void gl_timer_free(struct gl_timer *timer)
-{
- if (!timer)
- return;
-
- GL *gl = timer->gl;
- if (gl && gl->DeleteQueries) {
- // this is a no-op on already uninitialized queries
- gl->DeleteQueries(QUERY_OBJECT_NUM, timer->query);
- }
-
- talloc_free(timer);
-}
-
-static void gl_timer_record(struct gl_timer *timer, GLuint64 new)
-{
- // Input res into the buffer and grab the previous value
- uint64_t old = timer->samples[timer->sample_idx];
- timer->samples[timer->sample_idx++] = new;
- timer->sample_idx %= PERF_SAMPLE_COUNT;
-
- // Update average and sum
- timer->avg_sum = timer->avg_sum + new - old;
- timer->sample_count = MPMIN(timer->sample_count + 1, PERF_SAMPLE_COUNT);
-
- // Update peak if necessary
- if (new >= timer->peak) {
- timer->peak = new;
- } else if (timer->peak == old) {
- // It's possible that the last peak was the value we just removed,
- // if so we need to scan for the new peak
- uint64_t peak = new;
- for (int i = 0; i < PERF_SAMPLE_COUNT; i++)
- peak = MPMAX(peak, timer->samples[i]);
- timer->peak = peak;
- }
-}
-
-// If no free query is available, this can block. Shouldn't ever happen in
-// practice, though. (If it does, consider increasing QUERY_OBJECT_NUM)
-// IMPORTANT: only one gl_timer object may ever be active at a single time.
-// The caling code *MUST* ensure this
-void gl_timer_start(struct gl_timer *timer)
-{
- assert(timer);
- GL *gl = timer->gl;
- if (!gl->BeginQuery)
- return;
-
- // Get the next query object
- GLuint id = timer->query[timer->query_idx++];
- timer->query_idx %= QUERY_OBJECT_NUM;
-
- // If this query object already holds a result, we need to get and
- // record it first
- if (gl->IsQuery(id)) {
- GLuint64 elapsed;
- gl->GetQueryObjectui64v(id, GL_QUERY_RESULT, &elapsed);
- gl_timer_record(timer, elapsed);
- }
-
- gl->BeginQuery(GL_TIME_ELAPSED, id);
-}
-
-void gl_timer_stop(GL *gl)
-{
- if (gl->EndQuery)
- gl->EndQuery(GL_TIME_ELAPSED);
-}
-
// Upload a texture, going through a PBO. PBO supposedly can facilitate
// asynchronous copy from CPU to GPU, so this is an optimization. Note that
// changing format/type/tex_w/tex_h or reusing the PBO in the same frame can