phoboslab / WebGLImageFilter

Fast image filters for Browsers with WebGL support
MIT License
332 stars 62 forks source link

only create the gl texture once. fixes #7 #24

Closed mreinstein closed 4 years ago

mreinstein commented 4 years ago

@phoboslab this was another performance issue I ran into....after 10-20 seconds of running this in a tight animation loop, the gpu would take something like 250ms to render. I think this is due to the fact that we are creating a new gl texture unnecessarily on each call. This seems to help quite a bit.

phoboslab commented 4 years ago

Thanks!

Afaik using glTexSubImage2D() to update the pixel data for an existing texture should be even faster, because it doesn't allocate new image data on the GPU. Of course this only works when the input image dimension doesn't change. Maybe my info is outdated and OpenGL drivers and/or WebGL wrappers are smarter now. But I guess it's worth a try if you still have performance issues.

mreinstein commented 4 years ago

using glTexSubImage2D() to update the pixel data for an existing texture should be even faster

oh, interesting! That makes sense. I suppose if one were to pursue that, some setup/teardown logic for the texture would go into the _resize handler.