*/
GLfloat *current = (GLfloat *)vbo->current[i].Ptr;
fi_type tmp[8]; /* space for doubles */
- int dmul = 1;
-
- if (exec->vtx.attr[i].type == GL_DOUBLE ||
- exec->vtx.attr[i].type == GL_UNSIGNED_INT64_ARB)
- dmul = 2;
+ int dmul_shift = 0;
assert(exec->vtx.attr[i].size);
exec->vtx.attr[i].type == GL_UNSIGNED_INT64_ARB) {
memset(tmp, 0, sizeof(tmp));
memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attr[i].size * sizeof(GLfloat));
+ dmul_shift = 1;
} else {
COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
exec->vtx.attr[i].size,
exec->vtx.attr[i].type);
}
- if (exec->vtx.attr[i].type != vbo->current[i].Format.Type ||
- memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
- memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul);
-
- /* Given that we explicitly state size here, there is no need
- * for the COPY_CLEAN above, could just copy 16 bytes and be
- * done. The only problem is when Mesa accesses ctx->Current
- * directly.
- */
- /* Size here is in components - not bytes */
- vbo_set_vertex_format(&vbo->current[i].Format,
- exec->vtx.attr[i].size / dmul,
- exec->vtx.attr[i].type);
+ if (memcmp(current, tmp, 4 * sizeof(GLfloat) << dmul_shift) != 0) {
+ memcpy(current, tmp, 4 * sizeof(GLfloat) << dmul_shift);
- if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT &&
- i <= VBO_ATTRIB_MAT_BACK_INDEXES) {
+ if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT) {
ctx->NewState |= _NEW_MATERIAL;
ctx->PopAttribState |= GL_LIGHTING_BIT;
ctx->NewState |= _NEW_CURRENT_ATTRIB;
ctx->PopAttribState |= GL_CURRENT_BIT;
}
+
+ /* Given that we explicitly state size here, there is no need
+ * for the COPY_CLEAN above, could just copy 16 bytes and be
+ * done. The only problem is when Mesa accesses ctx->Current
+ * directly.
+ */
+ /* Size here is in components - not bytes */
+ if (exec->vtx.attr[i].type != vbo->current[i].Format.Type ||
+ (exec->vtx.attr[i].size >> dmul_shift) != vbo->current[i].Format.Size) {
+ vbo_set_vertex_format(&vbo->current[i].Format,
+ exec->vtx.attr[i].size >> dmul_shift,
+ exec->vtx.attr[i].type);
+ }
}
/* Colormaterial -- this kindof sucks.
const GLubyte size = attrib->Format.Size;
const GLenum16 type = attrib->Format.Type;
fi_type tmp[8];
- int dmul = 1;
+ int dmul_shift = 0;
if (type == GL_DOUBLE ||
- type == GL_UNSIGNED_INT64_ARB)
- dmul = 2;
-
- if (dmul == 2)
- memcpy(tmp, *data, size * dmul * sizeof(GLfloat));
- else
+ type == GL_UNSIGNED_INT64_ARB) {
+ dmul_shift = 1;
+ memcpy(tmp, *data, size * 2 * sizeof(GLfloat));
+ } else {
COPY_CLEAN_4V_TYPE_AS_UNION(tmp, size, *data, type);
+ }
- if (type != currval->Format.Type ||
- memcmp(currval->Ptr, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
- memcpy((fi_type*)currval->Ptr, tmp, 4 * sizeof(GLfloat) * dmul);
-
- vbo_set_vertex_format(&currval->Format, size, type);
+ if (memcmp(currval->Ptr, tmp, 4 * sizeof(GLfloat) << dmul_shift) != 0) {
+ memcpy((fi_type*)currval->Ptr, tmp, 4 * sizeof(GLfloat) << dmul_shift);
/* The fixed-func vertex program uses this. */
if (current_index == VBO_ATTRIB_MAT_FRONT_SHININESS ||
ctx->PopAttribState |= pop_state;
}
+ if (type != currval->Format.Type ||
+ (size >> dmul_shift) != currval->Format.Size)
+ vbo_set_vertex_format(&currval->Format, size >> dmul_shift, type);
+
*data += size;
}
}