summaryrefslogtreecommitdiff
path: root/cogl/cogl-pipeline-private.h
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-11-04 17:56:44 +0000
committerNeil Roberts <neil@linux.intel.com>2011-11-16 16:32:11 +0000
commit4a7cd0d2ac0b2e794d11b55dec43f3a688fff63c (patch)
tree2bfb082aeee5464880f1e4b037738ed7cc30182b /cogl/cogl-pipeline-private.h
parentf23b12a886b117d39b76490c5bceb30eed3cb239 (diff)
downloadcogl-4a7cd0d2ac0b2e794d11b55dec43f3a688fff63c.tar.gz
cogl-pipeline: Store the uniform overrides in an array instead of list
Previously the uniform overrides were stored in a linked list. Now they are stored in a g_malloc'd array. The values are still tightly packed so that there is only a value for each uniform that has a corresponding bit in override_mask. The allocated size of the array always exactly corresponds to the number of bits set in the override_mask. This means that when a new uniform value is set on a pipeline it will have to grow the array and copy the old values in. The assumption is that setting a value for a new uniform is much less frequent then setting a value for an existing uniform so it makes more sense to optimise the latter. The advantage of using an array is that we can quickly jump to right boxed value given a uniform location by doing a population count in the bitmask for the number of bits less than the given uniform location. This can be done in O(1) time whereas the old approach using a list would scale by the number of bits set. Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'cogl/cogl-pipeline-private.h')
-rw-r--r--cogl/cogl-pipeline-private.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index 4c2dd2b8..a6100a8c 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -339,32 +339,18 @@ typedef struct
CoglWinding front_winding;
} CoglPipelineCullFaceState;
-typedef struct _CoglPipelineUniformOverride CoglPipelineUniformOverride;
-
-COGL_SLIST_HEAD (CoglPipelineUniformOverrideList,
- CoglPipelineUniformOverride);
-
-struct _CoglPipelineUniformOverride
-{
- COGL_SLIST_ENTRY (CoglPipelineUniformOverride) list_node;
-
- /* We don't need to store the location of the uniform here because
- it is implicit from the order in the list */
-
- /* One of these overrides can effectively remove a uniform by
- setting the boxed value type to none. In that case no attempt
- will be made to upload the value */
-
- CoglBoxedValue value;
-};
-
typedef struct
{
CoglBitmask override_mask;
+
+ /* This is an array of values. Only the uniforms that have a bit set
+ in override_mask have a corresponding value here. The uniform's
+ location is implicit from the order in this array */
+ CoglBoxedValue *override_values;
+
/* Uniforms that have been modified since this pipeline was last
flushed */
CoglBitmask changed_mask;
- CoglPipelineUniformOverrideList override_list;
} CoglPipelineUniformsState;
typedef struct