Skip to content
Browse files

Work around OpenGL driver bugs again.

This time the workaround is for the NVIDIA 256.* series on Linux.

The GLSL compiler failed on the original version of the code. A variant of the
code with the three local variables sr, sg, sb but an inlined computation
compiled successfully, but resulted in wrong colors, probably due to invalid
optimizations.
  • Loading branch information...
1 parent c9e58a2 commit c7bf4d59494f07a339bc19d97935e9f5f442a68e @marlam marlam committed Dec 13, 2010
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/video_output_opengl_render.fs.glsl
View
13 src/video_output_opengl_render.fs.glsl
@@ -46,17 +46,22 @@ float srgb_to_lum(vec3 srgb)
}
#endif
+float linear_to_nonlinear(float x)
+{
+ return (x <= 0.0031308 ? (x * 12.92) : (1.055 * pow(x, 1.0 / 2.4) - 0.055));
+}
+
vec3 rgb_to_srgb(vec3 rgb)
{
#if $srgb_broken
return rgb;
#else
# if 1
// Correct variant, see GL_ARB_framebuffer_sRGB extension
- return vec3(
- (rgb.r <= 0.0031308 ? (rgb.r * 12.92) : (1.055 * pow(rgb.r, 1.0 / 2.4) - 0.055)),
- (rgb.g <= 0.0031308 ? (rgb.g * 12.92) : (1.055 * pow(rgb.g, 1.0 / 2.4) - 0.055)),
- (rgb.b <= 0.0031308 ? (rgb.b * 12.92) : (1.055 * pow(rgb.b, 1.0 / 2.4) - 0.055)));
+ float sr = linear_to_nonlinear(rgb.r);
+ float sg = linear_to_nonlinear(rgb.g);
+ float sb = linear_to_nonlinear(rgb.b);
+ return vec3(sr, sg, sb);
# endif
# if 0
// Faster variant

0 comments on commit c7bf4d5

Please sign in to comment.
Something went wrong with that request. Please try again.