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

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



I filed it underĀ https://bugzilla.mozilla.org/show_bug.cgi?id=866300

I rewrote Sven's fiddle (thanks!) a bit to show the problem more clearly.
It seems that Chrome remembers that the texture was uploaded so running things in a loop is skewing the result. It's very clear on Firefox though.

Rik

On Thu, Apr 25, 2013 at 11:18 PM, Kang-Hao (Kenny) Lu <kanghaol@oupeng.com> wrote:
It would be nice if you share the bug number with the list too!

(13/04/26 12:22), Jeff Gilbert wrote:
>
> Sure! It's on my list of Things To Fix, but it will need to have a bug filed sooner or later.
>
> Please email me when you create it. (Or just CC me on the bug)
>
> -Jeff
>
> ----- Original Message -----
> From: "Rik Cabanier" <cabanier@gmail.com>
> To: "Jeff Gilbert" <jgilbert@mozilla.com>
> Cc: "Kenneth Russell" <kbr@google.com>, "Benoit Jacob" <bjacob@mozilla.com>, "public webgl" <public_webgl@khronos.org>
> Sent: Thursday, April 25, 2013 9:09:28 PM
> Subject: Re: [Public WebGL] 2d canvas context to WebGL
>
> Should I log bugs against mozilla too? (It's a bit strange since there's nothing wrong per se)
>
>
>
> On Thu, Apr 25, 2013 at 4:14 PM, Jeff Gilbert < jgilbert@mozilla.com > wrote:
>
>
> I don't believe Firefox does, no.
>
>
> -Jeff
>
> ----- Original Message -----
>
>
> From: "Rik Cabanier" < cabanier@gmail.com >
> To: "Jeff Gilbert" < jgilbert@mozilla.com >
> Cc: "Kenneth Russell" < kbr@google.com >, "Benoit Jacob" < bjacob@mozilla.com >, "public webgl" < public_webgl@khronos.org >
> Sent: Thursday, April 25, 2013 4:09:52 PM
> Subject: Re: [Public WebGL] 2d canvas context to WebGL
>
> Do you also not optimize drawImage with a WebGL canvas?
>
>
> On Thu, Apr 25, 2013 at 3:10 PM, Jeff Gilbert < jgilbert@mozilla.com > wrote:
>
>
> 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
> -----------------------------------------------------------
>

Cheers,
Kenny
--
Web Specialist, Opera Sphinx Game Force, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/