Skip to content
Snippets Groups Projects
Commit 32abaa35 authored by Thomas Guillem's avatar Thomas Guillem Committed by Steve Lhomme
Browse files

opengl: sampler: specify sampler?D precision

Fixes the following error on GLES2 when using libplacebo shaders.

[00007fe3cc815910] gl generic error: Shader source:
   1: #version 300 es
   2: precision highp float;
   3: uniform sampler2D Textures[3];
   4: uniform mat3 _2;
   5: uniform mat3 _3;
   6: uniform mat3 _4;
   7: uniform float _a;
   8: uniform float _b;
   9: uniform mat3 _19;
  10: uniform sampler2D _6;
  11: uniform sampler3D _d;
  12:
  13: const float _8 = float(0.001953125);
  14: const float _9 = float(0.99609375);
  15: #define _7(x) (_9 * (x) + _8)
  16: #define _5(pos) (textureLod(_6, vec2(\
  17:     _7(float(pos))\
  18:    ,0.5\
  19:   ), 0.0).x)
  20: const float _f = float(0.010416666977107525);
  21: const float _10 = float(0.9791666269302368);
  22: #define _e(x) (_10 * (x) + _f)
  23: const float _12 = float(0.015625);
  24: const float _13 = float(0.96875);
  25: #define _11(x) (_13 * (x) + _12)
  26: const float _15 = float(0.001953125);
  27: const float _16 = float(0.99609375);
  28: #define _14(x) (_16 * (x) + _15)
  29: #define _c(pos) (textureLod(_d, vec3(\
  30:     _e(vec3(pos).x)\
  31:    ,_11(vec3(pos).y)\
  32:    ,_14(vec3(pos).z)\
  33:   ), 0.0).xyzw)
  34: const float _17 = float(-0.16753844916820526);
  35: const float _18 = float(2.0106043815612793);
  36: const float _1a = float(0.0595848374068737);
  37: const float _1b = float(1.149015188217163);
  38: vec4 _1(vec4 color) {
  39: // pl_shader_color_map
  40: {
  41: // pl_shader_linearize
  42: color.rgb = max(color.rgb, 0.0);
  43: color.rgb = pow(color.rgb, vec3(1.0/78.84375));
  44: color.rgb = max(color.rgb - vec3(0.8359375), 0.0)
  45:              / (vec3(18.8515625) - vec3(18.6875) * color.rgb);
  46: color.rgb = pow(color.rgb, vec3(1.0/0.1593017578125));
  47: color.rgb *= vec3(49.26108374384236);
  48: vec3 lms = _4 * color.rgb;
  49: vec3 lmspq = 0.0203000009059906 * lms;
  50: lmspq = pow(max(lmspq, 0.0), vec3(0.1593017578125));
  51: lmspq = (vec3(0.8359375) + 18.8515625 * lmspq)
  52:         / (vec3(1.0) + 18.6875 * lmspq);
  53: lmspq = pow(lmspq, vec3(78.84375));
  54: vec3 ipt = _2 * lmspq;
  55: float i_orig = ipt.x;
  56: #define tone_map(x) (_5(_b * (x) + _a))
  57: ipt.x = tone_map(ipt.x);
  58: vec2 hull = vec2(i_orig, ipt.x);
  59: hull = ((hull - 6.0) * hull + 9.0) * hull;
  60: ipt.yz *= min(i_orig / ipt.x, hull.y / hull.x);
  61: vec3 idx;
  62: idx.x = _18 * ipt.x + _17;
  63: idx.y = 2.0 * length(ipt.yz);
  64: idx.z = 0.15915494309189535 * atan(ipt.z, ipt.y) + 0.5;
  65: ipt = _c(idx).xyz;
  66: ipt.yz -= vec2(32768.0/65535.0);
  67: lmspq = _3 * ipt;
  68: lms = pow(max(lmspq, 0.0), vec3(1.0/78.84375));
  69: lms = max(lms - vec3(0.8359375), 0.0)
  70:              / (vec3(18.8515625) - 18.6875 * lms);
  71: lms = pow(lms, vec3(1.0/0.1593017578125));
  72: lms *= 49.261085510253906;
  73: color.rgb = _19 * lms;
  74: #undef tone_map
  75: // pl_shader_delinearize
  76: color.rgb = max(color.rgb, 0.0);
  77: color.rgb = pow(_1b * color.rgb, vec3(1.0/2.4)) - vec3(_1a);
  78: }
  79: return color;
  80: }
  81:
  82: uniform mat4 ConvMatrix;
  83: vec4 vlc_texture(vec2 tex_coords) {
  84:  vec4 pixel = vec4(
  85:   texture(Textures[0], tex_coords).r
  86:   ,  texture(Textures[1], tex_coords).r
  87:   ,  texture(Textures[2], tex_coords).r
  88:   ,  1.0);
  89:  vec4 result = ConvMatrix * pixel;
  90:  result = _1(result);
  91:  return result;
  92: }
  93: #if __VERSION__ < 300
  94: #define FragColor gl_FragColor
  95: varying vec2 PicCoords;
  96: #else
  97: in vec2 PicCoords;
  98: out vec4 FragColor;
  99: #endif
 100: void main() {
 101:  FragColor = vlc_texture(PicCoords);
 102: }

[00007fe3cc815910] gl generic error: shader: 0:11(1): error: No precision specified in this scope for type `sampler3D'
parent 66e4a5e9
No related branches found
No related tags found
1 merge request!6628opengl: fix 10bits on GL, add 10bits on GLES 3.0
......@@ -993,7 +993,9 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
int glsl_version;
if (api->is_gles) {
sampler->shader.precision = "precision highp float;\n";
sampler->shader.precision = "precision highp float;\n"
"precision highp sampler2D;\n"
"precision highp sampler3D;\n";
if (api->glsl_version >= 300) {
sampler->shader.version = strdup("#version 300 es\n");
glsl_version = 300;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment