summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-04-04 17:36:40 -0600
committerBrian Paul <[email protected]>2011-04-04 17:42:43 -0600
commited9396782e40a9a6106f0b3168e723de077c5587 (patch)
treee88f00195651cdb85c8f9dcd6d3f48fc1a183a97 /src/mesa
parent6cab07685fa48174b310e52b26151a8fb8a8e6dc (diff)
st/mesa: use 'array' local var to simplify the code a bit
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_draw.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 0eab4f73058..7ed0b8e9651 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -253,8 +253,9 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
for (attr = 0; attr < vpv->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
- const struct gl_buffer_object *bufObj = arrays[mesaAttr]->BufferObj;
- const GLsizei stride = arrays[mesaAttr]->StrideB; /* in bytes */
+ const struct gl_client_array *array = arrays[mesaAttr];
+ const struct gl_buffer_object *bufObj = array->BufferObj;
+ const GLsizei stride = array->StrideB; /* in bytes */
if (firstStride < 0) {
firstStride = stride;
@@ -272,9 +273,9 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
return GL_FALSE;
}
if (!client_addr) {
- client_addr = arrays[mesaAttr]->Ptr;
+ client_addr = array->Ptr;
}
- else if (abs(arrays[mesaAttr]->Ptr - client_addr) > firstStride) {
+ else if (abs(array->Ptr - client_addr) > firstStride) {
/* arrays start too far apart */
return GL_FALSE;
}
@@ -327,9 +328,10 @@ setup_interleaved_attribs(struct gl_context *ctx,
for (attr = 0; attr < vpv->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
- struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
+ const struct gl_client_array *array = arrays[mesaAttr];
+ struct gl_buffer_object *bufobj = array->BufferObj;
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- GLsizei stride = arrays[mesaAttr]->StrideB;
+ GLsizei stride = array->StrideB;
if (attr == 0) {
if (bufobj && bufobj->Name) {
@@ -337,7 +339,7 @@ setup_interleaved_attribs(struct gl_context *ctx,
pipe_resource_reference(&vbuffer->buffer, stobj->buffer);
vbuffer->buffer_offset = pointer_to_offset(low_addr);
} else {
- uint divisor = arrays[mesaAttr]->InstanceDivisor;
+ uint divisor = array->InstanceDivisor;
uint length = (divisor ? num_instances / divisor : max_index) + 1;
vbuffer->buffer =
pipe_user_buffer_create(pipe->screen, (void*)low_addr,
@@ -353,15 +355,13 @@ setup_interleaved_attribs(struct gl_context *ctx,
vbuffer->stride = stride; /* in bytes */
}
- velements[attr].src_offset =
- (unsigned) (arrays[mesaAttr]->Ptr - low_addr);
- velements[attr].instance_divisor = arrays[mesaAttr]->InstanceDivisor;
+ velements[attr].src_offset = (unsigned) (array->Ptr - low_addr);
+ velements[attr].instance_divisor = array->InstanceDivisor;
velements[attr].vertex_buffer_index = 0;
- velements[attr].src_format =
- st_pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size,
- arrays[mesaAttr]->Format,
- arrays[mesaAttr]->Normalized);
+ velements[attr].src_format = st_pipe_vertex_format(array->Type,
+ array->Size,
+ array->Format,
+ array->Normalized);
assert(velements[attr].src_format);
}
}
@@ -389,8 +389,9 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
for (attr = 0; attr < vpv->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
- struct gl_buffer_object *bufobj = arrays[mesaAttr]->BufferObj;
- GLsizei stride = arrays[mesaAttr]->StrideB;
+ const struct gl_client_array *array = arrays[mesaAttr];
+ struct gl_buffer_object *bufobj = array->BufferObj;
+ GLsizei stride = array->StrideB;
if (bufobj && bufobj->Name) {
/* Attribute data is in a VBO.
@@ -402,25 +403,24 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
vbuffer[attr].buffer = NULL;
pipe_resource_reference(&vbuffer[attr].buffer, stobj->buffer);
- vbuffer[attr].buffer_offset = pointer_to_offset(arrays[mesaAttr]->Ptr);
+ vbuffer[attr].buffer_offset = pointer_to_offset(array->Ptr);
}
else {
/* wrap user data */
uint bytes;
void *ptr;
- if (arrays[mesaAttr]->Ptr) {
+ if (array->Ptr) {
if (stride == 0) {
- bytes = _mesa_sizeof_type(arrays[mesaAttr]->Type)
- * arrays[mesaAttr]->Size;
+ bytes = _mesa_sizeof_type(array->Type) * array->Size;
}
else {
- uint divisor = arrays[mesaAttr]->InstanceDivisor;
+ uint divisor = array->InstanceDivisor;
uint length = (divisor ? num_instances / divisor : max_index) + 1;
bytes = stride * length;
}
- ptr = (void *) arrays[mesaAttr]->Ptr;
+ ptr = (void *) array->Ptr;
}
else {
/* no array, use ctx->Current.Attrib[] value */
@@ -448,13 +448,12 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
vbuffer[attr].stride = stride; /* in bytes */
velements[attr].src_offset = 0;
- velements[attr].instance_divisor = arrays[mesaAttr]->InstanceDivisor;
+ velements[attr].instance_divisor = array->InstanceDivisor;
velements[attr].vertex_buffer_index = attr;
- velements[attr].src_format
- = st_pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size,
- arrays[mesaAttr]->Format,
- arrays[mesaAttr]->Normalized);
+ velements[attr].src_format = st_pipe_vertex_format(array->Type,
+ array->Size,
+ array->Format,
+ array->Normalized);
assert(velements[attr].src_format);
}
}