[Mesa-dev] Mesa as part of OpenGL-on-OpenGL ES 2.0 (/WebGL)?
michel at daenzer.net
Tue Mar 6 00:08:27 PST 2012
On Mon, 2012-03-05 at 19:41 -0800, Benoit Jacob wrote:
> ----- Original Message -----
> > On Sat, 3 Mar 2012 13:21:08 -0800, Alon Zakai <alonzakai at gmail.com>
> > wrote:
> > >
> > > In the project I work on (Emscripten, an open source C/C++ to
> > > compile OpenGL games from desktop so that they work on
> > > WebGL on the web. The main remaining difficulty for us is
> > > to emulate the full OpenGL API using the WebGL API. WebGL
> > > is close to OpenGL ES 2.0, so it has shaders but lacks the
> > > fixed-function pipeline, glBegin etc.
> > >
> > > So far we have some of the OpenGL ES 2.0 API implemented,
> > > you can see a demo of it on the web here:
> > >
> > > http://people.mozilla.org/~eakhgari/es2gears.html
Too bad it refuses to run on big endian hosts yet. :)
> > Desktop GL includes ridiculous things like texture borders and
> > GL_CLAMP
> > and glDrawPixels and other things we all wish we could just forget
> > about. ES2 doesn't have those equivalents, so you'd have to emulate
> > them.
> That's exactly where we were hoping that Mesa might be able to help:
> doesn't Mesa already have an implementation of these OpenGL 1 pieces
> on top of something closer to OpenGL ES 2 (which IIUC is far closer to
> how modern hardware really works)?
> If Mesa had an implementation of GL1 on top of GLES2, Emscripten
> (Alon's C/C++-to-JS translator) could compile it to JS.
> > For a bunch of it, apps don't use it so nobody would notice.
> > glBitmap and glDrawPixels are reasonably popular, though. You should
> > be
> > able to build those with shaders, though. You can see partial
> > implementations for these in on top of fixed function in Mesa as
> > src/mesa/drivers/common/meta.c (contributions welcome, particularly
> > in
> > the form of GLSL-based implementations of them!)
> Thanks for the pointer but that (a GLES2-based implementation) is
> precisely what we're looking for :-)
> Before we'd start caring about glBitmap and glDrawPixels, we have more
> fundamental things to implement:
> - glBegin ... glVertex ... glEnd
> - glShadeModel(GL_FLAT) (this one seems really hard to do with OpenGL ES2, a real capability regression from OpenGL [ES] 1 it seems!)
> - display lists
> - the lighting model (glLight, glMaterial)
> Does Mesa have code that could be reused to implement some of that on top of ES2?
I suspect you're thinking of the Gallium3D framework, and I think it
could indeed be useful for this. Basically, you should only need to
* A core Gallium3D driver (src/gallium/drivers/.../) which
translates shaders from TGSI to GLSL (should be trivial at least
for a first pass) and Gallium3D state to GLES / WebGL state
* Possibly some environment glue code (src/gallium/winsys/.../).
* Target glue code (src/gallium/targets/.../).
The parts which translate from OpenGL/GLSL to Gallium3D/TGSI
(src/mesa/state_tracker/) are shared between all Gallium3D drivers.
There might be some gotchas I'm not aware of though...
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Debian, X and DRI developer
More information about the mesa-dev