[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Issues with sharing resources across contexts

On Wed, Jul 18, 2012 at 11:01 PM, Mark Callow <[email protected]> wrote:
On 19/07/2012 05:08, Gregg Tavares (社用) wrote:
*) Download images in a worker, decode and upload to texture
What are the advantages to using a worker rather than an async XMLHTTPRequest whose ready callback decodes & loads the texture? 

Uploading a texture is not instant period. Even if all you do is call glTexImage2D with raw data there's still overhead. Calling it in another thread means no overhead on the main thread which means no jank. Even in C programs I've had to do this and upload textures off the main thread.

In WebGL it's worse though. You have no control over the browser's image decoder. Does it decode in the foreground? Does it decode in the background? Maybe it decodes in the background but only on demand. Demand being that the image is displayed on the screen. That works for onscreen images since the browser can use a place holder until the image is ready. But when you use an image with WebGL the browser doesn't have that chance since there is no "displayed on the screen" or placeholder. It has to give you the correct image right now, synchronously. On top of that, let's assume it has decoded the image. There's no guarantee it decoded it in the correct format. Maybe you are asking for unpremultiplied alpha because you're loading from a PNG and your alpha channel is not actually alpha data. Or maybe you're loading an JPG but you want it uploaded in RGBA so it has to be converted to RGBA before calling glTexImage2D.




注意:この電子メールには、株式会社エイチアイの機密情報が含まれている場合が有ります。正式なメール受信者では無い場合はメール複製、 再配信または情報の使用を固く禁じております。エラー、手違いでこのメールを受け取られましたら削除を行い配信者にご連絡をお願いいたし ます。

NOTE: This electronic mail message may contain confidential and privileged information from HI Corporation. If you are not the intended recipient, any disclosure, photocopying, distribution or use of the contents of the received information is prohibited. If you have received this e-mail in error, please notify the sender immediately and permanently delete this message and all related copies.