summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/ra_gl.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-05 13:39:20 +0200
committerwm4 <wm4@nowhere>2017-08-05 13:44:30 +0200
commitdd096863fa00f1c0c9268932a46ddc321122f552 (patch)
tree49956dd4bcd2a0d12e298107f7aeeff7a61e28e4 /video/out/opengl/ra_gl.c
parent8dd4ae13ffd5ff11b97b84bbb4fdfe6185eeeb50 (diff)
downloadmpv-dd096863fa00f1c0c9268932a46ddc321122f552.tar.bz2
mpv-dd096863fa00f1c0c9268932a46ddc321122f552.tar.xz
vo_opengl: make OSD code use ra for textures
This requires a silly extension to ra_fns.tex_upload: since the OSD texture can be much larger than the actual OSD image data to upload, a mechanism for uploading only to a small part of the texture is needed. Otherwise, we'd have to realloc/copy the data, just to pad it, and then pay for uploading the padding too. The RA_TEX_UPLOAD_DISCARD flag is not interpreted by GL (not sure how you'd tell GL about this), but it clarifies the API and might be helpful if we support other backend APIs in the future.
Diffstat (limited to 'video/out/opengl/ra_gl.c')
-rw-r--r--video/out/opengl/ra_gl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c
index 62d16cbdbc..411adddec6 100644
--- a/video/out/opengl/ra_gl.c
+++ b/video/out/opengl/ra_gl.c
@@ -88,6 +88,10 @@ int ra_init_gl(struct ra *ra, GL *gl)
MP_TARRAY_APPEND(ra, ra->formats, ra->num_formats, fmt);
}
+ GLint max_wh;
+ gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_wh);
+ ra->max_texture_wh = max_wh;
+
gl->Disable(GL_DITHER);
return 0;
@@ -307,13 +311,15 @@ struct ra_tex *ra_create_wrapped_fb(struct ra *ra, GLuint gl_fbo, int w, int h)
}
static void gl_tex_upload(struct ra *ra, struct ra_tex *tex,
- const void *src, ptrdiff_t stride,
- struct ra_mapped_buffer *buf)
+ const void *src, ptrdiff_t stride,
+ struct mp_rect *rc, uint64_t flags,
+ struct ra_mapped_buffer *buf)
{
struct ra_gl *p = ra->priv;
GL *gl = p->gl;
struct ra_tex_gl *tex_gl = tex->priv;
struct ra_mapped_buffer_gl *buf_gl = NULL;
+ struct mp_rect full = {0, 0, tex->params.w, tex->params.h};
if (buf) {
buf_gl = buf->priv;
@@ -325,16 +331,20 @@ static void gl_tex_upload(struct ra *ra, struct ra_tex *tex,
switch (tex->params.dimensions) {
case 1:
+ assert(!rc);
gl->TexImage1D(tex_gl->target, 0, tex_gl->internal_format,
tex->params.w, 0, tex_gl->format, tex_gl->type, src);
break;
case 2:
+ if (!rc)
+ rc = &full;
gl_pbo_upload_tex(&tex_gl->pbo, gl, tex->use_pbo && !buf,
tex_gl->target, tex_gl->format, tex_gl->type,
tex->params.w, tex->params.h, src, stride,
- 0, 0, tex->params.w, tex->params.h);
+ rc->x0, rc->y0, rc->x1 - rc->x0, rc->y1 - rc->y0);
break;
case 3:
+ assert(!rc);
gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl->TexImage3D(GL_TEXTURE_3D, 0, tex_gl->internal_format, tex->params.w,
tex->params.h, tex->params.d, 0, tex_gl->format,