WebGL texImage2D vs texSubImage2D

JavaScript performance comparison

Revision 11 of this test case created

Preparation code

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

  var canvas = document.createElement('canvas');
  canvas.width = 640;
  canvas.height = 480;
 
  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,
                null);
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
texImage2D full texture
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
              size, size, 0,
              gl.RGBA, gl.UNSIGNED_BYTE,
              buffer);
pending…
texSubImage2D full texture
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 0, 0, size, size,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
pending…
texSubImage2D partial texture
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 1, 1, size-2, size-2,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
pending…
texSubImage2D 4 quadrants
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 0, 0, size/2, size/2,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 0, size/2, size/2, size/2,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 size/2, 0, size/2, size/2,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
gl.texSubImage2D(gl.TEXTURE_2D, 0,
                 size/2, size/2, size/2, size/2,
                 gl.RGBA, gl.UNSIGNED_BYTE,
                 buffer);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment