0

We are profiling our application and we're noticing that most of the cpu time is spent on calls to texImage2D which is what we use to populate a texture. An example is shown below. I'd like to know if there are faster methods available in WebGL 1/2 or propriatary browser extensions that make this faster?

   gl.bindTexture(gl.TEXTURE_2D, texture);
   gl.texImage2D(gl.TEXTURE_2D, 
                    0,             
                    0,            
                    0,             
                    width,  
                    height, 
                    gl.RED,      
                    gl.FLOAT,         
                    data);        
   gl.bindTexture(gl.TEXTURE_2D, null);
Jeff Saremi
  • 2,674
  • 3
  • 33
  • 57
  • Is texStorage2D a faster call? – Jeff Saremi Aug 29 '18 at 01:18
  • There's an offfset parameter which points to a PIXEL_UNPACK_BUFFER. Is that going to speed things up? – Jeff Saremi Aug 29 '18 at 01:33
  • I think this was already asked and the answer was no: https://stackoverflow.com/questions/43530082/how-can-i-upload-a-texture-in-webgl2-using-a-pixel-buffer-object – Jeff Saremi Aug 29 '18 at 01:38
  • `texStorage2D` creates an immutable texture (it's size and format cannot be changed by further calls, unlike textures created with `texImage2D`), which results in some speed gains, but I'm not sure if it would affect loading times. UnityWeb seems to only use `texStorage2D` and `compressedTexSubImage2D`, if it helps (as long as the context is WebGL2, of course). – riv Aug 29 '18 at 10:41
  • Thanks @riv. Good insight – Jeff Saremi Aug 29 '18 at 14:49

0 Answers0