Matrix multiplication. R32F textures shader

calculating

"WebGL 2" NxN matrix FP32 multiplication C = A x B (GEMM) demo N = 256.
All A, B elements are random (0 - 1). Error "er1" is calculated as the sum of |CCPU - CGPU |/(N*N) for all matrix elements. er2 = max(|CCPU - CGPU |). See also benchmark.

Fragment Shader 1

See also the page source
#version 300 es
precision highp float;
  uniform highp sampler2D samp0;
  uniform highp sampler2D samp1;
  out float fragColor;
  uniform int N;
void main(void) {
  float acc = 0;
  for(int i=0; i < N; i++)
    acc += texelFetch(samp0, ivec2(gl_FragCoord.x, i), 0).r * 
           texelFetch(samp1, ivec2(i, gl_FragCoord.y), 0).r;
  fragColor = acc;
}

SGEMM in WebGL2-compute     updated 26 Mar 2019