summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/osd.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/osd.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/osd.c')
-rw-r--r--video/out/opengl/osd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/opengl/osd.c b/video/out/opengl/osd.c
index bf03d34e90..d8059166be 100644
--- a/video/out/opengl/osd.c
+++ b/video/out/opengl/osd.c
@@ -139,18 +139,19 @@ static bool upload_pbo(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
GL *gl = ctx->gl;
bool success = true;
const struct gl_format *fmt = ctx->fmt_table[imgs->format];
- int pix_stride = gl_bytes_per_pixel(fmt->format, fmt->type);
+ size_t pix_stride = gl_bytes_per_pixel(fmt->format, fmt->type);
+ size_t buffer_size = pix_stride * osd->h * osd->w;
if (!osd->buffer) {
gl->GenBuffers(1, &osd->buffer);
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, osd->buffer);
- gl->BufferData(GL_PIXEL_UNPACK_BUFFER, osd->w * osd->h * pix_stride,
- NULL, GL_DYNAMIC_COPY);
+ gl->BufferData(GL_PIXEL_UNPACK_BUFFER, buffer_size, NULL, GL_DYNAMIC_COPY);
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, osd->buffer);
- char *data = gl->MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+ char *data = gl->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, buffer_size,
+ GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
if (!data) {
success = false;
} else {