summaryrefslogtreecommitdiff
path: root/cogl/cogl-attribute-private.h
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-11-24 18:09:53 +0000
committerRobert Bragg <robert@linux.intel.com>2011-12-06 18:51:57 +0000
commit7283e0a49c5eeee9242ccd5857e2a51d6934b792 (patch)
treec50a1652b4ee21195d7457bcd020b59cd3d5fb7b /cogl/cogl-attribute-private.h
parent2112af0bc51c5173a4b8fe2c6ea6bdca9274c5b3 (diff)
downloadcogl-7283e0a49c5eeee9242ccd5857e2a51d6934b792.tar.gz
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>
Diffstat (limited to 'cogl/cogl-attribute-private.h')
-rw-r--r--cogl/cogl-attribute-private.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/cogl/cogl-attribute-private.h b/cogl/cogl-attribute-private.h
index 040784ed..68ed52d0 100644
--- a/cogl/cogl-attribute-private.h
+++ b/cogl/cogl-attribute-private.h
@@ -40,19 +40,26 @@ typedef enum
COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY
} CoglAttributeNameID;
+typedef struct _CoglAttributeNameState
+{
+ char *name;
+ CoglAttributeNameID name_id;
+ int name_index;
+ gboolean normalized_default;
+ int texture_unit;
+} CoglAttributeNameState;
+
struct _CoglAttribute
{
CoglObject _parent;
CoglAttributeBuffer *attribute_buffer;
- const char *name;
- CoglAttributeNameID name_id;
+ const CoglAttributeNameState *name_state;
gsize stride;
gsize offset;
int n_components;
CoglAttributeType type;
gboolean normalized;
- unsigned int texture_unit;
int immutable_ref;
};
@@ -71,6 +78,16 @@ typedef enum
COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 3
} CoglDrawFlags;
+/* During CoglContext initialization we register the "cogl_color_in"
+ * attribute name so it gets a global name_index of 0. We need to know
+ * the name_index for "cogl_color_in" in
+ * _cogl_pipeline_flush_gl_state() */
+#define COGL_ATTRIBUTE_COLOR_NAME_INDEX 0
+
+CoglAttributeNameState *
+_cogl_attribute_register_attribute_name (CoglContext *context,
+ const char *name);
+
CoglAttribute *
_cogl_attribute_immutable_ref (CoglAttribute *attribute);