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

Re: [Public WebGL] 2d canvas context to WebGL



Firefox does not currently optimize canvas->canvas transfers, though we would like to implement this optimization in the future. We definitely readback and re-upload for texImage2D(<canvas>.

-Jeff

----- Original Message -----
From: "Kenneth Russell" <kbr@google.com>
To: "Rik Cabanier" <cabanier@gmail.com>
Cc: "Benoit Jacob" <bjacob@mozilla.com>, "public webgl" <public_webgl@khronos.org>
Sent: Thursday, April 25, 2013 1:31:07 PM
Subject: Re: [Public WebGL] 2d canvas context to WebGL


Please file a bug with a self-contained test case. Exposing these
issues is the only way they are going to be fixed.

-Ken


On Thu, Apr 25, 2013 at 1:26 PM, Rik Cabanier <cabanier@gmail.com> wrote:
> One of our frameworks draws into a 2d canvas, transfers it to WebGL, runs a
> shader and then brings the result back.
> Just copying a 500x500 canvas to and from WebGL takes:
>
> - 16ms on Chrome
> - 14ms on Firefox
> - 40ms on Safari
>
>
> This is way to slow to make fluid animations such as this one:
> http://ads2.msads.net/CIS/48/000/000/000/039/337.swf?fd=www.msn.com (sorry
> for the flash movie). If you look closely, you will see that the text is
> blurred during the animation.
> In most (all?) implementations, the canvas bits were already on the GPU so
> this time *could* be brought down to zero.
>
> Safari is twice as bad as chrome and Firefox. This is probably caused by the
> optimizations you mentioned.
>
> The bug you mentioned is because of synchronous readback, Ideally there
> would be no readback at all  :-)
>
> On Wed, Apr 24, 2013 at 2:07 PM, Kenneth Russell <kbr@google.com> wrote:
>>
>> There is definitely code in Chrome to make Canvas -> WebGL uploads
>> efficient (as well as the reverse direction), but I believe there are
>> still some slow paths. See
>> https://code.google.com/p/chromium/issues/detail?id=233205 for
>> example. I don't know how much of this made it in to Safari.
>>
>>
>>
>> On Wed, Apr 24, 2013 at 1:59 PM, Rik Cabanier <cabanier@gmail.com> wrote:
>> > Great!
>> > So Safari and Chrome implement this efficiently? Also is this documented
>> > somewhere?
>> >
>> >
>> > On Wed, Apr 24, 2013 at 1:47 PM, Benoit Jacob <bjacob@mozilla.com>
>> > wrote:
>> >>
>> >>
>> >> A 2D canvas can be passed directly to WebGL texImage2D.
>> >>
>> >> This happens to be slow in Firefox at the moment (the canvas is
>> >> currently read back and re-uploaded), but that could probably be fixed
>> >> if there is real-world pressure in that direction.
>> >>
>> >> Benoit
>> >>
>> >> On 13-04-24 04:23 PM, Rik Cabanier wrote:
>> >> > All,
>> >> >
>> >> > Sorry if this is already documented but is there a way to efficiently
>> >> > use a 2d canvas context in WebGL?
>> >> > We've seen cases where people want to apply effects on 2d contexts
>> >> > and
>> >> > they're doing this by copying the 2d canvas to a buffer, running a
>> >> > shader on it and getting the result back.
>> >> > This is an expensive workflow both in time and memory.
>> >> >
>> >> > Since the 2d canvas is already on the GPU (on most browsers), is
>> >> > there
>> >> > a way to directly access it from WebGL?
>> >> >
>> >> > Thanks!
>> >>
>> >>
>> >> -----------------------------------------------------------
>> >> You are currently subscribed to public_webgl@khronos.org.
>> >> To unsubscribe, send an email to majordomo@khronos.org with
>> >> the following command in the body of your email:
>> >> unsubscribe public_webgl
>> >> -----------------------------------------------------------
>> >>
>> >
>
>

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------


-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------