Commit Graph

4 Commits

Author SHA1 Message Date
Robert Bragg
7283e0a49c rework enabling of attributes, removing _cogl_enable()
This removes the limited caching of enabled attributes done by
_cogl_enable() and replaces it with a more generalized set of bitmasks
associated with the context that allow us to efficiently compare the set
of attribute locations that are currently enabled vs the new locations
that need enabling so we only have to inform OpenGL of the changes in
which locations are enabled/disabled.

This also adds a per-context hash table for mapping attribute names to
global name-state structs which includes a unique name-index for any
name as well as pre-validated information about builtin "cogl_"
attribute names including whether the attribute is normalized and what
texture unit a texture attribute corresponds too.

The name-state hash table means that cogl_attribute_new() now only needs
to validate names the first time they are seen.

CoglAttributes now reference a name-state structure instead of just the
attribute name, so now we can efficiently get the name-index for any
attribute and we can use that to index into a per-glsl-program cache
that maps name indices to real GL attribute locations so when we get
asked to draw a set of attributes we can very quickly determine what GL
attributes need to be setup and enabled. If we don't have a cached
location though we can still quickly access the string name so we can
query OpenGL.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-12-06 18:51:57 +00:00
Robert Bragg
9b0fd92527 cogl: rename CoglVertexAttribute CoglAttribute
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to reduce the verbosity
of using the API. Another reason is that CoglVertexArray is going to be
renamed CoglAttributeBuffer and we want to help emphasize the
relationship between CoglAttributes and CoglAttributeBuffers.
2011-01-21 16:24:14 +00:00
Neil Roberts
e38e9e0355 cogl-vertex-attribute: Use glVertexAttribPointer on GLES2
When the GLES2 wrapper is removed we can't use the fixed function API
such as glColorPointer to set the builtin attributes. Instead the GLSL
progend now maintains a cache of attribute locations that are queried
with glGetAttribLocation. The code that previously maintained a cache
of the enabled texture coord arrays has been modified to also cache
the enabled vertex attributes under GLES2. The vertex attribute API is
now the only place that is using this cache so it has been moved into
cogl-vertex-attribute.c
2010-12-13 17:28:29 +00:00
Neil Roberts
9b1ab9f0ec cogl: Add a GLSL 'progend'
'progend' is short for 'program backend'. The progend is intended to
operate on combined state from a fragment backend and a vertex
backend. The progend has an 'end' function which is run whenever the
pipeline is flushed and the two pipeline change notification
functions. All of the progends are run whenever the pipeline is
flushed instead of selecting a single one because it is possible that
multiple progends may be in use for example if the vertends and
fragends are different. The GLSL progend will take the shaders
generated by the fragend and vertend and link them into a single
program. The fragend code has been changed to only generate the shader
and not the program. The idea is that pipelines can share fragment
shader objects even if their vertex state is different. The authority
for the progend needs to be the combined authority on the vertend and
fragend state.
2010-12-13 17:22:57 +00:00