Setting a material using pixel data directly

Hi,guys :grinning:,I wonder if there is any way to set a material’s texture by using the pixel data directly?As for now I have to create a texture,copy the pixel data to that texture like this:

var tex = new pc.Texture(); 
   var pixels = tex.lock(); 
   for(var i=0;i<myPixelData.length;i++){
     pixels[i] = myPixelData[i];
   mat.diffusemap = tex;

when the texture’s resolution is large,this loop function will have a noticeable impact on performance.I wonder if there is any better solution? since the webgl can read pixel data,I guess there is a straightforward way,can you guys give me some advice?