diff options
author | wm4 <wm4@nowhere> | 2014-12-18 22:24:45 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-18 22:24:45 +0100 |
commit | 1b766ab208d23d272b2f57b4ea02c892dc1dd029 (patch) | |
tree | d6563d2fe8c9ad1532152e334b9db508b608d468 /video | |
parent | 32fb3dae8783800e01e94b561baca306389d64a8 (diff) | |
download | mpv-1b766ab208d23d272b2f57b4ea02c892dc1dd029.tar.bz2 mpv-1b766ab208d23d272b2f57b4ea02c892dc1dd029.tar.xz |
vo_opengl: do not use 4x3 matrix
This was a nice trick to get the mpv colormatrix directly into OpenGL,
because the memory representation happened to match.
Unfortunately, OpenGL ES 2 doesn't have glUniformMatrix4x3fv().
Even more unfortunately, the memory representation is now incompatible.
It would be nice to change it, but that would mean getting into a big
mess.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gl_common.c | 15 | ||||
-rw-r--r-- | video/out/gl_common.h | 2 | ||||
-rw-r--r-- | video/out/gl_video.c | 9 | ||||
-rw-r--r-- | video/out/gl_video_shaders.glsl | 5 |
4 files changed, 15 insertions, 16 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 50864afaf7..bbfbcdcda4 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -202,9 +202,11 @@ static const struct gl_functions gl_functions[] = { {0} }, }, - // GL 2.0-3.x functions + // GL 2.1-3.x functions (also: GLSL 120 shaders) + // All of the listed functions are also in GL 2.0 { - .ver_core = MPGL_VER(2, 0), + .ver_core = MPGL_VER(2, 1), + .provides = MPGL_CAP_GL21, .functions = (const struct gl_function[]) { DEF_FN(GenBuffers), DEF_FN(DeleteBuffers), @@ -245,15 +247,6 @@ static const struct gl_functions gl_functions[] = { {0}, }, }, - // GL 2.1-3.x functions (also: GLSL 120 shaders) - { - .ver_core = MPGL_VER(2, 1), - .provides = MPGL_CAP_GL21, - .functions = (const struct gl_function[]) { - DEF_FN(UniformMatrix4x3fv), - {0} - }, - }, // GL 3.x core only functions. { .ver_core = MPGL_VER(3, 0), diff --git a/video/out/gl_common.h b/video/out/gl_common.h index 999dc5d606..41335e2706 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -310,8 +310,6 @@ struct GL { const GLfloat *); void (GLAPIENTRY *UniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *); - void (GLAPIENTRY *UniformMatrix4x3fv)(GLint, GLsizei, GLboolean, - const GLfloat *); void (GLAPIENTRY *VDPAUInitNV)(const GLvoid *, const GLvoid *); void (GLAPIENTRY *VDPAUFiniNV)(void); diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 126decf4e7..8541559b90 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -632,7 +632,14 @@ static void update_uniforms(struct gl_video *p, GLuint program) } else { mp_get_yuv2rgb_coeffs(&cparams, m); } - gl->UniformMatrix4x3fv(loc, 1, GL_TRUE, &m[0][0]); + float transposed[3][3]; + for (int a = 0; a < 3; a++) { + for (int b = 0; b < 3; b++) + transposed[a][b] = m[b][a]; + } + gl->UniformMatrix3fv(loc, 1, GL_FALSE, &transposed[0][0]); + loc = gl->GetUniformLocation(program, "colormatrix_c"); + gl->Uniform3f(loc, m[0][3], m[1][3], m[2][3]); } gl->Uniform1f(gl->GetUniformLocation(program, "input_gamma"), diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index 322c91fd13..547d5cd621 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -168,7 +168,8 @@ uniform sampler2D lut_c; uniform sampler2D lut_l; uniform sampler3D lut_3d; uniform sampler2D dither; -uniform mat4x3 colormatrix; +uniform mat3 colormatrix; +uniform vec3 colormatrix_c; uniform mat3 cms_matrix; uniform mat2 dither_trafo; uniform vec3 inv_gamma; @@ -366,7 +367,7 @@ void main() { #endif #ifdef USE_COLORMATRIX // Conversion from Y'CbCr or other spaces to RGB - color = mat3(colormatrix) * color + colormatrix[3]; + color = mat3(colormatrix) * color + colormatrix_c; #endif #ifdef USE_CONV_GAMMA // Post-colormatrix converted gamma correction (eg. for MP_IMGFLAG_XYZ) |