summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-03 16:31:38 +0200
committerwm4 <wm4@nowhere>2016-07-03 16:34:32 +0200
commitb57debe5b3c8c85f14c1d7f895e61d4f4f26dcc4 (patch)
treef4a250de72339e0581aeca4c90de4dc19a3ac693
parent8c7f9dc1a89e90e44b2b7dfb13fa899ad52352ee (diff)
downloadmpv-b57debe5b3c8c85f14c1d7f895e61d4f4f26dcc4.tar.bz2
mpv-b57debe5b3c8c85f14c1d7f895e61d4f4f26dcc4.tar.xz
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.
-rw-r--r--video/out/opengl/utils.c17
-rw-r--r--video/out/opengl/utils.h3
2 files changed, 13 insertions, 7 deletions
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;
};