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

Re: [Public WebGL] webgl texture format conversions: doable in 17k of executable code (x86-64) !



Yup, let me know if you have questions. It's all in these two files:

http://hg.mozilla.org/integration/mozilla-inbound/file/9f87dbd4d39c/content/canvas/src/WebGLTexelConversions.h
http://hg.mozilla.org/integration/mozilla-inbound/file/9f87dbd4d39c/content/canvas/src/WebGLTexelConversions.cpp

Except for the WebGLTexelFormat enum which is declared there:
http://hg.mozilla.org/integration/mozilla-inbound/file/9f87dbd4d39c/content/canvas/src/WebGLContext.h#l141

In WebGLTexelConversions.h I had to depart significantly from the pack/unpack routines we were sharing with WebKit: they got templatized, so it was no longer possible to share long blocks of code without modification. I would encourage you to switch to templatized pack/unpack routines to, which has no drawback AFAICS and allows us to keep sharing this code. This can be done regardless of whether you switch to fully templatized conversion loops or not.

Also note that below the pack/unpack routines in this file, there are new convertType routines. They are needed e.g. when converting from RGBA8 to RGBA32F, e.g. when creating a float texture from a ImageData object. I found about this when debugging Firefox's failure to run my WebGL performance tests.

Cheers,
Benoit

----- Original Message -----
> Nice work! Thanks for contributing this to the community. I'm looking
> at integrating your new code back into WebKit now.
> 
> -Ken
> 
> 
> On Tue, May 8, 2012 at 7:05 AM, Benoit Jacob <bjacob@mozilla.com>
> wrote:
> >
> > Hi,
> >
> > This email is 50% bragging rights and 50% sharing hopefully useful
> > info with other browser vendors.
> >
> > You know that a WebGL implementation has to handle a large number
> > of cases of texture format conversions: there are many source
> > formats, many destination formats, and the possibility of
> > premultiplication or unpremultiplication.
> >
> > Here is a changeset (currently only on mozilla-inbound) that brings
> > this code size down to 17k on x86-64 (as measured with nm -S on
> > linux). Our previous version, which was already quite careful, was
> > 44k. This is using the 'fully templatized' approach i.e. a
> > separate conversion loop is compiled for each case, traversing the
> > bitmaps only once, with all the texel conversion functions inlined
> > into it.
> >
> > Changeset:
> > https://hg.mozilla.org/integration/mozilla-inbound/rev/9f87dbd4d39c
> >
> > The key was to avoid compiling paths that are never called, the
> > code for this is there:
> > https://hg.mozilla.org/integration/mozilla-inbound/rev/9f87dbd4d39c#l4.82
> >
> > Cheers,
> > Benoit
> >
> > -----------------------------------------------------------
> > 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
-----------------------------------------------------------