summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-19 00:58:56 +0100
committerwm4 <wm4@nowhere>2014-12-19 01:21:18 +0100
commitfe35130ba9079c09c74a5f5334584f1ccca15e52 (patch)
tree8e03910ea175b91aa46d12e97ef211b684f1b62a /video/out/gl_video.c
parentde3e26bc846eee938248c9be3a688091f0eab49c (diff)
downloadmpv-fe35130ba9079c09c74a5f5334584f1ccca15e52.tar.bz2
mpv-fe35130ba9079c09c74a5f5334584f1ccca15e52.tar.xz
vo_opengl: mess with PixelStorei state management
This is needed for GLES 2 support. GLES 2 doesn't support GL_UNPACK_ROW_LENGTH, and we shouldn't even use this constant, since a GLES implementation could raise an error. So set it only if neccessary, and leave it in the default state otherwise. This also smuggles in a ES 2 fallback for glUploadTex(), and querying an extension relevant for ES 2. For the alignment state (GL_[UN]PACK_ALIGNMENT) do the same for symmetry. All 4 states (alignment/rows x pack/unpack) are now assumed to be in their initial states by default. Also redo the PixelStorei handling in the function table. I could rebase this, but look at the commit time.
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r--video/out/gl_video.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 5fafcd04f1..8d4682bfe7 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1249,8 +1249,6 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
gl->GenTextures(1, &scaler->gl_lut);
gl->BindTexture(GL_TEXTURE_2D, scaler->gl_lut);
- gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
float *weights = talloc_array(NULL, float, LOOKUP_TEXTURE_SIZE * size);
mp_compute_lut(scaler->kernel, LOOKUP_TEXTURE_SIZE, weights);
@@ -1329,13 +1327,13 @@ static void init_dither(struct gl_video *p)
gl->GenTextures(1, &p->dither_texture);
gl->BindTexture(GL_TEXTURE_2D, p->dither_texture);
gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
gl->TexImage2D(GL_TEXTURE_2D, 0, tex_iformat, tex_size, tex_size, 0,
tex_format, tex_type, tex_data);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
gl->ActiveTexture(GL_TEXTURE0);
debug_check_gl(p, "dither setup");
@@ -1432,8 +1430,6 @@ void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d)
gl->ActiveTexture(GL_TEXTURE0 + TEXUNIT_3DLUT);
gl->BindTexture(GL_TEXTURE_3D, p->lut_3d_texture);
- gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
gl->TexImage3D(GL_TEXTURE_3D, 0, GL_RGB16, lut3d->size[0], lut3d->size[1],
lut3d->size[2], 0, GL_RGB, GL_UNSIGNED_SHORT, lut3d->data);
gl->TexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -2060,8 +2056,6 @@ static bool test_fbo(struct gl_video *p, GLenum format)
GL *gl = p->gl;
bool success = false;
struct fbotex fbo = {0};
- gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
- gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
if (fbotex_init(p, &fbo, 16, 16, format)) {
gl->BindFramebuffer(GL_FRAMEBUFFER, fbo.fbo);
gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -2234,16 +2228,17 @@ void gl_video_set_gl_state(struct gl_video *p)
struct m_color c = p->opts.background;
gl->ClearColor(c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0);
gl->ActiveTexture(GL_TEXTURE0);
+ if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH) {
+ gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
+ gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ }
+ gl->PixelStorei(GL_PACK_ALIGNMENT, 4);
+ gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
void gl_video_unset_gl_state(struct gl_video *p)
{
- GL *gl = p->gl;
-
- gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
- gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- gl->PixelStorei(GL_PACK_ALIGNMENT, 4);
- gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ // nop
}
// dest = src.<w> (always using 4 components)