aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/vbo/vbo_exec_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/vbo/vbo_exec_array.c')
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c128
1 files changed, 49 insertions, 79 deletions
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 7023380a1..97221a54d 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -270,11 +270,11 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
const void *elemMap;
GLint i, k;
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
elemMap = ctx->Driver.MapBufferRange(ctx, 0,
- ctx->Array.ElementArrayBufferObj->Size,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Size,
GL_MAP_READ_BIT,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
elements = ADD_POINTERS(elements, elemMap);
}
@@ -297,29 +297,15 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
}
/* check element j of each enabled array */
- check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j);
- check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j);
- check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j);
- check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j);
- for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
- check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j);
- }
for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
- check_array_data(ctx, &arrayObj->VertexAttrib[k],
- VERT_ATTRIB_GENERIC0 + k, j);
+ check_array_data(ctx, &arrayObj->VertexAttrib[k], k, j);
}
}
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
+ if (_mesa_is_bufferobj(arrayObj->ElementArrayBufferObj)) {
+ ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
}
- unmap_array_buffer(ctx, &arrayObj->Vertex);
- unmap_array_buffer(ctx, &arrayObj->Normal);
- unmap_array_buffer(ctx, &arrayObj->Color);
- for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
- unmap_array_buffer(ctx, &arrayObj->TexCoord[k]);
- }
for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]);
}
@@ -398,29 +384,12 @@ bind_array_obj(struct gl_context *ctx)
struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
GLuint i;
- /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array
- * rather than as individual named arrays. Then this function can
- * go away.
- */
- exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex;
- exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight;
- exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal;
- exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color;
- exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor;
- exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord;
- exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index;
- if (arrayObj->PointSize.Enabled) {
- /* this aliases COLOR_INDEX */
- exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize;
- }
- exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag;
-
- for (i = 0; i < Elements(arrayObj->TexCoord); i++)
- exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++)
+ exec->array.legacy_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_FF(i)];
- for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
assert(i < Elements(exec->array.generic_array));
- exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
+ exec->array.generic_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
}
}
@@ -439,7 +408,7 @@ recalculate_input_bindings(struct gl_context *ctx)
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
const struct gl_client_array **inputs = &exec->array.inputs[0];
- GLbitfield const_inputs = 0x0;
+ GLbitfield64 const_inputs = 0x0;
GLuint i;
switch (get_program_mode(ctx)) {
@@ -449,26 +418,26 @@ recalculate_input_bindings(struct gl_context *ctx)
* 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,
@@ -485,23 +454,24 @@ recalculate_input_bindings(struct gl_context *ctx)
* 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;
@@ -521,24 +491,24 @@ recalculate_input_bindings(struct gl_context *ctx)
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);
}
}
@@ -547,7 +517,7 @@ recalculate_input_bindings(struct gl_context *ctx)
break;
}
- _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
+ _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
}
@@ -727,15 +697,15 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLvoid *map =
ctx->Driver.MapBufferRange(ctx, 0,
- ctx->Array.ElementArrayBufferObj->Size,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Size,
GL_MAP_READ_BIT,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
switch (type) {
case GL_UNSIGNED_BYTE:
{
const GLubyte *us = (const GLubyte *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size; i++) {
printf("%02x ", us[i]);
if (i % 32 == 31)
printf("\n");
@@ -747,7 +717,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLushort *us = (const GLushort *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 2; i++) {
printf("%04x ", us[i]);
if (i % 16 == 15)
printf("\n");
@@ -759,7 +729,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLuint *us = (const GLuint *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 4; i++) {
printf("%08x ", us[i]);
if (i % 8 == 7)
printf("\n");
@@ -771,7 +741,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
;
}
- ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
+ ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
}
@@ -807,7 +777,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
ib.count = count;
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = indices;
prim[0].begin = 1;
@@ -909,8 +879,8 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"\tThis should probably be fixed in the application.",
start, end, count, type, indices,
ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ElementArrayBufferObj->Name,
- (int) ctx->Array.ElementArrayBufferObj->Size);
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
+ (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
}
if (0)
@@ -924,7 +894,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
*/
if (0) {
GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
if (max >= ctx->Array.ArrayObj->_MaxElement) {
if (warnCount < 10) {
_mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
@@ -934,8 +904,8 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"\tSkipping the glDrawRangeElements() call",
start, end, count, type, indices, max,
ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ElementArrayBufferObj->Name,
- (int) ctx->Array.ElementArrayBufferObj->Size);
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
+ (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
}
}
/* XXX we could also find the min index and compare to 'start'
@@ -958,7 +928,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
"base %d\n",
start, end, type, count,
- ctx->Array.ElementArrayBufferObj->Name,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
basevertex);
}
@@ -1171,13 +1141,13 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
* subranges of the index buffer as one large index buffer may lead to
* us reading unmapped memory.
*/
- if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
+ if (!_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj))
fallback = GL_TRUE;
if (!fallback) {
ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = (void *)min_index_ptr;
for (i = 0; i < primcount; i++) {
@@ -1204,7 +1174,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
for (i = 0; i < primcount; i++) {
ib.count = count[i];
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = indices[i];
prim[0].begin = 1;