summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_save_draw.c
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2016-05-22 14:10:19 +0200
committerMathias Fröhlich <[email protected]>2016-06-16 05:50:55 +0200
commit0e73d9454d626f4ac96be51733d3d3db4b77392c (patch)
tree08e171c55dc3a550b7d6e6ce7974bd073c7acae8 /src/mesa/vbo/vbo_save_draw.c
parentbc4e0c486874ee8c6f2e616b91589a1da63164d8 (diff)
vbo: Use a bitmask to track the active arrays in vbo_save*.
The use of a bitmask makes functions iterating only active attributes less visible in profiles. v2: Use _mesa_bit_scan{,64} instead of open coding. v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}. Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_save_draw.c')
-rw-r--r--src/mesa/vbo/vbo_save_draw.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index b1fd6892026..7881ce17d0f 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -34,6 +34,7 @@
#include "main/macros.h"
#include "main/light.h"
#include "main/state.h"
+#include "util/bitscan.h"
#include "vbo_context.h"
@@ -49,7 +50,8 @@ _playback_copy_to_current(struct gl_context *ctx,
struct vbo_context *vbo = vbo_context(ctx);
fi_type vertex[VBO_ATTRIB_MAX * 4];
fi_type *data;
- GLuint i, offset;
+ GLbitfield64 mask;
+ GLuint offset;
if (node->current_size == 0)
return;
@@ -73,35 +75,36 @@ _playback_copy_to_current(struct gl_context *ctx,
data += node->attrsz[0]; /* skip vertex position */
}
- for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
- if (node->attrsz[i]) {
- fi_type *current = (fi_type *)vbo->currval[i].Ptr;
- fi_type tmp[4];
-
- COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
- node->attrsz[i],
- data,
- node->attrtype[i]);
+ mask = node->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
+ while (mask) {
+ const int i = u_bit_scan64(&mask);
+ fi_type *current = (fi_type *)vbo->currval[i].Ptr;
+ fi_type tmp[4];
+ assert(node->attrsz[i]);
+
+ COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
+ node->attrsz[i],
+ data,
+ node->attrtype[i]);
+
+ if (node->attrtype[i] != vbo->currval[i].Type ||
+ memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) {
+ memcpy(current, tmp, 4 * sizeof(GLfloat));
- if (node->attrtype[i] != vbo->currval[i].Type ||
- memcmp(current, tmp, 4 * sizeof(GLfloat)) != 0) {
- memcpy(current, tmp, 4 * sizeof(GLfloat));
-
- vbo->currval[i].Size = node->attrsz[i];
- vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat);
- vbo->currval[i].Type = node->attrtype[i];
- vbo->currval[i].Integer =
- vbo_attrtype_to_integer_flag(node->attrtype[i]);
+ vbo->currval[i].Size = node->attrsz[i];
+ vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat);
+ vbo->currval[i].Type = node->attrtype[i];
+ vbo->currval[i].Integer =
+ vbo_attrtype_to_integer_flag(node->attrtype[i]);
- if (i >= VBO_ATTRIB_FIRST_MATERIAL &&
- i <= VBO_ATTRIB_LAST_MATERIAL)
- ctx->NewState |= _NEW_LIGHT;
+ if (i >= VBO_ATTRIB_FIRST_MATERIAL &&
+ i <= VBO_ATTRIB_LAST_MATERIAL)
+ ctx->NewState |= _NEW_LIGHT;
- ctx->NewState |= _NEW_CURRENT_ATTRIB;
- }
-
- data += node->attrsz[i];
+ ctx->NewState |= _NEW_CURRENT_ATTRIB;
}
+
+ data += node->attrsz[i];
}
/* Colormaterial -- this kindof sucks.