#include "vbo.h"
#include "vbo_context.h"
-
-
-#define NR_LEGACY_ATTRIBS 16
-#define NR_GENERIC_ATTRIBS 16
#define NR_MAT_ATTRIBS 12
-
static GLuint check_size( const GLfloat *attr )
{
if (attr[3] != 1.0) return 4;
struct gl_client_array *arrays = vbo->legacy_currval;
GLuint i;
- memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_FF_MAX);
/* Set up a constant (StrideB == 0) array for each current
* attribute:
*/
- for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
struct gl_client_array *cl = &arrays[i];
/* Size will have to be determined at runtime:
struct gl_client_array *arrays = vbo->generic_currval;
GLuint i;
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_GENERIC_MAX);
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
struct gl_client_array *cl = &arrays[i];
/* This will have to be determined at runtime:
GLuint i;
/* When no vertex program, pull in the material attributes in
- * the 16..32 generic range.
+ * the generic range.
*/
- for (i = 0; i < 16; i++)
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++)
vbo->map_vp_none[i] = i;
- for (i = 0; i < 12; i++)
- vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
- for (i = 0; i < 4; i++)
- vbo->map_vp_none[28+i] = i;
+ for (i = 0; i < NR_MAT_ATTRIBS; i++)
+ vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
+ = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
+ for (i = NR_MAT_ATTRIBS; i < VERT_ATTRIB_GENERIC_MAX; i++)
+ vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = i;
for (i = 0; i < Elements(vbo->map_vp_arb); i++)
vbo->map_vp_arb[i] = i;
/* These just mirror the current arrayobj (todo: make arrayobj
* look like this and remove the mirror):
*/
- const struct gl_client_array *legacy_array[16];
- const struct gl_client_array *generic_array[16];
+ const struct gl_client_array *legacy_array[VERT_ATTRIB_FF_MAX];
+ const struct gl_client_array *generic_array[VERT_ATTRIB_GENERIC_MAX];
/* Arrays and current values manipulated according to program
* mode, etc. These are the attributes as seen by vertex
struct gl_client_array *arrays = exec->vtx.arrays;
unsigned i;
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
-
- for (i = 0; i < 16; ++i) {
- arrays[i ].BufferObj = NULL;
- arrays[i + 16].BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arrays[i ].BufferObj,
+ memcpy(arrays, vbo->legacy_currval,
+ VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_FF(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
vbo->legacy_currval[i].BufferObj);
- _mesa_reference_buffer_object(ctx, &arrays[i + 16].BufferObj,
+ }
+
+ memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
+ VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_GENERIC(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
vbo->generic_currval[i].BufferObj);
}
}
* generic slots. This is the only situation where material values
* are available as per-vertex attributes.
*/
- for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT(i);
}
}
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->mat_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
/* Could use just about anything, just to fill in the empty
* slots:
*/
- for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
/* There is no need to make _NEW_ARRAY dirty here for the TnL program,
* conventional, legacy arrays. No materials, and the generic
* slots are vacant.
*/
- for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
- if (exec->array.generic_array[i]->Enabled)
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
+ if (i < VERT_ATTRIB_GENERIC_MAX
+ && exec->array.generic_array[i]->Enabled)
inputs[i] = exec->array.generic_array[i];
else if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT_FF(i);
}
}
/* Could use just about anything, just to fill in the empty
* slots:
*/
- for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
- inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
- const_inputs |= 1 << i;
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
ctx->NewState |= _NEW_ARRAY;
inputs[0] = exec->array.legacy_array[0];
else {
inputs[0] = &vbo->legacy_currval[0];
- const_inputs |= 1 << 0;
+ const_inputs |= VERT_BIT_POS;
}
- for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
+ for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT_FF(i);
}
}
- for (i = 1; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
+ for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
if (exec->array.generic_array[i]->Enabled)
- inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
+ inputs[VERT_ATTRIB_GENERIC(i)] = exec->array.generic_array[i];
else {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
}
*/
switch (get_program_mode(exec->ctx)) {
case VP_NONE:
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
}
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
- ASSERT(attr + 16 < Elements(exec->vtx.inputs));
- exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
+ ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr];
}
map = vbo->map_vp_none;
break;
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
- ASSERT(attr + 16 < Elements(exec->vtx.inputs));
- exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
+ for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
+ ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr];
}
map = vbo->map_vp_arb;
*/
if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
(ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
- exec->vtx.inputs[16] = exec->vtx.inputs[0];
- exec->vtx.attrsz[16] = exec->vtx.attrsz[0];
- exec->vtx.attrptr[16] = exec->vtx.attrptr[0];
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0];
+ exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
+ exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
exec->vtx.attrsz[0] = 0;
}
break;
exec->vtx.bufferobj);
arrays[attr]._MaxElement = count; /* ??? */
- varying_inputs |= 1 << attr;
+ varying_inputs |= VERT_BIT(attr);
ctx->NewState |= _NEW_ARRAY;
}
}
struct gl_client_array *arrays = save->arrays;
unsigned i;
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
-
- for (i = 0; i < 16; ++i) {
- arrays[i ].BufferObj = NULL;
- arrays[i + 16].BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arrays[i ].BufferObj,
+ memcpy(arrays, vbo->legacy_currval,
+ VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_FF(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
vbo->legacy_currval[i].BufferObj);
- _mesa_reference_buffer_object(ctx, &arrays[i + 16].BufferObj,
+ }
+
+ memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
+ VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_GENERIC(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
vbo->generic_currval[i].BufferObj);
}
}
*/
switch (get_program_mode(ctx)) {
case VP_NONE:
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
save->inputs[attr] = &vbo->legacy_currval[attr];
}
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
- save->inputs[attr + 16] = &vbo->mat_currval[attr];
+ save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr];
}
map = vbo->map_vp_none;
break;
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
save->inputs[attr] = &vbo->legacy_currval[attr];
- save->inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
+ for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
+ save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr];
}
map = vbo->map_vp_arb;
*/
if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
(ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
- save->inputs[16] = save->inputs[0];
- node_attrsz[16] = node_attrsz[0];
+ save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[0];
+ node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0];
node_attrsz[0] = 0;
}
break;
assert(arrays[attr].BufferObj->Name);
buffer_offset += node->attrsz[src] * sizeof(GLfloat);
- varying_inputs |= 1<<attr;
+ varying_inputs |= VERT_BIT(attr);
ctx->NewState |= _NEW_ARRAY;
}
}