X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=inline;f=src%2Fglx%2Findirect_vertex_array.c;h=2bf2ff1bdb6bf7263b567d531efbfdc158578fcd;hb=134728fdaef9d2a5d072d25b31437ac0fecd9076;hp=ec0e654ceae6bfe53baca2a3d98e33c1c5b92604;hpb=3ce4375912c8ea488460e593e07c5bb15b92dca9;p=mesa.git diff --git a/src/glx/indirect_vertex_array.c b/src/glx/indirect_vertex_array.c index ec0e654ceae..2bf2ff1bdb6 100644 --- a/src/glx/indirect_vertex_array.c +++ b/src/glx/indirect_vertex_array.c @@ -84,9 +84,9 @@ static struct array_state *get_array_entry(const struct array_state_vector *arrays, GLenum key, unsigned index); static void fill_array_info_cache(struct array_state_vector *arrays); -static GLboolean validate_mode(__GLXcontext * gc, GLenum mode); -static GLboolean validate_count(__GLXcontext * gc, GLsizei count); -static GLboolean validate_type(__GLXcontext * gc, GLenum type); +static GLboolean validate_mode(struct glx_context * gc, GLenum mode); +static GLboolean validate_count(struct glx_context * gc, GLsizei count); +static GLboolean validate_type(struct glx_context * gc, GLenum type); /** @@ -109,20 +109,16 @@ const GLuint __glXTypeSize_table[16] = { * __glXInitVertexArrayState(). */ void -__glXFreeVertexArrayState(__GLXcontext * gc) +__glXFreeVertexArrayState(struct glx_context * gc) { __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; if (arrays) { - if (arrays->stack) { - free(arrays->stack); - arrays->stack = NULL; - } - if (arrays->arrays) { - free(arrays->arrays); - arrays->arrays = NULL; - } + free(arrays->stack); + arrays->stack = NULL; + free(arrays->arrays); + arrays->arrays = NULL; free(arrays); state->array_state = NULL; } @@ -135,16 +131,13 @@ __glXFreeVertexArrayState(__GLXcontext * gc) * \param gc GLX context whose vertex array state is to be initialized. * * \warning - * This function may only be called after __GLXcontext::gl_extension_bits, - * __GLXcontext::server_minor, and __GLXcontext::server_major have been + * This function may only be called after struct glx_context::gl_extension_bits, + * struct glx_context::server_minor, and __GLXcontext::server_major have been * initialized. These values are used to determine what vertex arrays are * supported. - * - * \bug - * Return values from malloc are not properly tested. */ void -__glXInitVertexArrayState(__GLXcontext * gc) +__glXInitVertexArrayState(struct glx_context * gc) { __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays; @@ -158,7 +151,11 @@ __glXInitVertexArrayState(__GLXcontext * gc) arrays = calloc(1, sizeof(struct array_state_vector)); - state->array_state = arrays; + + if (arrays == NULL) { + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol; arrays->new_DrawArrays_possible = GL_FALSE; @@ -208,6 +205,12 @@ __glXInitVertexArrayState(__GLXcontext * gc) arrays->num_arrays = array_count; arrays->arrays = calloc(array_count, sizeof(struct array_state)); + if (arrays->arrays == NULL) { + free(arrays); + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + arrays->arrays[0].data_type = GL_FLOAT; arrays->arrays[0].count = 3; arrays->arrays[0].key = GL_NORMAL_ARRAY; @@ -278,7 +281,7 @@ __glXInitVertexArrayState(__GLXcontext * gc) i += vertex_program_attribs; - /* Vertex array *must* be last becuase of the way that + /* Vertex array *must* be last because of the way that * emit_DrawArrays_none works. */ @@ -293,6 +296,18 @@ __glXInitVertexArrayState(__GLXcontext * gc) arrays->stack = malloc(sizeof(struct array_stack_state) * arrays->num_arrays * __GL_CLIENT_ATTRIB_STACK_DEPTH); + + if (arrays->stack == NULL) { + free(arrays->arrays); + free(arrays); + __glXSetError(gc, GL_OUT_OF_MEMORY); + return; + } + + /* Everything went ok so we put vertex array state in place + * in context. + */ + state->array_state = arrays; } @@ -487,7 +502,7 @@ fill_array_info_cache(struct array_state_vector *arrays) void emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -549,7 +564,7 @@ emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count) * A pointer to the buffer for array data. */ static GLubyte * -emit_DrawArrays_header_old(__GLXcontext * gc, +emit_DrawArrays_header_old(struct glx_context * gc, struct array_state_vector *arrays, size_t * elements_per_request, unsigned int *total_requests, @@ -658,7 +673,7 @@ emit_DrawArrays_header_old(__GLXcontext * gc, void emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -720,7 +735,7 @@ void emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -787,7 +802,7 @@ void emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -875,7 +890,7 @@ emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type, * \c GL_TRUE if the argument is valid, \c GL_FALSE if is not. */ static GLboolean -validate_mode(__GLXcontext * gc, GLenum mode) +validate_mode(struct glx_context * gc, GLenum mode) { switch (mode) { case GL_POINTS: @@ -908,7 +923,7 @@ validate_mode(__GLXcontext * gc, GLenum mode) * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. */ static GLboolean -validate_count(__GLXcontext * gc, GLsizei count) +validate_count(struct glx_context * gc, GLsizei count) { if (count < 0) { __glXSetError(gc, GL_INVALID_VALUE); @@ -927,7 +942,7 @@ validate_count(__GLXcontext * gc, GLsizei count) * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not. */ static GLboolean -validate_type(__GLXcontext * gc, GLenum type) +validate_type(struct glx_context * gc, GLenum type) { switch (type) { case GL_UNSIGNED_INT: @@ -944,7 +959,7 @@ validate_type(__GLXcontext * gc, GLenum type) void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -963,7 +978,7 @@ __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count) void __indirect_glArrayElement(GLint index) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -989,7 +1004,7 @@ void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -1011,7 +1026,7 @@ __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -1034,10 +1049,10 @@ __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, void -__indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, - GLsizei primcount) +__indirect_glMultiDrawArrays(GLenum mode, const GLint *first, + const GLsizei *count, GLsizei primcount) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -1060,10 +1075,10 @@ __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, - GLenum type, const GLvoid ** indices, + GLenum type, const GLvoid * const * indices, GLsizei primcount) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); const __GLXattribute *state = (const __GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; @@ -1119,7 +1134,7 @@ __indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv }; uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1164,7 +1179,7 @@ __indirect_glNormalPointer(GLenum type, GLsizei stride, const GLvoid * pointer) { uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1235,7 +1250,7 @@ __indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv }; uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1290,7 +1305,7 @@ void __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer) { uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1335,7 +1350,7 @@ __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer) void __indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1397,7 +1412,7 @@ __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, }; uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1466,11 +1481,11 @@ __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void -__indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, +__indirect_glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) { uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1526,11 +1541,11 @@ __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, void -__indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, +__indirect_glFogCoordPointer(GLenum type, GLsizei stride, const GLvoid * pointer) { uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1568,7 +1583,7 @@ __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, void -__indirect_glVertexAttribPointerARB(GLuint index, GLint size, +__indirect_glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer) { @@ -1577,7 +1592,7 @@ __indirect_glVertexAttribPointerARB(GLuint index, GLint size, static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 }; uint16_t opcode; - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); __GLXattribute *state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *arrays = state->array_state; struct array_state *a; @@ -1690,7 +1705,7 @@ __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) { - __GLXcontext *gc = __glXGetCurrentContext(); + struct glx_context *gc = __glXGetCurrentContext(); GLboolean normalized = GL_FALSE; @@ -1705,7 +1720,7 @@ __indirect_glVertexAttribPointerNV(GLuint index, GLint size, case GL_SHORT: case GL_FLOAT: case GL_DOUBLE: - __indirect_glVertexAttribPointerARB(index, size, type, + __indirect_glVertexAttribPointer(index, size, type, normalized, stride, pointer); return; default: @@ -1716,9 +1731,9 @@ __indirect_glVertexAttribPointerNV(GLuint index, GLint size, void -__indirect_glClientActiveTextureARB(GLenum texture) +__indirect_glClientActiveTexture(GLenum texture) { - __GLXcontext *const gc = __glXGetCurrentContext(); + struct glx_context *const gc = __glXGetCurrentContext(); __GLXattribute *const state = (__GLXattribute *) (gc->client_state_private); struct array_state_vector *const arrays = state->array_state; @@ -1965,13 +1980,13 @@ __glXPopArrayState(__GLXattribute * state) stack[i].user_stride, stack[i].data); break; case GL_SECONDARY_COLOR_ARRAY: - __indirect_glSecondaryColorPointerEXT(stack[i].count, + __indirect_glSecondaryColorPointer(stack[i].count, stack[i].data_type, stack[i].user_stride, stack[i].data); break; case GL_FOG_COORDINATE_ARRAY: - __indirect_glFogCoordPointerEXT(stack[i].data_type, + __indirect_glFogCoordPointer(stack[i].data_type, stack[i].user_stride, stack[i].data); break;