* compiled using the fallback opcode mechanism provided by dlist.c.
*/
struct vbo_save_vertex_list {
+ GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum attrtype[VBO_ATTRIB_MAX];
GLuint vertex_size; /**< size in GLfloats */
struct gl_client_array arrays[VBO_ATTRIB_MAX];
const struct gl_client_array *inputs[VBO_ATTRIB_MAX];
+ GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX]; /**< 1, 2, 3 or 4 */
GLenum attrtype[VBO_ATTRIB_MAX]; /**< GL_FLOAT, GL_INT, etc */
GLubyte active_sz[VBO_ATTRIB_MAX]; /**< 1, 2, 3 or 4 */
#include "main/api_arrayelt.h"
#include "main/vtxfmt.h"
#include "main/dispatch.h"
+#include "util/bitscan.h"
#include "vbo_context.h"
#include "vbo_noop.h"
/* Duplicate our template, increment refcounts to the storage structs:
*/
+ node->enabled = save->enabled;
memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
memcpy(node->attrtype, save->attrtype, sizeof(node->attrtype));
node->vertex_size = save->vertex_size;
_save_copy_to_current(struct gl_context *ctx)
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
- GLuint i;
+ GLbitfield64 enabled = save->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
- for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
- if (save->attrsz[i]) {
- save->currentsz[i][0] = save->attrsz[i];
- COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i],
- save->attrptr[i], save->attrtype[i]);
- }
+ while (enabled) {
+ const int i = u_bit_scan64(&enabled);
+ assert(save->attrsz[i]);
+
+ save->currentsz[i][0] = save->attrsz[i];
+ COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i],
+ save->attrptr[i], save->attrtype[i]);
}
}
_save_copy_from_current(struct gl_context *ctx)
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
- GLint i;
+ GLbitfield64 enabled = save->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
+
+ while (enabled) {
+ const int i = u_bit_scan64(&enabled);
- for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
switch (save->attrsz[i]) {
case 4:
save->attrptr[i][3] = save->current[i][3];
save->attrptr[i][1] = save->current[i][1];
case 1:
save->attrptr[i][0] = save->current[i][0];
+ break;
case 0:
+ assert(0);
break;
}
}
*/
oldsz = save->attrsz[attr];
save->attrsz[attr] = newsz;
+ save->enabled |= BITFIELD64_BIT(attr);
save->vertex_size += newsz - oldsz;
save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) /
if (save->copied.nr) {
const fi_type *data = save->copied.buffer;
fi_type *dest = save->buffer;
- GLuint j;
/* Need to note this and fix up at runtime (or loopback):
*/
}
for (i = 0; i < save->copied.nr; i++) {
- for (j = 0; j < VBO_ATTRIB_MAX; j++) {
- if (save->attrsz[j]) {
- if (j == attr) {
- if (oldsz) {
- COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data,
- save->attrtype[j]);
- data += oldsz;
- dest += newsz;
- }
- else {
- COPY_SZ_4V(dest, newsz, save->current[attr]);
- dest += newsz;
- }
+ GLbitfield64 enabled = save->enabled;
+ while (enabled) {
+ const int j = u_bit_scan64(&enabled);
+ assert(save->attrsz[j]);
+ if (j == attr) {
+ if (oldsz) {
+ COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data,
+ save->attrtype[j]);
+ data += oldsz;
+ dest += newsz;
}
else {
- GLint sz = save->attrsz[j];
- COPY_SZ_4V(dest, sz, data);
- data += sz;
- dest += sz;
+ COPY_SZ_4V(dest, newsz, save->current[attr]);
+ dest += newsz;
}
}
+ else {
+ GLint sz = save->attrsz[j];
+ COPY_SZ_4V(dest, sz, data);
+ data += sz;
+ dest += sz;
+ }
}
}
_save_reset_vertex(struct gl_context *ctx)
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
- GLuint i;
- for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ while (save->enabled) {
+ const int i = u_bit_scan64(&save->enabled);
+ assert(save->attrsz[i]);
save->attrsz[i] = 0;
save->active_sz[i] = 0;
}
#include "main/macros.h"
#include "main/light.h"
#include "main/state.h"
+#include "util/bitscan.h"
#include "vbo_context.h"
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;
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.