WebGL texImage2D vs texSubImage2D (v20)

Revision 20 of this benchmark created on


Preparation HTML

<script>
  var size = 1024;
  var buffer = new Uint8Array(size*size*4);

  var canvas = document.createElement('canvas');
  canvas.width = size;
  canvas.height = size;
  
  var gl = canvas.getContext('experimental-webgl');
  var tex = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D, tex);

  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
                size, size, 0,
                gl.RGBA, gl.UNSIGNED_BYTE,
                buffer);
var numQuads = 4;
var sqrtQuads = Math.sqrt(numQuads);
isqrtQuads = 1/sqrtQuads;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
texImage2D full texture
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
              size, size, 0,
              gl.RGBA, gl.UNSIGNED_BYTE,
              buffer);
ready
texSubImage2D full texture
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 0, 0, size, size,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
ready
texSubImage2D partial texture
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 1, 1, size-1, size-1,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
ready
texSubImage2D 4 quadrants
for(var i = 0; i < sqrtQuads; ++i){
  for(var j = 0; j < sqrtQuads; ++j){
   gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 i * sqrtQuads, j * sqrtQuads, size * isqrtQuads, size * isqrtQuads,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
  }
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.