From b57debe5b3c8c85f14c1d7f895e61d4f4f26dcc4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Jul 2016 16:31:38 +0200 Subject: vo_opengl: use ringbuffer of PBOs This is how PBOs are normally supposed to be used. Unfortunately I can't see an any absolute improvement on nVidia binary drivers and playing 4K material. Compared to the "old" PBO path with 1 buffer, the measured GL time decreases significantly, though. --- video/out/opengl/utils.c | 17 +++++++++++------ video/out/opengl/utils.h | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'video') diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index b47da6b1da..72a748a82d 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -1152,15 +1152,20 @@ void gl_pbo_upload_tex(struct gl_pbo_upload *pbo, GL *gl, bool use_pbo, if (buffer_size != pbo->buffer_size) gl_pbo_upload_uninit(pbo); - if (!pbo->buffer) { + if (!pbo->buffers[0]) { pbo->gl = gl; pbo->buffer_size = buffer_size; - gl->GenBuffers(1, &pbo->buffer); - gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffer); - gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL, GL_DYNAMIC_COPY); + gl->GenBuffers(2, &pbo->buffers[0]); + for (int n = 0; n < 2; n++) { + gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[n]); + gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL, + GL_DYNAMIC_COPY); + } } - gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffer); + pbo->index = (pbo->index + 1) % 2; + + gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo->buffers[pbo->index]); void *data = gl->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, needed_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); if (!data) @@ -1186,6 +1191,6 @@ no_pbo: void gl_pbo_upload_uninit(struct gl_pbo_upload *pbo) { if (pbo->gl) - pbo->gl->DeleteBuffers(1, &pbo->buffer); + pbo->gl->DeleteBuffers(2, &pbo->buffers[0]); *pbo = (struct gl_pbo_upload){0}; } diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h index 35211f6485..ec54d19b8a 100644 --- a/video/out/opengl/utils.h +++ b/video/out/opengl/utils.h @@ -184,7 +184,8 @@ uint64_t gl_timer_peak_us(struct gl_timer *timer); struct gl_pbo_upload { GL *gl; - GLuint buffer; + int index; + GLuint buffers[2]; size_t buffer_size; }; -- cgit v1.2.3