glx: nitpick renames
[mesa.git] / src / glx / x11 / indirect_vertex_array.c
index d8b43f3963fd341bd1ccf4ed4282a2e32d1131d1..09d7244ba9243348141a04bcb8e9dbaa3efa6ee0 100644 (file)
@@ -32,7 +32,7 @@
 #include <GL/glxproto.h>
 #include "glxextensions.h"
 #include "indirect_vertex_array.h"
-#include "indirect_va_private.h"
+#include "indirect_vertex_array_priv.h"
 
 #define __GLX_PAD(n) (((n)+3) & ~3)
 
@@ -123,10 +123,8 @@ __glXInitVertexArrayState( __GLXcontext * gc )
     struct array_state_vector * arrays;
 
     unsigned array_count;
-    unsigned texture_units = 1;
-    unsigned i;
-    unsigned j;
-    unsigned vertex_program_attribs = 0;
+    int texture_units = 1, vertex_program_attribs = 0;
+    unsigned i, j;
 
     GLboolean got_fog = GL_FALSE;
     GLboolean got_secondary_color = GL_FALSE;
@@ -151,7 +149,7 @@ __glXInitVertexArrayState( __GLXcontext * gc )
      * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
      * GL_EDGE_FLAG_ARRAY are supported.
      */
-    
+
     array_count = 5;
     
     if ( __glExtensionBitIsEnabled( gc, GL_EXT_fog_coord_bit )
@@ -380,15 +378,17 @@ static GLboolean
 allocate_array_info_cache( struct array_state_vector * arrays,
                           size_t required_size )
 {
+#define MAX_HEADER_SIZE 20
     if ( arrays->array_info_cache_buffer_size < required_size ) {
-       GLubyte * temp = realloc( arrays->array_info_cache, required_size + 20 );
+       GLubyte * temp = realloc( arrays->array_info_cache_base,
+                                 required_size + MAX_HEADER_SIZE );
 
        if ( temp == NULL ) {
            return GL_FALSE;
        }
 
-       arrays->large_header = temp;
-       arrays->array_info_cache = temp + 20;
+       arrays->array_info_cache_base = temp;
+       arrays->array_info_cache = temp + MAX_HEADER_SIZE;
        arrays->array_info_cache_buffer_size = required_size;
     }
 
@@ -418,7 +418,6 @@ fill_array_info_cache( struct array_state_vector * arrays )
        }
     }
     
-    
     if ( arrays->new_DrawArrays_possible ) {
        assert( ! arrays->new_DrawArrays_possible );
     }
@@ -486,14 +485,14 @@ emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count )
 
     for ( i = 0 ; i < count ; i++ ) {
        if ( (pc + single_vertex_size) >= gc->bufEnd ) {
-           pc = __glXFlushRenderBuffer(gc, gc->pc);
+           pc = __glXFlushRenderBuffer(gc, pc);
        }
 
        pc = emit_element_none( pc, arrays, first + i );
     }
 
     if ( (pc + 4) >= gc->bufEnd ) {
-       pc = __glXFlushRenderBuffer(gc, gc->pc);
+       pc = __glXFlushRenderBuffer(gc, pc);
     }
 
     (void) memcpy( pc, end_cmd, 4 );
@@ -528,7 +527,7 @@ static GLubyte *
 emit_DrawArrays_header_old( __GLXcontext * gc,
                            struct array_state_vector * arrays,
                            size_t * elements_per_request,
-                           size_t * total_requests,
+                           unsigned int * total_requests,
                            GLenum mode, GLsizei count )
 {
     size_t command_size;
@@ -590,7 +589,7 @@ emit_DrawArrays_header_old( __GLXcontext * gc,
 
        command_size += 4;
 
-       pc = arrays->large_header;
+       pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
        *(uint32_t *)(pc +  0) = command_size;
        *(uint32_t *)(pc +  4) = X_GLrop_DrawArrays;
        *(uint32_t *)(pc +  8) = count;
@@ -727,7 +726,7 @@ emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
        unsigned  index = 0;
 
        if ( (pc + single_vertex_size) >= gc->bufEnd ) {
-           pc = __glXFlushRenderBuffer(gc, gc->pc);
+           pc = __glXFlushRenderBuffer(gc, pc);
        }
 
        switch( type ) {
@@ -745,7 +744,7 @@ emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
     }
 
     if ( (pc + 4) >= gc->bufEnd ) {
-       pc = __glXFlushRenderBuffer(gc, gc->pc);
+       pc = __glXFlushRenderBuffer(gc, pc);
     }
 
     (void) memcpy( pc, end_cmd, 4 );
@@ -774,9 +773,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
     unsigned total_requests = 0;
     unsigned i;
     unsigned req;
-    const GLuint   * ui_ptr = (const GLuint   *) indices;
-    const GLushort * us_ptr = (const GLushort *) indices;
-    const GLubyte  * ub_ptr = (const GLubyte  *) indices;
+    unsigned req_element=0;
 
 
     pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
@@ -793,25 +790,34 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
        }
 
        switch( type ) {
-       case GL_UNSIGNED_INT:
+       case GL_UNSIGNED_INT: {
+           const GLuint   * ui_ptr = (const GLuint   *) indices + req_element;
+
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(ui_ptr++);
                pc = emit_element_old( pc, arrays, index );
            }
            break;
-       case GL_UNSIGNED_SHORT:
+       }
+       case GL_UNSIGNED_SHORT: {
+           const GLushort * us_ptr = (const GLushort *) indices + req_element;
+
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(us_ptr++);
                pc = emit_element_old( pc, arrays, index );
            }
            break;
-       case GL_UNSIGNED_BYTE:
+       }
+       case GL_UNSIGNED_BYTE: {
+           const GLubyte  * ub_ptr = (const GLubyte  *) indices + req_element;
+
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(ub_ptr++);
                pc = emit_element_old( pc, arrays, index );
            }
            break;
        }
+       }
 
        if ( total_requests != 0 ) {
            __glXSendLargeChunk( gc, req, total_requests, gc->pc,
@@ -821,6 +827,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
        }
 
        count -= elements_per_request;
+       req_element += elements_per_request;
     }
 
 
@@ -1584,7 +1591,7 @@ void __indirect_glClientActiveTextureARB(GLenum texture)
     const GLint unit = (GLint) texture - GL_TEXTURE0;
 
 
-    if ( (unit < 0) || (unit > arrays->num_texture_units) ) {
+    if ( (unit < 0) || (unit >= arrays->num_texture_units) ) {
        __glXSetError(gc, GL_INVALID_ENUM);
        return;
     }
@@ -1662,7 +1669,7 @@ __glXGetArrayType( const __GLXattribute * const state,
                                                    key, index );
 
     if ( a != NULL ) {
-       *dest = (GLintptr) a->enabled;
+       *dest = (GLintptr) a->data_type;
     }
 
     return (a != NULL);
@@ -1759,13 +1766,14 @@ __glXPushArrayState( __GLXattribute * state )
     struct array_stack_state * stack = & arrays->stack[ (arrays->stack_index * arrays->num_arrays)];
     unsigned  i;
 
-
+    /* XXX are we pushing _all_ the necessary fields? */
     for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
        stack[i].data = arrays->arrays[i].data;
        stack[i].data_type = arrays->arrays[i].data_type;
        stack[i].user_stride = arrays->arrays[i].user_stride;
        stack[i].count = arrays->arrays[i].count;
        stack[i].key = arrays->arrays[i].key;
+        stack[i].index = arrays->arrays[i].index;
        stack[i].enabled = arrays->arrays[i].enabled;
     }