diff options
-rwxr-xr-x | bin/mklib | 19 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | progs/tests/.gitignore | 2 | ||||
-rw-r--r-- | progs/tests/Makefile | 2 | ||||
-rw-r--r-- | progs/tests/SConscript | 2 | ||||
-rw-r--r-- | progs/tests/scissor-viewport.c | 138 | ||||
-rw-r--r-- | progs/tests/scissor.c | 168 | ||||
-rw-r--r-- | scons/gallium.py | 17 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 6 | ||||
-rw-r--r-- | src/mesa/main/config.h | 4 | ||||
-rw-r--r-- | src/mesa/main/debug.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bufferobjects.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 43 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 29 |
16 files changed, 394 insertions, 60 deletions
diff --git a/bin/mklib b/bin/mklib index 2fd95ba7751..24449450068 100755 --- a/bin/mklib +++ b/bin/mklib @@ -885,6 +885,17 @@ case $ARCH in CYGWIN*) # GCC-based environment + if [ $NOPREFIX = 1 ] ; then + # No "lib" or ".so" part + echo "mklib: Making CYGWIN shared library: " ${LIBNAME} + OPTS="-shared -Wl,--enable-auto-image-base" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + rm -f ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS=${LIBNAME} + else CYGNAME="cyg${LIBNAME}" # prefix with "cyg" LIBNAME="lib${LIBNAME}" # prefix with "lib" @@ -901,11 +912,11 @@ case $ARCH in # finish up FINAL_LIBS=${LIBNAME}.a else - OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" + OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" if [ "${ALTOPTS}" ] ; then OPTS=${ALTOPTS} fi - echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll + echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll if [ $CPLUSPLUS = 1 ] ; then LINK="g++" @@ -914,7 +925,8 @@ case $ARCH in fi # rm any old libs - rm -f ${LIBNAME}-${MAJOR}.dll + rm -f ${CYGNAME}-${MAJOR}.dll + rm -f ${LIBNAME}-${MAJOR}.dll.a rm -f ${LIBNAME}.dll.a rm -f ${LIBNAME}.a @@ -927,6 +939,7 @@ case $ARCH in # special case for installing in bin FINAL_BINS="${CYGNAME}-${MAJOR}.dll" fi + fi ;; 'example') diff --git a/configure.ac b/configure.ac index eb2733c0dc8..d4a8222df0d 100644 --- a/configure.ac +++ b/configure.ac @@ -227,6 +227,8 @@ else case "$host_os" in darwin* ) LIB_EXTENSION='dylib' ;; + cygwin* ) + LIB_EXTENSION='dll' ;; * ) LIB_EXTENSION='so' ;; esac @@ -1078,6 +1080,9 @@ if test "x$APP_LIB_DEPS" = x; then solaris*) APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm" ;; + cygwin*) + APP_LIB_DEPS="-lX11" + ;; *) APP_LIB_DEPS="-lm" ;; diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore index 959ddcc51f6..d6a85387676 100644 --- a/progs/tests/.gitignore +++ b/progs/tests/.gitignore @@ -62,6 +62,8 @@ readrate readtex.c readtex.h rubberband +scissor +scissor-viewport seccolor shader_api shaderutil.c diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 1a3ba4f1816..5069817be3e 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -71,6 +71,8 @@ SOURCES = \ random.c \ readrate.c \ rubberband.c \ + scissor.c \ + scissor-viewport.c \ seccolor.c \ shader_api.c \ sharedtex.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index 453fcecd9c1..9d89ff6a0d0 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -95,6 +95,8 @@ progs = [ 'random', 'readrate', 'rubberband', + 'scissor', + 'scissor-viewport', 'seccolor', 'shader_api', 'stencil_twoside', diff --git a/progs/tests/scissor-viewport.c b/progs/tests/scissor-viewport.c new file mode 100644 index 00000000000..582e65fb72b --- /dev/null +++ b/progs/tests/scissor-viewport.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * Copyright (c) 2009 VMware, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + +struct program +{ + unsigned width; + unsigned height; + int i; +}; + +struct program prog; + +static void init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + fflush(stderr); + + prog.i = 0; +} + +static void reshape(int width, int height) +{ + glViewport(0, 0, 100, 100); + + prog.width = width; + prog.height = height; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + glutPostRedisplay(); + return; + } +} + +static void drawQuad(void) +{ + glBegin(GL_QUADS); + glVertex2d(-1.0, -1.0); + glVertex2d( 1.0, -1.0); + glVertex2d( 1.0, 1.0); + glVertex2d(-1.0, 1.0); + glEnd(); +} + +static void draw(void) +{ + int i; + + glClearColor(0.0, 0.0, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + i = prog.i++; + if (prog.i >= 3) + prog.i = 0; + + glEnable(GL_SCISSOR_TEST); + + { + glColor4d(1.0, 0.0, 0.0, 1.0); + + glScissor(i, i, 10 - 2*i, 10 - 2*i); + drawQuad(); + } + + glDisable(GL_SCISSOR_TEST); + + //glutSwapBuffers(); + glFlush(); +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + prog.width = 200; + prog.height = 200; + + glutInitWindowPosition(100, 0); + glutInitWindowSize(prog.width, prog.height); + + //type = GLUT_RGB | GLUT_DOUBLE; + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + init(); + + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutDisplayFunc(draw); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/scissor.c b/progs/tests/scissor.c new file mode 100644 index 00000000000..2dfd2174e82 --- /dev/null +++ b/progs/tests/scissor.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * Copyright (c) 2009 VMware, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + +struct program +{ + unsigned width; + unsigned height; + unsigned quads; +}; + +struct program prog; + +static void init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + fflush(stderr); +} + +static void reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + prog.width = width; + prog.height = height; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + prog.quads = !prog.quads; + glutPostRedisplay(); + return; + } +} + +static void drawQuad(void) +{ + + if (prog.quads) { + glBegin(GL_QUADS); + glVertex2d(-1.0, -1.0); + glVertex2d( 1.0, -1.0); + glVertex2d( 1.0, 1.0); + glVertex2d(-1.0, 1.0); + glEnd(); + } else { + glClear(GL_COLOR_BUFFER_BIT); + } +} + +static void draw(void) +{ + glClearColor(0.0, 0.0, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + printf("drawing with %s\n", prog.quads ? "quads" : "clears"); + + glEnable(GL_SCISSOR_TEST); + + { + glClearColor(1.0, 0.0, 0.0, 1.0); + glColor4d(1.0, 0.0, 0.0, 1.0); + + glScissor(1, 1, 10, 10); + drawQuad(); + glScissor(1, prog.height - 11, 10, 10); + drawQuad(); + glScissor(prog.width - 11, prog.height - 11, 10, 10); + drawQuad(); + } + + { + glClearColor(0.0, 1.0, 0.0, 1.0); + glColor4d(0.0, 1.0, 0.0, 1.0); + + glScissor(12, 1, 10, 10); + drawQuad(); + glScissor(12, prog.height - 11, 10, 10); + drawQuad(); + glScissor(prog.width - 22, prog.height - 11, 10, 10); + drawQuad(); + } + + { + glClearColor(1.0, 1.0, 0.0, 1.0); + glColor4d(1.0, 1.0, 0.0, 1.0); + + glScissor(1, 12, 10, 10); + drawQuad(); + glScissor(1, prog.height - 22, 10, 10); + drawQuad(); + glScissor(prog.width - 11, prog.height - 22, 10, 10); + drawQuad(); + } + + glDisable(GL_SCISSOR_TEST); + + //glutSwapBuffers(); + glFlush(); +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + prog.width = 200; + prog.height = 200; + + glutInitWindowPosition(100, 0); + glutInitWindowSize(prog.width, prog.height); + + //type = GLUT_RGB | GLUT_DOUBLE; + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + init(); + + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutDisplayFunc(draw); + glutMainLoop(); + return 0; +} diff --git a/scons/gallium.py b/scons/gallium.py index 0d5843603e9..5b3c9752bc4 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -362,23 +362,8 @@ def generate(env): '/GL-', # disable whole program optimization ] else: - if env['machine'] == 'x86_64': - cflags += [ - # Same as /O2, but without global optimizations or auto-inlining - # http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx - '/Ob1', # enable inline expansion, disable auto-inlining - '/Oi', # enable intrinsic functions - '/Ot', # favors fast code - '/Oy', # omit frame pointer - '/Gs', # enable stack probes - '/GF', # eliminate duplicate strings - '/Gy', # enable function-level linking - ] - else: - cflags += [ - '/O2', # optimize for speed - ] cflags += [ + '/O2', # optimize for speed #'/fp:fast', # fast floating point ] if env['profile']: diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index 5a342fbf3b1..d8decba49df 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -200,8 +200,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0); if(!mm_buf->block) { - debug_printf("warning: heap full\n"); #if 0 + debug_printf("warning: heap full\n"); mmDumpMemInfo(mm->heap); #endif FREE(mm_buf); diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index de37d135dfe..a601fc5646b 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -118,7 +118,8 @@ stw_call_window_proc( * be called from any thread. */ pipe_mutex_lock( fb->mutex ); - st_resize_framebuffer( fb->stfb, width, height ); + if (fb->stfb) + st_resize_framebuffer( fb->stfb, width, height ); pipe_mutex_unlock( fb->mutex ); } } @@ -379,6 +380,9 @@ stw_swap_buffers( if (fb == NULL) return FALSE; + if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) + return TRUE; + pipe_mutex_lock( fb->mutex ); /* If we're swapping the buffer associated with the current context diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 5a05a65396a..f77a29a43ec 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -179,7 +179,7 @@ /*@{*/ #define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) #define MAX_PROGRAM_LOCAL_PARAMS 256 /**< per-program constants (power of two) */ -#define MAX_PROGRAM_ENV_PARAMS 128 +#define MAX_PROGRAM_ENV_PARAMS 256 /**< per-context constants (power of two) */ #define MAX_PROGRAM_MATRICES 8 #define MAX_PROGRAM_MATRIX_STACK_DEPTH 4 #define MAX_PROGRAM_CALL_DEPTH 8 @@ -196,7 +196,7 @@ /*@{*/ #define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 #define MAX_NV_VERTEX_PROGRAM_TEMPS 12 -#define MAX_NV_VERTEX_PROGRAM_PARAMS MAX_PROGRAM_ENV_PARAMS +#define MAX_NV_VERTEX_PROGRAM_PARAMS 96 #define MAX_NV_VERTEX_PROGRAM_INPUTS 16 #define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 /*@}*/ diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 7276c22742d..1c8c44fcb96 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -285,7 +285,7 @@ write_texture_image(struct gl_texture_object *texObj) case MESA_FORMAT_RGB565: { GLubyte *buf2 = (GLubyte *) _mesa_malloc(img->Width * img->Height * 3); - GLint i; + GLuint i; for (i = 0; i < img->Width * img->Height; i++) { GLint r, g, b; GLushort s = ((GLushort *) img->Data)[i]; diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index a90ce95a639..7e166830fd5 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1022,7 +1022,10 @@ parse_teximage_num (GLcontext * ctx, const GLubyte ** inst, GLint i = parse_integer (inst, Program); if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) { - program_error(ctx, Program->Position, "Invalid texture image index"); + char s[100]; + _mesa_snprintf(s, sizeof(s), "Invalid texture image index %d (%u is max)", + i, ctx->Const.MaxTextureImageUnits); + program_error(ctx, Program->Position, s); return 1; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index f140641d7ef..7021d732089 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -245,11 +245,10 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target, assert(offset < obj->Size); assert(offset + length <= obj->Size); - map = obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, - offset, length, flags); - if (obj->Pointer) { - obj->Offset = 0; - obj->Length = obj->Size; + map = obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags); + if(obj->Pointer) { + obj->Offset = offset; + obj->Length = length; map += offset; } @@ -268,7 +267,6 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target, /* Subrange is relative to mapped range */ assert(offset >= 0); assert(length >= 0); - assert(offset < obj->Length); assert(offset + length <= obj->Length); pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 34926101ed0..72ca8524582 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -55,20 +55,6 @@ #define TGSI_DEBUG 0 -/** XXX we should use the version of this from u_memory.h but including - * that header causes symbol collisions. - */ -static INLINE void * -mem_dup(const void *src, uint size) -{ - void *dup = _mesa_malloc(size); - if (dup) - _mesa_memcpy(dup, src, size); - return dup; -} - - - /** * Translate a Mesa vertex shader into a TGSI shader. * \param outputMapping to map vertex program output registers (VERT_RESULT_x) @@ -84,7 +70,7 @@ st_translate_vertex_program(struct st_context *st, const ubyte *outputSemanticIndex) { struct pipe_context *pipe = st->pipe; - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; + struct tgsi_token *tokens; GLuint defaultOutputMapping[VERT_RESULT_MAX]; struct pipe_shader_state vs; GLuint attr, i; @@ -102,6 +88,13 @@ st_translate_vertex_program(struct st_context *st, GLbitfield input_flags[MAX_PROGRAM_INPUTS]; GLbitfield output_flags[MAX_PROGRAM_OUTPUTS]; + tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens); + if(!tokens) { + /* FIXME: propagate error to the caller */ + assert(0); + return; + } + memset(&vs, 0, sizeof(vs)); memset(input_flags, 0, sizeof(input_flags)); memset(output_flags, 0, sizeof(output_flags)); @@ -297,9 +290,6 @@ st_translate_vertex_program(struct st_context *st, } } - assert(vs_output_semantic_name[0] == TGSI_SEMANTIC_POSITION); - - if (outputMapping) { /* find max output slot referenced to compute vs_num_outputs */ GLuint maxSlot = 0; @@ -347,7 +337,9 @@ st_translate_vertex_program(struct st_context *st, assert(num_tokens < ST_MAX_SHADER_TOKENS); vs.tokens = (struct tgsi_token *) - mem_dup(tokens, num_tokens * sizeof(tokens[0])); + _mesa_realloc(tokens, + ST_MAX_SHADER_TOKENS * sizeof *tokens, + num_tokens * sizeof *tokens); stvp->num_inputs = vs_num_inputs; stvp->state = vs; /* struct copy */ @@ -375,7 +367,7 @@ st_translate_fragment_program(struct st_context *st, const GLuint inputMapping[]) { struct pipe_context *pipe = st->pipe; - struct tgsi_token tokens[ST_MAX_SHADER_TOKENS]; + struct tgsi_token *tokens; GLuint outputMapping[FRAG_RESULT_MAX]; GLuint defaultInputMapping[FRAG_ATTRIB_MAX]; struct pipe_shader_state fs; @@ -395,6 +387,13 @@ st_translate_fragment_program(struct st_context *st, GLbitfield input_flags[MAX_PROGRAM_INPUTS]; GLbitfield output_flags[MAX_PROGRAM_OUTPUTS]; + tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens); + if(!tokens) { + /* FIXME: propagate error to the caller */ + assert(0); + return; + } + memset(&fs, 0, sizeof(fs)); memset(input_flags, 0, sizeof(input_flags)); memset(output_flags, 0, sizeof(output_flags)); @@ -536,7 +535,9 @@ st_translate_fragment_program(struct st_context *st, assert(num_tokens < ST_MAX_SHADER_TOKENS); fs.tokens = (struct tgsi_token *) - mem_dup(tokens, num_tokens * sizeof(tokens[0])); + _mesa_realloc(tokens, + ST_MAX_SHADER_TOKENS * sizeof *tokens, + num_tokens * sizeof *tokens); stfp->state = fs; /* struct copy */ stfp->driver_shader = pipe->create_fs_state(pipe, &fs); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 6871ee5cab1..372d6819c1f 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -727,19 +727,32 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) { - if (exec->vtx.bufferobj->Name) { - /* using a real VBO for vertex data */ - GLcontext *ctx = exec->ctx; - _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); - } - else { - /* just using malloc'd space for vertex data */ - if (exec->vtx.buffer_map) { + /* using a real VBO for vertex data */ + GLcontext *ctx = exec->ctx; + unsigned i; + + /* True VBOs should already be unmapped + */ + if (exec->vtx.buffer_map) { + assert (exec->vtx.bufferobj->Name == 0); + if (exec->vtx.bufferobj->Name == 0) { ALIGN_FREE(exec->vtx.buffer_map); exec->vtx.buffer_map = NULL; exec->vtx.buffer_ptr = NULL; } } + + /* Drop any outstanding reference to the vertex buffer + */ + for (i = 0; i < Elements(exec->vtx.arrays); i++) { + _mesa_reference_buffer_object(ctx, + &exec->vtx.arrays[i].BufferObj, + NULL); + } + + /* Free the vertex buffer: + */ + _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); } void vbo_exec_BeginVertices( GLcontext *ctx ) |