summaryrefslogtreecommitdiff
path: root/cogl/cogl-primitive-private.h
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-09-20 01:24:16 +0100
committerRobert Bragg <robert@linux.intel.com>2011-09-21 15:50:08 +0100
commitd739892a5cf08084835795337b4444f1678ba8c8 (patch)
treea12f75581db307b90b3e06d77013145bc26acf0d /cogl/cogl-primitive-private.h
parent791773987ca70e34b550bae2687b1777459cd8ff (diff)
downloadcogl-d739892a5cf08084835795337b4444f1678ba8c8.tar.gz
primitive: micro optimize primitive allocations
We've started seeing cases where we want to allocate lots of one-shot primitives per-frame and the cost of allocating primitives becomes important in this case since it can start being noticeable in profiles. The main cost for allocating primitives was the GArray allocation and appending the attributes to the array. This updates the code to simply over allocate the primitive storage so we can embed the list of attributes directly in that allocation. If the user later sets new attributes and there isn't enough embedded space then a separate slice allocation for the new attributes is made but still this should be far less costly than using a GArray as before. Most of the time we would expect when setting new attributes there will still be the same number of attributes, so the embedded space can simple be reused. Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl-primitive-private.h')
-rw-r--r--cogl/cogl-primitive-private.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/cogl/cogl-primitive-private.h b/cogl/cogl-primitive-private.h
index c50181f5..3deb1e79 100644
--- a/cogl/cogl-primitive-private.h
+++ b/cogl/cogl-primitive-private.h
@@ -39,9 +39,14 @@ struct _CoglPrimitive
int first_vertex;
int n_vertices;
CoglIndices *indices;
- GArray *attributes;
int immutable_ref;
+
+ CoglAttribute **attributes;
+ int n_attributes;
+
+ int n_embedded_attributes;
+ CoglAttribute *embedded_attribute;
};
CoglPrimitive *