[vlc-devel] [PATCH] opengl: fix xyz12 fragment shader

Romain Vimont rom1v at videolabs.io
Tue Mar 31 11:05:38 CEST 2020


Commits bf4f21b54f03e7b33c5c55d3171caf06d1482459 and
cb16845b7e1244f3a7085276489f9dd2e01a2949 moved transformations from the
renderer to the (sampler) fragment shader.

But the transformations were applied only on the "main" fragment shader.
Also apply them on the specific fragment shader generated for XYZ12
chroma.

---
This fixes this error on XYZ12 videos:

    vlc: ../../modules/video_output/opengl/renderer.c:360: opengl_link_program: Assertion `renderer->uloc.TransformMatrix != -1' failed.
    Aborted
---
 modules/video_output/opengl/fragment_shaders.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 9bc7e9b6bd..117020cbe7 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -347,10 +347,16 @@ xyz12_shader_init(struct vlc_gl_renderer *renderer)
         "    0.0,      0.0,         0.0,        1.0 "
         " );"
 
+        "uniform mat4 TransformMatrix;\n"
+        "uniform mat4 OrientationMatrix;\n"
+        "uniform mat3 TexCoordsMap0;\n"
         "vec4 vlc_texture(vec2 pic_coords)\n"
         "{ "
         " vec4 v_in, v_out;"
-        " v_in  = texture2D(Texture0, pic_coords);"
+        /* Homogeneous (oriented) coordinates */
+        " vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st, 1.0);\n"
+        " vec2 tex_coords = (TexCoordsMap0 * pic_hcoords).st;\n"
+        " v_in  = texture2D(Texture0, tex_coords);\n"
         " v_in = pow(v_in, xyz_gamma);"
         " v_out = matrix_xyz_rgb * v_in ;"
         " v_out = pow(v_out, rgb_gamma) ;"
-- 
2.26.0



More information about the vlc-devel mailing list