WebGL texImage2D vs texSubImage2D

JavaScript performance comparison

Test case created by Brian Chirls

Preparation code

<script>
  var canvas = document.createElement('canvas');
  canvas.width = 640;
  canvas.height = 360;
 
  var img = new Image();
  img.src = canvas.toDataURL();
 
  var gl = canvas.getContext('experimental-webgl');
  var tex = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D, tex);
 
  img.onload = function() {
    console.log(img.width, img.height);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
  };
</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
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
pending…
texSubImage2D
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, img);
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