[Bf-committers] Viewport FX Design
Brecht Van Lommel
brechtvanlommel at pandora.be
Fri Jun 1 16:05:51 CEST 2012
I may be saying again what you already wrote, but let me give my view
on the immediate mode emulation stuff. What we need:
* For OpenGL ES we need to avoid immediate mode.
* VBO and non-VBO mesh drawing in derived meshes needs to be unduplicated.
* Performance improvements by avoiding CPU overhead.
* API needs to stay relatively simple.
I think the current immediate mode emulation is a good start, but we
can unify it with vertex arrays and VBO's, and make it more than just
immediate mode emulation. It already requires to specify up front
which types of data are going to be passed, so it's already close in
usage. The big remaining difference is that you don't need to specify
up front how many vertices you're going to pass, and we can make it
support both cases with a single API.
It would be the API to pass primitives and their attributes to GL,
which are either drawn immediately or retained. There would still be
an immediate mode component to avoid continuously allocating or
freeing memory, but most of it can be shared with retained mode.
Basically the API will always be, allocate an array for each needed
attribute, fill up the arrays, and then give them back.
Filling up these arrays can be wrapped in nice immediate-mode-ish
functions, but for best performance, after function inlining it should
just end up filling arrays and increasing a counter for each vertex
(the current gpu_vector_copy function still has too much overhead).
For cases where you don't specify the number of vertices up front, the
arrays could have a reasonably big default size, and then every N
vertices it could send out the data in a batch, that still would just
be a single if() test per vertex.
Specifying the needed attributes should be totally simple for simple
cases, it could be a bitflag to specify the attributes you will use.
For more complex cases like arbitrary GLSL attributes it can be more
complicated of course, but that's the exception. We also do not need
to support multiple texture coordinates, they're only used in game
engine immediate mode drawing which can just be dropped.
So in most cases (almost everything except mesh drawing) it could look
something like this.
More information about the Bf-committers