summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-23 18:02:37 +0200
committerwm4 <wm4@nowhere>2016-05-23 21:27:18 +0200
commit80d702dce8469928012b9a709805a76274cd0256 (patch)
treeff0be1fb603572b41fe5bd74a672ae72ac004ecc /video/out/opengl/video.c
parentafcef4c25b8dabff92716c3995e26068362bc3aa (diff)
downloadmpv-80d702dce8469928012b9a709805a76274cd0256.tar.bz2
mpv-80d702dce8469928012b9a709805a76274cd0256.tar.xz
vo_opengl: make PBOs work on GLES 3.x
For some reason, GLES has no glMapBuffer, only glMapBufferRange. GLES 2 has no buffer mapping at all, and GL 2.1 does not always have glMapBufferRange. On those PBOs remain unsupported (there's no reason to care about GL 2.1 without the extension). This doesn't actually work on ANGLE, and I have no idea why. (There are artifacts on OSD, as if parts of the OSD data weren't copied.) It works on desktop OpenGL and at least 1 other ES 3 implementation. Don't enable it on ANGLE, I guess.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index bebe1373d6..edf7c7d1f6 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -2870,15 +2870,17 @@ static bool map_image(struct gl_video *p, struct mp_image *mpi)
for (int n = 0; n < p->plane_count; n++) {
struct texplane *plane = &vimg->planes[n];
mpi->stride[n] = mp_image_plane_w(mpi, n) * p->image_desc.bytes[n];
+ size_t buffer_size = mp_image_plane_h(mpi, n) * mpi->stride[n];
if (!plane->gl_buffer) {
gl->GenBuffers(1, &plane->gl_buffer);
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, plane->gl_buffer);
- size_t buffer_size = mp_image_plane_h(mpi, n) * mpi->stride[n];
gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size,
NULL, GL_DYNAMIC_DRAW);
}
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, plane->gl_buffer);
- mpi->planes[n] = gl->MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ mpi->planes[n] = gl->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
+ buffer_size, GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_BUFFER_BIT);
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
if (!mpi->planes[n]) {
unmap_image(p, mpi);
@@ -3042,9 +3044,9 @@ static void check_gl_features(struct gl_video *p)
}
}
- if (gl->es && p->opts.pbo) {
+ if (!gl->MapBufferRange && p->opts.pbo) {
p->opts.pbo = 0;
- MP_WARN(p, "Disabling PBOs (GLES unsupported).\n");
+ MP_WARN(p, "Disabling PBOs (GL2.1/GLES2 unsupported).\n");
}
p->forced_dumb_mode = p->opts.dumb_mode || !have_fbo || !have_texrg;