From 1aba1baa622116759bfedca87f37e527c0111d16 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 21 Aug 2009 10:24:50 -0600 Subject: st/mesa: flush bitmap cache if Z value changes When adding a new bitmap to the cache we have to check if the Z value is changing and flush first if it is. This is a modified version of a patch from Justin Dou --- src/mesa/state_tracker/st_cb_bitmap.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 8709633557..ccf972f805 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -94,6 +94,9 @@ struct bitmap_cache GLfloat color[4]; + /** Bitmap's Z position */ + GLfloat zpos; + struct pipe_texture *texture; struct pipe_transfer *trans; @@ -104,6 +107,8 @@ struct bitmap_cache }; +/** Epsilon for Z comparisons */ +#define Z_EPSILON 1e-06 /** @@ -538,9 +543,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, } /* draw textured quad */ - offset = setup_bitmap_vertex_data(st, x, y, width, height, - ctx->Current.RasterPos[2], - color); + offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color); util_draw_vertex_buffer(pipe, st->bitmap.vbuf, offset, PIPE_PRIM_TRIANGLE_FAN, @@ -647,7 +650,7 @@ st_flush_bitmap_cache(struct st_context *st) draw_bitmap_quad(st->ctx, cache->xpos, cache->ypos, - st->ctx->Current.RasterPos[2], + cache->zpos, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, cache->texture, cache->color); @@ -687,6 +690,7 @@ accum_bitmap(struct st_context *st, { struct bitmap_cache *cache = st->bitmap.cache; int px = -999, py; + const GLfloat z = st->ctx->Current.RasterPos[2]; if (width > BITMAP_CACHE_WIDTH || height > BITMAP_CACHE_HEIGHT) @@ -697,7 +701,8 @@ accum_bitmap(struct st_context *st, py = y - cache->ypos; if (px < 0 || px + width > BITMAP_CACHE_WIDTH || py < 0 || py + height > BITMAP_CACHE_HEIGHT || - !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color)) { + !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color) || + ((fabs(z - cache->zpos) > Z_EPSILON))) { /* This bitmap would extend beyond cache bounds, or the bitmap * color is changing * so flush and continue. @@ -712,6 +717,7 @@ accum_bitmap(struct st_context *st, py = (BITMAP_CACHE_HEIGHT - height) / 2; cache->xpos = x; cache->ypos = y - py; + cache->zpos = z; cache->empty = GL_FALSE; COPY_4FV(cache->color, st->ctx->Current.RasterColor); } -- cgit v1.2.3 From f785b35b47926e052571386227eff58db7c084e2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 24 Aug 2009 11:43:02 -0600 Subject: glsl: Silence gcc uninitialized variable warning. --- src/mesa/shader/slang/slang_builtin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index 289d94644f..4e67241f3b 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -436,7 +436,7 @@ emit_statevars(const char *name, int array_len, struct gl_program_parameter_list *paramList) { if (type->type == SLANG_SPEC_ARRAY) { - GLint i, pos; + GLint i, pos = -1; assert(array_len > 0); if (strcmp(name, "gl_ClipPlane") == 0) { tokens[0] = STATE_CLIPPLANE; -- cgit v1.2.3 From b9b04872d526ed7955f647542399e110ace0325c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 24 Aug 2009 12:43:57 -0600 Subject: vbo: fix divide by zero exception Fixes bug 23489. --- src/mesa/vbo/vbo_exec_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index c53a4eee00..98177a4175 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -383,7 +383,7 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec, } - if (unmap) + if (unmap || exec->vtx.vertex_size == 0) exec->vtx.max_vert = 0; else exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / -- cgit v1.2.3 From bf7e4b10cbed496a12c8be17531c9cb7da1be177 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 24 Aug 2009 13:56:01 -0600 Subject: ARB prog: Set error instead of falling through with incorrect value If a fragment program only parameter was queried of a vertex program (e.g., GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB) no error would be set and a random value would be returned. This caused 'glxinfo -l' to show the same values for GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB as for GL_MAX_PROGRAM_ENV_PARAMETERS_ARB. This is confusing and incorrect. (cherry picked from master, commit 4bccd693a72a0b42dffc849034263a68e779ca91) --- src/mesa/shader/arbprogram.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 981565ab8f..a0331054bb 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -985,6 +985,9 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)"); return; } + } else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)"); + return; } } -- cgit v1.2.3 From 04d170794a22d93d58afeb5d0930e06f85964f9a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Aug 2009 11:39:24 -0600 Subject: glsl: fix bug in sampler array indexing Need to add the 'offset' parameter when indexing the parameter array. Before, if we were setting arrays of samplers, we were actually only setting the 0th sampler's value. Because of how progs/glsl/samplers.c is constructed, this wasn't showing up as a failure in the samplers_array output. --- src/mesa/shader/shader_api.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 14da974a87..95b7490ca9 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1624,7 +1624,6 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, if (param->Type == PROGRAM_SAMPLER) { /* This controls which texture unit which is used by a sampler */ - GLuint texUnit, sampler; GLint i; /* data type for setting samplers must be int */ @@ -1639,8 +1638,9 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, * common thing... */ for (i = 0; i < count; i++) { - sampler = (GLuint) program->Parameters->ParameterValues[index + i][0]; - texUnit = ((GLuint *) values)[i]; + GLuint sampler = + (GLuint) program->Parameters->ParameterValues[index + offset + i][0]; + GLuint texUnit = ((GLuint *) values)[i]; /* check that the sampler (tex unit index) is legal */ if (texUnit >= ctx->Const.MaxTextureImageUnits) { @@ -1651,6 +1651,10 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* This maps a sampler to a texture unit: */ if (sampler < MAX_SAMPLERS) { +#if 0 + _mesa_printf("Set program %p sampler %d '%s' to unit %u\n", + program, sampler, param->Name, texUnit); +#endif program->SamplerUnits[sampler] = texUnit; } } -- cgit v1.2.3