Perfectly healthy fragment shader fails to compile: Uniform X not found

Duplicate Issue #19723762 • See Issue #19320539

Details

Author
jeff s.
Created
Nov 26, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
Duplicates
See progress on Bug #19320539
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

This compiles with no issues in Chrome and Firefox however it consistently fails in Edge:

precision highp float;
precision highp int;
varying vec2 TexCoords;

uniform sampler2D X;


  void copyVec(int src[5], out int dest[5]) {

    dest[0] = src[0];

    dest[1] = src[1];

    dest[2] = src[2];

    dest[3] = src[3];

    dest[4] = src[4];

  }


  int coordsToOffset(vec2 coords, int width, int height) {
    float s = coords.s * float(width);
    float t = coords.t * float(height);
    int offset = int(t) * width + int(s);
    return offset;
  }



  void toVec(vec2 texCoords, out int c[5]) {

  int offset = coordsToOffset(texCoords, 961, 93);

    c[0] = offset / 89373;
    offset -= c[0] * 89373;
    c[1] = offset / 29791;
    offset -= c[1] * 29791;
    c[2] = offset / 961;
    offset -= c[2] * 961;
    c[3] = offset / 31;
    offset -= c[3] * 31;
    c[4] = offset;
  }
  void toVec(int offset, out int c[5]) {

    c[0] = offset / 89373;
    offset -= c[0] * 89373;
    c[1] = offset / 29791;
    offset -= c[1] * 29791;
    c[2] = offset / 961;
    offset -= c[2] * 961;
    c[3] = offset / 31;
    offset -= c[3] * 31;
    c[4] = offset;
  }


  int indicesToOffset_X(int indices[5]) {
    int offset = 0;

    offset += indices[4] * 1;

    offset += indices[3] * 32;

    offset += indices[2] * 1024;

    offset += indices[1] * 32768;

    offset += indices[0] * 98304;

    return offset;
  }


  vec2 offsetToCoords(int offset, int width, int height) {
    int t = offset / width;
    int s = offset - t*width;
    vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
    return coords;
  }

highp float decode(highp vec4 rgba) {
return rgba.r;
}

    float getColorAsFloat(vec4 color) {
        return decode(color);
    }


    float _X(int m[5]) {
      int offset = indicesToOffset_X(m);
      vec2 coords = offsetToCoords(offset, 384, 256);
      float value = getColorAsFloat(texture2D(X, coords));
      return value;
    }





void offsetToIndices(int offset, int[3] strides, out int[3] indices) {
  if (3 == 0) {
    return;
  }
  for (int i = 0; i < 3 - 1; ++i) {
    indices[i] = offset / strides[i];
    offset -= indices[i] * strides[i];
  }
  indices[3 - 1] = offset;
}
        float process(int indices[5]) {
            int x[5];
            copyVec(indices, x);
            int offset[3];
            int pads[6];
            int inputDims[5];
            int kernelStrides[3];
            int strides[3];

  pads[0] = 0;

  pads[1] = 0;

  pads[2] = 0;

  pads[3] = 0;

  pads[4] = 0;

  pads[5] = 0;


  inputDims[0] = 1;

  inputDims[1] = 3;

  inputDims[2] = 32;

  inputDims[3] = 32;

  inputDims[4] = 32;


  strides[0] = 1;

  strides[1] = 1;

  strides[2] = 1;


  kernelStrides[0] = 4;

  kernelStrides[1] = 2;

  kernelStrides[2] = 1;


            float value = -1e5;
            int pad = 0;
            bool isPad = false;
            for (int i = 0; i < 8; i++) {
                offsetToIndices(i, kernelStrides, offset);
                isPad = false;
                for (int j = 5 - 3; j < 5; j++) {
                  x[j] = indices[j] * strides[j - 5 + 3]
                    + offset[j - 5 + 3] - pads[j - 2];

              }

          value = max(_X(x), value);

            }


            return value;
        }



void main() {
  int indices[5];
  toVec(TexCoords, indices);

  vec4 result = vec4(process(indices));

  gl_FragColor = result;
}

Attachments

0 attachments

    Comments and activity

    You need to sign in to your Microsoft account to add a comment.

    Sign in