From 33aa5b69642405fbc300430bed1f2ccf521f3086 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Sep 2008 07:57:08 -0600 Subject: cell: disable calls to old gen code --- src/gallium/drivers/cell/ppu/cell_pipe_state.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index e04cf5f274..475c6ef0ce 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -48,8 +48,9 @@ cell_create_blend_state(struct pipe_context *pipe, struct cell_blend_state *cb = MALLOC(sizeof(struct cell_blend_state)); (void) memcpy(cb, blend, sizeof(*blend)); +#if 0 cell_generate_alpha_blend(cb); - +#endif return cb; } @@ -100,8 +101,9 @@ cell_create_depth_stencil_alpha_state(struct pipe_context *pipe, MALLOC(sizeof(struct cell_depth_stencil_alpha_state)); (void) memcpy(cdsa, depth_stencil, sizeof(*depth_stencil)); +#if 0 cell_generate_depth_stencil_test(cdsa); - +#endif return cdsa; } -- cgit v1.2.3 From 44e53b37a02933f238b438e5dc3a2891da5eb51a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Sep 2008 11:35:22 -0600 Subject: cell: fix twiddled tile display for XSHM. Fixed blank window problem. --- src/gallium/winsys/xlib/xm_winsys.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c index 2acbc94fc8..3334af175b 100644 --- a/src/gallium/winsys/xlib/xm_winsys.c +++ b/src/gallium/winsys/xlib/xm_winsys.c @@ -349,19 +349,26 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf) if (x + w > surf->width) w = surf->width - x; - offset *= 4 * TILE_SIZE * TILE_SIZE; - - twiddle_tile((uint *) ((char *) xm_buf->data + offset), - tmpTile); - ximage->data = (char*) tmpTile; + /* offset in pixels */ + offset *= TILE_SIZE * TILE_SIZE; if (XSHM_ENABLED(xm_buf)) { + ximage->data = (char *) xm_buf->data + 4 * offset; + /* make copy of tile data */ + memcpy(tmpTile, (uint *) ximage->data, sizeof(tmpTile)); + /* twiddle from temp to ximage in shared memory */ + twiddle_tile(tmpTile, (uint *) ximage->data); + /* display image in shared memory */ #if defined(USE_XSHM) && !defined(XFree86Server) XShmPutImage(b->xm_visual->display, b->drawable, b->gc, ximage, 0, 0, x, y, w, h, False); #endif } else { + /* twiddel from ximage buffer to temp tile */ + twiddle_tile((uint *) xm_buf->data + offset, tmpTile); + /* display temp tile data */ + ximage->data = (char *) tmpTile; XPutImage(b->xm_visual->display, b->drawable, b->gc, ximage, 0, 0, x, y, w, h); } -- cgit v1.2.3 From 75c19eb5a1caf0c36e04270174579d0d7fec9ccb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 13 Sep 2008 15:20:31 -0600 Subject: gallium: add another value check to util_fast_pow() Fixes glitches seen in morph3d demo. --- src/gallium/auxiliary/util/u_math.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 9b4ca39371..0b10622ee7 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -272,8 +272,10 @@ util_fast_log2(float val) static INLINE float util_fast_pow(float x, float y) { - /* XXX this test may need adjustment */ - if (y >= 3.0 && -0.02f <= x && x <= 0.02f) + /* XXX these tests may need adjustment */ + if (y >= 3.0f && (-0.02f <= x && x <= 0.02f)) + return 0.0f; + if (y >= 50.0f && (-0.9f <= x && x <= 0.9f)) return 0.0f; return util_fast_exp2(util_fast_log2(x) * y); } -- cgit v1.2.3 From cd23c5c5998f3c48153a22bed53986b4293f797a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 15 Sep 2008 13:47:25 +0100 Subject: mesa: get another class of degenerate dlists working Primitive begin in one dlist, end in another. --- src/mesa/main/dlist.c | 7 +++++-- src/mesa/vbo/vbo_save_api.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index b4ed300b2e..ffe6dbfe08 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -6737,6 +6737,11 @@ _mesa_EndList(void) _mesa_error(ctx, GL_INVALID_OPERATION, "glEndList"); return; } + + /* Call before emitting END_OF_LIST, in case the driver wants to + * emit opcodes itself. + */ + ctx->Driver.EndList(ctx); (void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0); @@ -6750,8 +6755,6 @@ _mesa_EndList(void) if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) mesa_print_display_list(ctx->ListState.CurrentListNum); - ctx->Driver.EndList(ctx); - ctx->ListState.CurrentList = NULL; ctx->ListState.CurrentListNum = 0; ctx->ListState.CurrentListPtr = NULL; diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 88d573f128..f93ef3a02a 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1045,6 +1045,30 @@ void vbo_save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) void vbo_save_EndList( GLcontext *ctx ) { struct vbo_save_context *save = &vbo_context(ctx)->save; + + /* EndList called inside a (saved) Begin/End pair? + */ + if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) { + GLint i = save->prim_count - 1; + + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + save->prim[i].end = 0; + save->prim[i].count = (save->vert_count - + save->prim[i].start); + + /* Make sure this vertex list gets replayed by the "loopback" + * mechanism: + */ + save->dangling_attr_ref = 1; + vbo_save_SaveFlushVertices( ctx ); + + /* Swap out this vertex format while outside begin/end. Any color, + * etc. received between here and the next begin will be compiled + * as opcodes. + */ + _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); + } + unmap_vertex_store( ctx, save->vertex_store ); assert(save->vertex_size == 0); -- cgit v1.2.3 From 987c4b35b8f552a88e1b6459adaabbf544d6bbf6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Sep 2008 09:07:32 -0600 Subject: mesa: remove some assertions that are invalid during context tear-down --- src/mesa/main/bufferobj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index f1e0932b07..ecdb4d219c 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -205,11 +205,14 @@ _mesa_reference_buffer_object(GLcontext *ctx, if (deleteFlag) { /* some sanity checking: don't delete a buffer still in use */ +#if 0 + /* unfortunately, these tests are invalid during context tear-down */ ASSERT(ctx->Array.ArrayBufferObj != bufObj); ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj); - ASSERT(ctx->Driver.DeleteBuffer); +#endif + ASSERT(ctx->Driver.DeleteBuffer); ctx->Driver.DeleteBuffer(ctx, oldObj); } -- cgit v1.2.3 From b1f5fbe1cb937bc639cc335acfcfb8c09dfeb3ec Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 15 Sep 2008 17:10:04 -0600 Subject: mesa: fix MSAA enable state in update_multisample() --- src/mesa/main/state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 344af91e17..d355f78a0e 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -295,10 +295,10 @@ static void update_multisample(GLcontext *ctx) { ctx->Multisample._Enabled = GL_FALSE; - if (ctx->DrawBuffer) { - if (ctx->DrawBuffer->Visual.sampleBuffers) - ctx->Multisample._Enabled = GL_TRUE; - } + if (ctx->Multisample.Enabled && + ctx->DrawBuffer && + ctx->DrawBuffer->Visual.sampleBuffers) + ctx->Multisample._Enabled = GL_TRUE; } -- cgit v1.2.3 From eef2edadf33cdb4ce033565ebc5b6aaf56e9288f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 16 Sep 2008 20:24:43 +0900 Subject: trace: Fix typo in build instructions. --- src/gallium/drivers/trace/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index e7a2f12b02..f0e1cd596d 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -10,7 +10,7 @@ This directory contains a Gallium3D pipe driver which traces all incoming calls. To build, invoke scons on the top dir as - scons statetrackers=mesa drivers=softpipe,i915simple,trace winsys=xlib + scons statetrackers=mesa drivers=softpipe,i965simple,trace winsys=xlib = Usage = -- cgit v1.2.3 From ad16ecbbe4fe8c1bcb18ed8fbbd672c68a0b17fa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Sep 2008 16:16:54 +0200 Subject: tgsi: Make tgsi_sanity.c compile with make --- src/gallium/auxiliary/tgsi/Makefile | 1 + src/gallium/auxiliary/tgsi/tgsi_sanity.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile index 806a2bd4c5..c5d2082087 100644 --- a/src/gallium/auxiliary/tgsi/Makefile +++ b/src/gallium/auxiliary/tgsi/Makefile @@ -4,6 +4,7 @@ include $(TOP)/configs/current LIBNAME = tgsi C_SOURCES = \ + tgsi_sanity.c \ tgsi_build.c \ tgsi_dump.c \ tgsi_exec.c \ diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index c659027296..20b32477be 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -152,6 +152,12 @@ check_register_usage( { if (!check_file_name( ctx, file )) return FALSE; + + if (index < 0 || index > MAX_REGISTERS) { + report_error( ctx, "%s[%i]: Invalid index %s", file_names[file], index, name ); + return FALSE; + } + if (indirect_access) { if (!is_any_register_declared( ctx, file )) report_error( ctx, "%s: Undeclared %s register", file_names[file], name ); -- cgit v1.2.3 From 358aab12c60d5e627d2ce54c1407659cbc207e8c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 16 Sep 2008 16:17:46 +0200 Subject: mesa: State tracker now checks for faulty shaders on debug --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 5ec9fddd7f..e822c8ac61 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -35,10 +35,12 @@ #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_build.h" #include "tgsi/tgsi_util.h" +#include "tgsi/tgsi_dump.h" +#include "tgsi/tgsi_sanity.h" #include "st_mesa_to_tgsi.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" - +#include "pipe/p_debug.h" /* * Map mesa register file to TGSI register file. @@ -980,5 +982,14 @@ tgsi_translate_mesa_program( maxTokens - ti ); } +#if DEBUG + if(!tgsi_sanity_check(tokens)) { + //debug_printf("Due to sanity check failure the following shader program is invalid\n"); + tgsi_dump(tokens, 0); + + assert(0); + } +#endif + return ti; } -- cgit v1.2.3 From 4992806ae54d7d1db86eed9c6524aa05f4a2fbd6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 08:49:43 -0600 Subject: mesa: protect against double-free in _vbo_DestroyContext() --- src/mesa/vbo/vbo_context.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index dc7c534251..b452ac8a38 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -246,12 +246,14 @@ void _vbo_DestroyContext( GLcontext *ctx ) ctx->aelt_context = NULL; } - vbo_exec_destroy(ctx); + if (vbo_context(ctx)) { + vbo_exec_destroy(ctx); #if FEATURE_dlist - vbo_save_destroy(ctx); + vbo_save_destroy(ctx); #endif - FREE(vbo_context(ctx)); - ctx->swtnl_im = NULL; + FREE(vbo_context(ctx)); + ctx->swtnl_im = NULL; + } } -- cgit v1.2.3 From 753635f733c5548ac8e662e792f65d41b454052a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 08:51:28 -0600 Subject: gallium: move _vbo_DestroyContext() call Call it before freeing core Mesa state to avoid references to freed buffer objects. --- src/mesa/state_tracker/st_context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 08d4db7f7f..534c7c12ac 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -188,8 +188,6 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_drawtex(st); #endif - _vbo_DestroyContext(st->ctx); - for (i = 0; i < Elements(st->state.sampler_texture); i++) { pipe_texture_reference(&st->state.sampler_texture[i], NULL); } @@ -223,6 +221,8 @@ void st_destroy_context( struct st_context *st ) _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache); + _vbo_DestroyContext(st->ctx); + _mesa_free_context_data(ctx); st_destroy_context_priv(st); -- cgit v1.2.3 From ea9568dfbe7415db1a529ca4ecc1b9c41cae10b1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 08:55:54 -0600 Subject: mesa: fix bug in get_uniform_rows_cols(): sometimes returned too many rows --- src/mesa/shader/shader_api.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index d8b210be53..a86ef56c65 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1108,7 +1108,8 @@ get_matrix_dims(GLenum type, GLint *rows, GLint *cols) /** * Determine the number of rows and columns occupied by a uniform - * according to its datatype. + * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4), + * the number of rows = 1 and cols = number of elements in the vector. */ static void get_uniform_rows_cols(const struct gl_program_parameter *p, @@ -1117,11 +1118,17 @@ get_uniform_rows_cols(const struct gl_program_parameter *p, get_matrix_dims(p->DataType, rows, cols); if (*rows == 0 && *cols == 0) { /* not a matrix type, probably a float or vector */ - *rows = p->Size / 4 + 1; - if (p->Size % 4 == 0) - *cols = 4; - else - *cols = p->Size % 4; + if (p->Size <= 4) { + *rows = 1; + *cols = p->Size; + } + else { + *rows = p->Size / 4 + 1; + if (p->Size % 4 == 0) + *cols = 4; + else + *cols = p->Size % 4; + } } } -- cgit v1.2.3 From 8cdab20c9a0d8794d5d85dbeef478b982ce39506 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 12:52:19 -0600 Subject: gallium: fix info entries for KIL, KILP KIL takes 1 src register. KILP uses no registers (uses cond codes). --- src/gallium/auxiliary/tgsi/tgsi_info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index a4899cd4c2..68c7a6b7f5 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -69,7 +69,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 1, 1, 0, 0, "COS" }, { 1, 1, 0, 0, "DDX" }, { 1, 1, 0, 0, "DDY" }, - { 0, 1, 0, 0, "KILP" }, + { 0, 0, 0, 0, "KILP" }, { 1, 1, 0, 0, "PK2H" }, { 1, 1, 0, 0, "PK2US" }, { 1, 1, 0, 0, "PK4B" }, @@ -146,7 +146,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = { 0, 1, 0, 0, "CALLNZ" }, { 0, 1, 0, 0, "IFC" }, { 0, 1, 0, 0, "BREAKC" }, - { 0, 0, 0, 0, "KIL" }, + { 0, 1, 0, 0, "KIL" }, { 0, 0, 0, 0, "END" }, { 1, 1, 0, 0, "SWZ" } }; -- cgit v1.2.3 From 39cb5b9f73318a069e2d8553243ae17955a85695 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 13:23:01 -0600 Subject: mesa: fix display list regression (check if save->prim_count > 0 in vbo_save_EndList()) --- src/mesa/vbo/vbo_save_api.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index f93ef3a02a..f69a33d817 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1049,12 +1049,14 @@ void vbo_save_EndList( GLcontext *ctx ) /* EndList called inside a (saved) Begin/End pair? */ if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) { - GLint i = save->prim_count - 1; - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - save->prim[i].end = 0; - save->prim[i].count = (save->vert_count - - save->prim[i].start); + if (save->prim_count > 0) { + GLint i = save->prim_count - 1; + ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; + save->prim[i].end = 0; + save->prim[i].count = (save->vert_count - + save->prim[i].start); + } /* Make sure this vertex list gets replayed by the "loopback" * mechanism: -- cgit v1.2.3 From 37607aeaf8b0fd35213635ba1c3743b6e059d48f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 11:59:24 -0600 Subject: gallium: fix glTexImage(width=height=depth=0) case Free old teximage/level data, then stop. --- src/mesa/state_tracker/st_cb_texture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index a3e8fc992d..2ba3766939 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -455,6 +455,11 @@ st_TexImage(GLcontext * ctx, _mesa_align_free(texImage->Data); } + if (width == 0 || height == 0 || depth == 0) { + /* stop after freeing old image */ + return; + } + /* If this is the only mipmap level in the texture, could call * bmBufferData with NULL data to free the old block and avoid * waiting on any outstanding fences. -- cgit v1.2.3 From e53296c928d80c6627a9551345c160533aa1a19e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Sep 2008 15:50:44 -0600 Subject: mesa: rework GLSL vertex attribute binding Calls to glBindAttribLocation() should not take effect until the next time that glLinkProgram() is called. gl_shader_program::Attributes now just contains user-defined bindings. gl_shader_program::VertexProgram->Attributes contains the actual/final bindings. --- src/mesa/main/mtypes.h | 4 +- src/mesa/shader/shader_api.c | 62 +++++++++-------- src/mesa/shader/slang/slang_link.c | 139 +++++++++++++++++++------------------ src/mesa/shader/slang/slang_link.h | 8 +-- 4 files changed, 110 insertions(+), 103 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 71a4ca55bc..2fc169493b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2143,12 +2143,14 @@ struct gl_shader_program GLuint NumShaders; /**< number of attached shaders */ struct gl_shader **Shaders; /**< List of attached the shaders */ + /** User-defined attribute bindings (glBindAttribLocation) */ + struct gl_program_parameter_list *Attributes; + /* post-link info: */ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ struct gl_uniform_list *Uniforms; struct gl_program_parameter_list *Varying; - struct gl_program_parameter_list *Attributes; /**< Vertex attributes */ GLboolean LinkStatus; /**< GL_LINK_STATUS */ GLboolean Validated; GLchar *InfoLog; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index a86ef56c65..decdec53ed 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.2 * * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. * @@ -497,10 +497,14 @@ _mesa_get_attrib_location(GLcontext *ctx, GLuint program, if (!name) return -1; - if (shProg->Attributes) { - GLint i = _mesa_lookup_parameter_index(shProg->Attributes, -1, name); - if (i >= 0) { - return shProg->Attributes->Parameters[i].StateIndexes[0]; + if (shProg->VertexProgram) { + const struct gl_program_parameter_list *attribs = + shProg->VertexProgram->Base.Attributes; + if (attribs) { + GLint i = _mesa_lookup_parameter_index(attribs, -1, name); + if (i >= 0) { + return attribs->Parameters[i].StateIndexes[0]; + } } } return -1; @@ -513,7 +517,7 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, { struct gl_shader_program *shProg; const GLint size = -1; /* unknown size */ - GLint i, oldIndex; + GLint i; GLenum datatype = GL_FLOAT_VEC4; shProg = _mesa_lookup_shader_program_err(ctx, program, @@ -536,14 +540,6 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, return; } - if (shProg->LinkStatus) { - /* get current index/location for the attribute */ - oldIndex = _mesa_get_attrib_location(ctx, program, name); - } - else { - oldIndex = -1; - } - /* this will replace the current value if it's already in the list */ i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index); if (i < 0) { @@ -551,12 +547,10 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index, return; } - if (shProg->VertexProgram && oldIndex >= 0 && oldIndex != index) { - /* If the index changed, need to search/replace references to that attribute - * in the vertex program. - */ - _slang_remap_attribute(&shProg->VertexProgram->Base, oldIndex, index); - } + /* + * Note that this attribute binding won't go into effect until + * glLinkProgram is called again. + */ } @@ -798,24 +792,29 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLchar *nameOut) { + const struct gl_program_parameter_list *attribs = NULL; struct gl_shader_program *shProg; shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); if (!shProg) return; - if (!shProg->Attributes || index >= shProg->Attributes->NumParameters) { + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + + if (!attribs || index >= attribs->NumParameters) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); return; } - copy_string(nameOut, maxLength, length, - shProg->Attributes->Parameters[index].Name); + copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name); + if (size) - *size = shProg->Attributes->Parameters[index].Size - / sizeof_glsl_type(shProg->Attributes->Parameters[index].DataType); + *size = attribs->Parameters[index].Size + / sizeof_glsl_type(attribs->Parameters[index].DataType); + if (type) - *type = shProg->Attributes->Parameters[index].DataType; + *type = attribs->Parameters[index].DataType; } @@ -937,6 +936,7 @@ static void _mesa_get_programiv(GLcontext *ctx, GLuint program, GLenum pname, GLint *params) { + const struct gl_program_parameter_list *attribs; struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); @@ -945,6 +945,11 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, return; } + if (shProg->VertexProgram) + attribs = shProg->VertexProgram->Base.Attributes; + else + attribs = NULL; + switch (pname) { case GL_DELETE_STATUS: *params = shProg->DeletePending; @@ -962,11 +967,10 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, *params = shProg->NumShaders; break; case GL_ACTIVE_ATTRIBUTES: - *params = shProg->Attributes ? shProg->Attributes->NumParameters : 0; + *params = attribs ? attribs->NumParameters : 0; break; case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = _mesa_longest_parameter_name(shProg->Attributes, - PROGRAM_INPUT) + 1; + *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1; break; case GL_ACTIVE_UNIFORMS: *params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 57dbfc2388..30035b4fee 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.2 * - * Copyright (C) 2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -215,74 +215,110 @@ link_uniform_vars(struct gl_shader_program *shProg, * For example, if the vertex shader declared "attribute vec4 foobar" we'll * allocate a generic vertex attribute for "foobar" and plug that value into * the vertex program instructions. + * But if the user called glBindAttributeLocation(), those bindings will + * have priority. */ static GLboolean _slang_resolve_attributes(struct gl_shader_program *shProg, - struct gl_program *prog) + const struct gl_program *origProg, + struct gl_program *linkedProg) { + GLint attribMap[MAX_VERTEX_ATTRIBS]; GLuint i, j; GLbitfield usedAttributes; - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); + assert(origProg != linkedProg); + assert(origProg->Target == GL_VERTEX_PROGRAM_ARB); + assert(linkedProg->Target == GL_VERTEX_PROGRAM_ARB); if (!shProg->Attributes) shProg->Attributes = _mesa_new_parameter_list(); + if (linkedProg->Attributes) { + _mesa_free_parameter_list(linkedProg->Attributes); + } + linkedProg->Attributes = _mesa_new_parameter_list(); + + /* Build a bitmask indicating which attribute indexes have been * explicitly bound by the user with glBindAttributeLocation(). */ usedAttributes = 0x0; for (i = 0; i < shProg->Attributes->NumParameters; i++) { GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0]; - usedAttributes |= attr; + usedAttributes |= (1 << attr); + } + + /* initialize the generic attribute map entries to -1 */ + for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) { + attribMap[i] = -1; } /* * Scan program for generic attribute references */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; + for (i = 0; i < linkedProg->NumInstructions; i++) { + struct prog_instruction *inst = linkedProg->Instructions + i; for (j = 0; j < 3; j++) { if (inst->SrcReg[j].File == PROGRAM_INPUT && inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) { - /* this is a generic attrib */ - const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0; - const char *name = prog->Attributes->Parameters[k].Name; - /* See if this attrib name is in the program's attribute list - * (i.e. was bound by the user). + /* + * OK, we've found a generic vertex attribute reference. */ - GLint index = _mesa_lookup_parameter_index(shProg->Attributes, - -1, name); - GLint attr; - if (index >= 0) { - /* found, user must have specified a binding */ - attr = shProg->Attributes->Parameters[index].StateIndexes[0]; - } - else { - /* Not found, choose our own attribute number. - * Start at 1 since generic attribute 0 always aliases - * glVertex/position. + const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0; + + GLint attr = attribMap[k]; + + if (attr < 0) { + /* Need to figure out attribute mapping now. + */ + const char *name = origProg->Attributes->Parameters[k].Name; + const GLint size = origProg->Attributes->Parameters[k].Size; + const GLenum type =origProg->Attributes->Parameters[k].DataType; + GLint index, attr; + + /* See if there's a user-defined attribute binding for + * this name. */ - GLint size = prog->Attributes->Parameters[k].Size; - GLenum datatype = prog->Attributes->Parameters[k].DataType; - for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { - if (((1 << attr) & usedAttributes) == 0) - break; + index = _mesa_lookup_parameter_index(shProg->Attributes, + -1, name); + if (index >= 0) { + /* Found a user-defined binding */ + attr = shProg->Attributes->Parameters[index].StateIndexes[0]; } - if (attr == MAX_VERTEX_ATTRIBS) { - /* too many! XXX record error log */ - return GL_FALSE; + else { + /* No user-defined binding, choose our own attribute number. + * Start at 1 since generic attribute 0 always aliases + * glVertex/position. + */ + for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { + if (((1 << attr) & usedAttributes) == 0) + break; + } + if (attr == MAX_VERTEX_ATTRIBS) { + link_error(shProg, "Too many vertex attributes"); + return GL_FALSE; + } + + /* mark this attribute as used */ + usedAttributes |= (1 << attr); } - _mesa_add_attribute(shProg->Attributes, name, size, datatype,attr); - /* set the attribute as used */ - usedAttributes |= 1<attrib binding so it can be queried + * with glGetAttributeLocation(). + */ + _mesa_add_attribute(linkedProg->Attributes, name, + size, type, attr); } + /* update the instruction's src reg */ inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr; } } } + return GL_TRUE; } @@ -344,36 +380,6 @@ _slang_update_inputs_outputs(struct gl_program *prog) } -/** - * Scan a vertex program looking for instances of - * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + oldAttrib) and replace with - * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + newAttrib). - * This is used when the user calls glBindAttribLocation on an already linked - * shader program. - */ -void -_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, GLuint newAttrib) -{ - GLuint i, j; - - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); - - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - for (j = 0; j < 3; j++) { - if (inst->SrcReg[j].File == PROGRAM_INPUT) { - if (inst->SrcReg[j].Index == VERT_ATTRIB_GENERIC0 + oldAttrib) { - inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + newAttrib; - } - } - } - } - - _slang_update_inputs_outputs(prog); -} - - - /** cast wrapper */ static struct gl_vertex_program * vertex_program(struct gl_program *prog) @@ -492,9 +498,8 @@ _slang_link(GLcontext *ctx, /*_mesa_print_uniforms(shProg->Uniforms);*/ if (shProg->VertexProgram) { - if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) { - /*goto cleanup;*/ - _mesa_problem(ctx, "_slang_resolve_attributes() failed"); + if (!_slang_resolve_attributes(shProg, &vertProg->Base, + &shProg->VertexProgram->Base)) { return; } } diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h index 8ef8a6b4b3..2b44d20787 100644 --- a/src/mesa/shader/slang/slang_link.h +++ b/src/mesa/shader/slang/slang_link.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.2 * - * Copyright (C) 2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -32,10 +32,6 @@ extern void _slang_link(GLcontext *ctx, GLhandleARB h, struct gl_shader_program *shProg); -extern void -_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, - GLuint newAttrib); - #endif -- cgit v1.2.3 From 0d20c88f626dfcfd8ad0b95f9e05feed19151e35 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 09:05:04 -0600 Subject: mesa: fix bug in previous changes to _slang_resolve_attributes() --- src/mesa/shader/slang/slang_link.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 30035b4fee..a6390846b2 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -275,7 +275,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, const char *name = origProg->Attributes->Parameters[k].Name; const GLint size = origProg->Attributes->Parameters[k].Size; const GLenum type =origProg->Attributes->Parameters[k].DataType; - GLint index, attr; + GLint index; /* See if there's a user-defined attribute binding for * this name. @@ -313,6 +313,8 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, size, type, attr); } + assert(attr >= 0); + /* update the instruction's src reg */ inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr; } -- cgit v1.2.3 From f10e7f0d288530a31a7ed3bc976a537fe640ce69 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 09:47:51 -0600 Subject: gallium: fix lack of surface reference counting in cso_set/save/restore_framebuffer() Fixes asst problems with FBO / render to texture. --- src/gallium/auxiliary/cso_cache/cso_context.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index f22ba40824..b1ccfc0374 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -765,12 +765,30 @@ void cso_restore_vertex_shader(struct cso_context *ctx) } +/** + * Copy framebuffer state from src to dst with refcounting of surfaces. + */ +static void +copy_framebuffer_state(struct pipe_framebuffer_state *dst, + const struct pipe_framebuffer_state *src) +{ + uint i; + + dst->width = src->width; + dst->height = src->height; + dst->num_cbufs = src->num_cbufs; + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]); + } + pipe_surface_reference(&dst->zsbuf, src->zsbuf); +} + enum pipe_error cso_set_framebuffer(struct cso_context *ctx, const struct pipe_framebuffer_state *fb) { if (memcmp(&ctx->fb, fb, sizeof(*fb)) != 0) { - ctx->fb = *fb; + copy_framebuffer_state(&ctx->fb, fb); ctx->pipe->set_framebuffer_state(ctx->pipe, fb); } return PIPE_OK; @@ -778,13 +796,13 @@ enum pipe_error cso_set_framebuffer(struct cso_context *ctx, void cso_save_framebuffer(struct cso_context *ctx) { - ctx->fb_saved = ctx->fb; + copy_framebuffer_state(&ctx->fb_saved, &ctx->fb); } void cso_restore_framebuffer(struct cso_context *ctx) { if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) { - ctx->fb = ctx->fb_saved; + copy_framebuffer_state(&ctx->fb, &ctx->fb_saved); ctx->pipe->set_framebuffer_state(ctx->pipe, &ctx->fb); } } -- cgit v1.2.3 From f8a5cb8cb2fde732016888a2554872d702803c01 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 17 Sep 2008 18:08:03 +0200 Subject: tgsi: More debug printing on sanity check error --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index e822c8ac61..49abee15a1 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -984,9 +984,12 @@ tgsi_translate_mesa_program( #if DEBUG if(!tgsi_sanity_check(tokens)) { - //debug_printf("Due to sanity check failure the following shader program is invalid\n"); + debug_printf("Due to sanity check failure(s) above the following shader program is invalid:\n"); + debug_printf("\nOriginal program:\n%s", program->String); + debug_printf("\nMesa program:\n"); + _mesa_print_program(program); + debug_printf("\nTGSI program:\n"); tgsi_dump(tokens, 0); - assert(0); } #endif -- cgit v1.2.3 From ec8398d62f5e5084e9eeb98ed55324ab98214248 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 17 Sep 2008 18:11:35 +0200 Subject: tgsi: Add a ugly fix for CONSTANT problems --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 49abee15a1..ff0bc04619 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -241,6 +241,15 @@ compile_instruction( immediateMapping, indirectAccess ); + /** + * This not at all the correct solution. + * FIXME: Roll this up in the above map functions + */ + if (fullsrc->SrcRegister.File == TGSI_FILE_IMMEDIATE && fullsrc->SrcRegister.Index == ~0) { + fullsrc->SrcRegister.File = TGSI_FILE_CONSTANT; + fullsrc->SrcRegister.Index = inst->SrcReg[i].Index; + } + /* swizzle (ext swizzle also depends on negation) */ { GLuint swz[4]; -- cgit v1.2.3 From 63b915d743e1807696a55f5e52a1fe9df799aeb3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 10:20:49 -0600 Subject: gallium: new assertion on surface->texture --- src/mesa/state_tracker/st_cb_fbo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 8406bf247f..00076f61e0 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -170,6 +170,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, 0, 0, 0, surface_usage ); + assert(strb->surface->texture); assert(strb->surface->buffer); assert(strb->surface->format); assert(strb->surface->block.size); -- cgit v1.2.3 From 66682651b622be201b211d50c7311e0b81b2b4a5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 10:22:38 -0600 Subject: gallium: need to finish, not flush, in st_copy_texsubimage() --- src/mesa/state_tracker/st_cb_texture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 2ba3766939..2e1ad93942 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1053,7 +1053,8 @@ st_copy_texsubimage(GLcontext *ctx, GLboolean use_fallback = GL_TRUE; GLboolean matching_base_formats; - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + /* any rendering in progress must complete before we grab the fb image */ + st_finish(ctx->st); /* determine if copying depth or color data */ if (texBaseFormat == GL_DEPTH_COMPONENT) { -- cgit v1.2.3 From 095ca0acd8019e8f2da89f9320b92ce4a96a140e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 10:25:18 -0600 Subject: gallium: include prog_print.h to silence warning --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index ff0bc04619..b9807bb807 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -40,6 +40,7 @@ #include "st_mesa_to_tgsi.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" +#include "shader/prog_print.h" #include "pipe/p_debug.h" /* -- cgit v1.2.3 From 133693ebe8904de785610efd38219bca67b75222 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 13:13:02 -0600 Subject: mesa: update program->NumAddressRegs field in _slang_update_inputs_outputs() --- src/mesa/shader/slang/slang_link.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index a6390846b2..a44d001477 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -363,6 +363,7 @@ static void _slang_update_inputs_outputs(struct gl_program *prog) { GLuint i, j; + GLuint maxAddrReg = 0; prog->InputsRead = 0x0; prog->OutputsWritten = 0x0; @@ -374,11 +375,19 @@ _slang_update_inputs_outputs(struct gl_program *prog) if (inst->SrcReg[j].File == PROGRAM_INPUT) { prog->InputsRead |= 1 << inst->SrcReg[j].Index; } + else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { + maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1); + } } if (inst->DstReg.File == PROGRAM_OUTPUT) { prog->OutputsWritten |= 1 << inst->DstReg.Index; } + else if (inst->DstReg.File == PROGRAM_ADDRESS) { + maxAddrReg = MAX2(maxAddrReg, inst->DstReg.Index + 1); + } } + + prog->NumAddressRegs = maxAddrReg; } -- cgit v1.2.3 From e6a120fefea44078b3a8d4292d83671e6c41357f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 13:14:57 -0600 Subject: gallium: fix tgsi sanity checker with respect to END. Subroutine code may be found after the END instruction so it's not always the last instruction. At least check for presence of exactly one END instruction though. --- src/gallium/auxiliary/tgsi/tgsi_sanity.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index 20b32477be..11659247c0 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -180,12 +180,10 @@ iter_instruction( const struct tgsi_opcode_info *info; uint i; - /* There must be no other instructions after END. - */ - if (ctx->index_of_END != ~0) { - report_error( ctx, "Unexpected instruction after END" ); - } - else if (inst->Instruction.Opcode == TGSI_OPCODE_END) { + if (inst->Instruction.Opcode == TGSI_OPCODE_END) { + if (ctx->index_of_END != ~0) { + report_error( ctx, "Too many END instructions" ); + } ctx->index_of_END = ctx->num_instructions; } @@ -307,10 +305,10 @@ epilog( struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter; uint file; - /* There must be an END instruction at the end. + /* There must be an END instruction somewhere. */ - if (ctx->index_of_END == ~0 || ctx->index_of_END != ctx->num_instructions - 1) { - report_error( ctx, "Expected END at end of instruction sequence" ); + if (ctx->index_of_END == ~0) { + report_error( ctx, "Missing END instruction" ); } /* Check if all declared registers were used. -- cgit v1.2.3 From 1a820f52f6fa125786538c1adf2aa350e66b8c1e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 14:32:33 -0600 Subject: gallium: clean-up/fix msaa override in state tracker --- src/mesa/state_tracker/st_atom_rasterizer.c | 2 +- src/mesa/state_tracker/st_context.c | 15 +++++++++++++++ src/mesa/state_tracker/st_context.h | 6 ++++++ src/mesa/state_tracker/st_framebuffer.c | 11 +++++------ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index e286dc5116..fc47896c24 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -254,7 +254,7 @@ static void update_raster_state( struct st_context *st ) raster->line_stipple_factor = ctx->Line.StippleFactor - 1; /* _NEW_MULTISAMPLE */ - if (ctx->Multisample._Enabled) + if (ctx->Multisample._Enabled || st->force_msaa) raster->multisample = 1; /* _NEW_SCISSOR */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 534c7c12ac..cca808d328 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -88,6 +88,19 @@ void st_invalidate_state(GLcontext * ctx, GLuint new_state) } +/** + * Check for multisample env var override. + */ +int +st_get_msaa(void) +{ + const char *msaa = _mesa_getenv("__GL_FSAA_MODE"); + if (msaa) + return atoi(msaa); + return 0; +} + + static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { @@ -141,6 +154,8 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st->pixel_xfer.cache = _mesa_new_program_cache(); + st->force_msaa = st_get_msaa(); + /* GL limits and extensions */ st_init_limits(st); st_init_extensions(st); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 4314d9af5c..1d1aca3111 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -181,6 +181,8 @@ struct st_context struct blit_state *blit; struct cso_context *cso_context; + + int force_msaa; }; @@ -238,4 +240,8 @@ st_fb_orientation(const struct gl_framebuffer *fb) } +extern int +st_get_msaa(void); + + #endif diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 0f4a03fa48..ec8928f200 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -51,13 +51,12 @@ st_create_framebuffer( const __GLcontextModes *visual, { struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer); if (stfb) { - int samples = 0; - const char *msaa_override = _mesa_getenv("__GL_FSAA_MODE"); + int samples = st_get_msaa(); + + if (visual->sampleBuffers) + samples = visual->samples; + _mesa_initialize_framebuffer(&stfb->Base, visual); - if (visual->sampleBuffers) samples = visual->samples; - if (msaa_override) { - samples = _mesa_atoi(msaa_override); - } { /* fake frontbuffer */ -- cgit v1.2.3 From 3b3d34d637d413af48fa5bd037b579ccb4ea7bb5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 15:29:59 -0600 Subject: egl: print multisample info --- progs/egl/eglinfo.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c index 89feec9be4..14620a9759 100644 --- a/progs/egl/eglinfo.c +++ b/progs/egl/eglinfo.c @@ -48,9 +48,9 @@ PrintConfigs(EGLDisplay d) eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); printf("Configurations:\n"); - printf(" bf lv d st colorbuffer dp st vis supported\n"); - printf(" id sz l b ro r g b a th cl id surfaces \n"); - printf("---------------------------------------------------\n"); + printf(" bf lv d st colorbuffer dp st ms vis supported\n"); + printf(" id sz l b ro r g b a th cl ns b id surfaces \n"); + printf("--------------------------------------------------------\n"); for (i = 0; i < numConfigs; i++) { EGLint id, size, level; EGLint red, green, blue, alpha; @@ -58,6 +58,7 @@ PrintConfigs(EGLDisplay d) EGLint surfaces; EGLint doubleBuf = 1, stereo = 0; EGLint vid; + EGLint samples, sampleBuffers; char surfString[100] = ""; eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id); @@ -73,6 +74,9 @@ PrintConfigs(EGLDisplay d) eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid); eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); + eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples); + eglGetConfigAttrib(d, configs[i], EGL_SAMPLE_BUFFERS, &sampleBuffers); + if (surfaces & EGL_WINDOW_BIT) strcat(surfString, "win,"); if (surfaces & EGL_PBUFFER_BIT) @@ -86,12 +90,13 @@ PrintConfigs(EGLDisplay d) if (strlen(surfString) > 0) surfString[strlen(surfString) - 1] = 0; - printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d 0x%02x %-12s\n", + printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x %-12s\n", id, size, level, doubleBuf ? 'y' : '.', stereo ? 'y' : '.', red, green, blue, alpha, - depth, stencil, vid, surfString); + depth, stencil, + samples, sampleBuffers, vid, surfString); } } -- cgit v1.2.3 From d7a7b0a10dd355fbeb7a404091a42d4ab558c820 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 16:48:13 -0600 Subject: mesa: new gl_fragment_program fields indicating use of fog, front-facing, point coord --- src/mesa/main/mtypes.h | 5 +++- src/mesa/shader/slang/slang_link.c | 50 ++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2fc169493b..a5e1cf6a27 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1953,7 +1953,10 @@ struct gl_fragment_program { struct gl_program Base; /**< base class */ GLenum FogOption; - GLboolean UsesKill; + GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean UsesPointCoord; /**< shader uses gl_PointCoord */ + GLboolean UsesFrontFacing; /**< shader used gl_FrontFacing */ + GLboolean UsesFogFragCoord; /**< shader used gl_FogFragCoord */ }; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index a44d001477..dd7d5be6d8 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -42,6 +42,24 @@ #include "slang_link.h" +/** cast wrapper */ +static struct gl_vertex_program * +vertex_program(struct gl_program *prog) +{ + assert(prog->Target == GL_VERTEX_PROGRAM_ARB); + return (struct gl_vertex_program *) prog; +} + + +/** cast wrapper */ +static struct gl_fragment_program * +fragment_program(struct gl_program *prog) +{ + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); + return (struct gl_fragment_program *) prog; +} + + /** * Record a linking error. */ @@ -374,6 +392,20 @@ _slang_update_inputs_outputs(struct gl_program *prog) for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == PROGRAM_INPUT) { prog->InputsRead |= 1 << inst->SrcReg[j].Index; + if (prog->Target == GL_FRAGMENT_PROGRAM_ARB && + inst->SrcReg[j].Index == FRAG_ATTRIB_FOGC) { + /* The fragment shader FOGC input is used for fog, + * front-facing and sprite/point coord. + */ + struct gl_fragment_program *fp = fragment_program(prog); + const GLint swz = GET_SWZ(inst->SrcReg[j].Swizzle, 0); + if (swz == SWIZZLE_X) + fp->UsesFogFragCoord = GL_TRUE; + else if (swz == SWIZZLE_Y) + fp->UsesFrontFacing = GL_TRUE; + else if (swz == SWIZZLE_Z || swz == SWIZZLE_W) + fp->UsesPointCoord = GL_TRUE; + } } else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { maxAddrReg = MAX2(maxAddrReg, inst->SrcReg[j].Index + 1); @@ -391,24 +423,6 @@ _slang_update_inputs_outputs(struct gl_program *prog) } -/** cast wrapper */ -static struct gl_vertex_program * -vertex_program(struct gl_program *prog) -{ - assert(prog->Target == GL_VERTEX_PROGRAM_ARB); - return (struct gl_vertex_program *) prog; -} - - -/** cast wrapper */ -static struct gl_fragment_program * -fragment_program(struct gl_program *prog) -{ - assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); - return (struct gl_fragment_program *) prog; -} - - /** * Shader linker. Currently: * -- cgit v1.2.3 From 4ee8d1ad679ea8540e91616933a880cdb3836a19 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 16:49:26 -0600 Subject: gallium: fix fog vs. pointcoord attribute handling in mesa->TGSI conversion --- src/mesa/state_tracker/st_program.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 936a6e32ea..b2abf0286e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -409,7 +409,10 @@ st_translate_fragment_program(struct st_context *st, interpMode[slot] = TGSI_INTERPOLATE_LINEAR; break; case FRAG_ATTRIB_FOGC: - stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + if (stfp->Base.UsesPointCoord) + stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + else + stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; stfp->input_semantic_index[slot] = 0; interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; -- cgit v1.2.3 From a06d38a74e865a0373a7314aad26b25c27ef8c57 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Sep 2008 16:51:53 -0600 Subject: gallium: fix wide point / point coord semantic info (generic, not fog) --- src/gallium/auxiliary/draw/draw_pipe_wide_point.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c index 4f1326053d..e1af9e56a2 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c @@ -222,8 +222,8 @@ static void widepoint_first_point( struct draw_stage *stage, /* find fragment shader PointCoord/Fog input */ wide->point_coord_fs_input = 0; /* XXX fix this! */ - /* setup extra vp output */ - draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_FOG; + /* setup extra vp output (point coord implemented as a texcoord) */ + draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC; draw->extra_vp_outputs.semantic_index = 0; draw->extra_vp_outputs.slot = draw->vs.num_vs_outputs; } -- cgit v1.2.3 From 1672e8e05996d48e51a1998bd7e9b08b78e012f5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Sep 2008 11:10:09 +0900 Subject: pipebuffer: New callback to flush all temporary-held buffers. Used mostly to aid debugging memory issues or to clean up resources when the drivers are long lived. --- .../auxiliary/pipebuffer/pb_buffer_malloc.c | 14 +++++++++--- src/gallium/auxiliary/pipebuffer/pb_bufmgr.h | 14 ++++++++---- src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c | 16 +++++++++++++ src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 11 ++++++--- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 11 +++++++++ .../auxiliary/pipebuffer/pb_bufmgr_fenced.c | 14 ++++++++++++ src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 10 ++++++++- src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 8 +++++++ src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 26 ++++++++++++++++++++++ 9 files changed, 113 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c index 20fc87b39d..1bf22a2ec0 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c @@ -129,7 +129,7 @@ pb_malloc_buffer_create(size_t size, static struct pb_buffer * -pb_malloc_buffer_create_buffer(struct pb_manager *mgr, +pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr, size_t size, const struct pb_desc *desc) { @@ -137,6 +137,13 @@ pb_malloc_buffer_create_buffer(struct pb_manager *mgr, } +static void +pb_malloc_bufmgr_flush(struct pb_manager *mgr) +{ + /* No-op */ +} + + static void pb_malloc_bufmgr_destroy(struct pb_manager *mgr) { @@ -146,8 +153,9 @@ pb_malloc_bufmgr_destroy(struct pb_manager *mgr) static struct pb_manager pb_malloc_bufmgr = { - pb_malloc_buffer_create_buffer, - pb_malloc_bufmgr_destroy + pb_malloc_bufmgr_destroy, + pb_malloc_bufmgr_create_buffer, + pb_malloc_bufmgr_flush }; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h index 32867029ee..cafbee045a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h @@ -69,13 +69,22 @@ struct pipe_winsys; */ struct pb_manager { + void + (*destroy)( struct pb_manager *mgr ); + struct pb_buffer * (*create_buffer)( struct pb_manager *mgr, size_t size, const struct pb_desc *desc); + /** + * Flush all temporary-held buffers. + * + * Used mostly to aid debugging memory issues or to clean up resources when + * the drivers are long lived. + */ void - (*destroy)( struct pb_manager *mgr ); + (*flush)( struct pb_manager *mgr ); }; @@ -153,9 +162,6 @@ struct pb_manager * pb_cache_manager_create(struct pb_manager *provider, unsigned usecs); -void -pb_cache_flush(struct pb_manager *mgr); - /** * Fenced buffer manager. diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c index 2afaeafa1a..c956924cc7 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c @@ -75,6 +75,21 @@ pb_alt_manager_create_buffer(struct pb_manager *_mgr, } +static void +pb_alt_manager_flush(struct pb_manager *_mgr) +{ + struct pb_alt_manager *mgr = pb_alt_manager(_mgr); + + assert(mgr->provider1->flush); + if(mgr->provider1->flush) + mgr->provider1->flush(mgr->provider1); + + assert(mgr->provider2->flush); + if(mgr->provider2->flush) + mgr->provider2->flush(mgr->provider2); +} + + static void pb_alt_manager_destroy(struct pb_manager *mgr) { @@ -97,6 +112,7 @@ pb_alt_manager_create(struct pb_manager *provider1, mgr->base.destroy = pb_alt_manager_destroy; mgr->base.create_buffer = pb_alt_manager_create_buffer; + mgr->base.flush = pb_alt_manager_flush; mgr->provider1 = provider1; mgr->provider2 = provider2; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 1ec422fb19..8f118874ec 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -306,8 +306,8 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, } -void -pb_cache_flush(struct pb_manager *_mgr) +static void +pb_cache_manager_flush(struct pb_manager *_mgr) { struct pb_cache_manager *mgr = pb_cache_manager(_mgr); struct list_head *curr, *next; @@ -323,13 +323,17 @@ pb_cache_flush(struct pb_manager *_mgr) next = curr->next; } pipe_mutex_unlock(mgr->mutex); + + assert(mgr->provider->flush); + if(mgr->provider->flush) + mgr->provider->flush(mgr->provider); } static void pb_cache_manager_destroy(struct pb_manager *mgr) { - pb_cache_flush(mgr); + pb_cache_manager_flush(mgr); FREE(mgr); } @@ -349,6 +353,7 @@ pb_cache_manager_create(struct pb_manager *provider, mgr->base.destroy = pb_cache_manager_destroy; mgr->base.create_buffer = pb_cache_manager_create_buffer; + mgr->base.flush = pb_cache_manager_flush; mgr->provider = provider; mgr->usecs = usecs; LIST_INITHEAD(&mgr->delayed); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 5f1ed3e5a8..1675e6e182 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -313,6 +313,16 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, } +static void +pb_debug_manager_flush(struct pb_manager *_mgr) +{ + struct pb_debug_manager *mgr = pb_debug_manager(_mgr); + assert(mgr->provider->flush); + if(mgr->provider->flush) + mgr->provider->flush(mgr->provider); +} + + static void pb_debug_manager_destroy(struct pb_manager *_mgr) { @@ -336,6 +346,7 @@ pb_debug_manager_create(struct pb_manager *provider, size_t band_size) mgr->base.destroy = pb_debug_manager_destroy; mgr->base.create_buffer = pb_debug_manager_create_buffer; + mgr->base.flush = pb_debug_manager_flush; mgr->provider = provider; mgr->band_size = band_size; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c index 8fc63ce648..633ee70a75 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c @@ -94,6 +94,19 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr, } +static void +fenced_bufmgr_flush(struct pb_manager *mgr) +{ + struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); + + fenced_buffer_list_check_free(fenced_mgr->fenced_list, TRUE); + + assert(fenced_mgr->provider->flush); + if(fenced_mgr->provider->flush) + fenced_mgr->provider->flush(fenced_mgr->provider); +} + + static void fenced_bufmgr_destroy(struct pb_manager *mgr) { @@ -123,6 +136,7 @@ fenced_bufmgr_create(struct pb_manager *provider, fenced_mgr->base.destroy = fenced_bufmgr_destroy; fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer; + fenced_mgr->base.flush = fenced_bufmgr_flush; fenced_mgr->provider = provider; fenced_mgr->fenced_list = fenced_buffer_list_create(winsys); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index e8c7f8e1f8..fe80ca30ee 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -199,6 +199,13 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, } +static void +mm_bufmgr_flush(struct pb_manager *mgr) +{ + /* No-op */ +} + + static void mm_bufmgr_destroy(struct pb_manager *mgr) { @@ -230,8 +237,9 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, if (!mm) return NULL; - mm->base.create_buffer = mm_bufmgr_create_buffer; mm->base.destroy = mm_bufmgr_destroy; + mm->base.create_buffer = mm_bufmgr_create_buffer; + mm->base.flush = mm_bufmgr_flush; mm->size = size; mm->align2 = align2; /* 64-byte alignment */ diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 3ef72c5bbb..61ac291ed7 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -202,6 +202,13 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr, } +static void +pool_bufmgr_flush(struct pb_manager *mgr) +{ + /* No-op */ +} + + static void pool_bufmgr_destroy(struct pb_manager *mgr) { @@ -238,6 +245,7 @@ pool_bufmgr_create(struct pb_manager *provider, pool->base.destroy = pool_bufmgr_destroy; pool->base.create_buffer = pool_bufmgr_create_buffer; + pool->base.flush = pool_bufmgr_flush; LIST_INITHEAD(&pool->free); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index 8698c4cff6..2a80154920 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -406,6 +406,17 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr, } +static void +pb_slab_manager_flush(struct pb_manager *_mgr) +{ + struct pb_slab_manager *mgr = pb_slab_manager(_mgr); + + assert(mgr->provider->flush); + if(mgr->provider->flush) + mgr->provider->flush(mgr->provider); +} + + static void pb_slab_manager_destroy(struct pb_manager *_mgr) { @@ -430,6 +441,7 @@ pb_slab_manager_create(struct pb_manager *provider, mgr->base.destroy = pb_slab_manager_destroy; mgr->base.create_buffer = pb_slab_manager_create_buffer; + mgr->base.flush = pb_slab_manager_flush; mgr->provider = provider; mgr->bufSize = bufSize; @@ -465,6 +477,19 @@ pb_slab_range_manager_create_buffer(struct pb_manager *_mgr, } +static void +pb_slab_range_manager_flush(struct pb_manager *_mgr) +{ + struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr); + + /* Individual slabs don't hold any temporary buffers so no need to call them */ + + assert(mgr->provider->flush); + if(mgr->provider->flush) + mgr->provider->flush(mgr->provider); +} + + static void pb_slab_range_manager_destroy(struct pb_manager *_mgr) { @@ -499,6 +524,7 @@ pb_slab_range_manager_create(struct pb_manager *provider, mgr->base.destroy = pb_slab_range_manager_destroy; mgr->base.create_buffer = pb_slab_range_manager_create_buffer; + mgr->base.flush = pb_slab_range_manager_flush; mgr->provider = provider; mgr->minBufSize = minBufSize; -- cgit v1.2.3 From fa7529335c38d4c139e5b1fc17a518f7e5fa1d82 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Sep 2008 14:14:56 +0200 Subject: progs/fp: Add a bit of local variable testing to fp-tri --- progs/fp/fp-tri.c | 2 ++ progs/fp/local.txt | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 progs/fp/local.txt diff --git a/progs/fp/fp-tri.c b/progs/fp/fp-tri.c index cb991f803e..2512e824ee 100644 --- a/progs/fp/fp-tri.c +++ b/progs/fp/fp-tri.c @@ -130,6 +130,8 @@ static void Display(void) { glClear(GL_COLOR_BUFFER_BIT); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 1.0, 1.0, 0.0, 0.0); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 0.0, 0.0, 1.0, 1.0); glBegin(GL_TRIANGLES); glColor3f(0,0,1); glVertex3f( 0.9, -0.9, -30.0); diff --git a/progs/fp/local.txt b/progs/fp/local.txt new file mode 100644 index 0000000000..6cb2a2f13c --- /dev/null +++ b/progs/fp/local.txt @@ -0,0 +1,11 @@ +!!ARBfp1.0 +TEMP R0; +PARAM c[4] = { { 0, 0, 0, 0 }, + program.local[0..1], + { 1, 1, 1, 1 } }; +MOV R0, c[1]; +SUB R0, R0, c[0]; +ADD R0, R0, c[2]; +MUL R0, R0, c[3]; +MOV result.color, R0; +END -- cgit v1.2.3 From 5e1ef85dc430a4439cd60b66262eab9062dd5f4f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Sep 2008 14:48:45 +0200 Subject: tgsi: Make tgsi dumps look more like mesa shader dumps. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index afc8ffa553..3177f54952 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -68,6 +68,7 @@ dump_enum( #define CHR(C) ctx->printf( ctx, "%c", C ) #define UIX(I) ctx->printf( ctx, "0x%x", I ) #define UID(I) ctx->printf( ctx, "%u", I ) +#define INSTID(I) ctx->printf( ctx, "% 3u", I ) #define SID(I) ctx->printf( ctx, "%d", I ) #define FLT(F) ctx->printf( ctx, "%10.4f", F ) #define ENM(E,ENUMS) dump_enum( ctx, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) ) @@ -315,8 +316,8 @@ iter_instruction( uint i; boolean first_reg = TRUE; - UID( instno ); - CHR( ':' ); + INSTID( instno ); + TXT( ": " ); TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic ); switch (inst->Instruction.Saturate) { -- cgit v1.2.3 From f68d2a0febca38bc7b31f9ab9718e944935b48bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 18 Sep 2008 08:10:34 -0600 Subject: gallium: fix surface object memory leak in cso module --- src/gallium/auxiliary/cso_cache/cso_context.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index b1ccfc0374..68508f24de 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -80,6 +80,10 @@ struct cso_context { }; +static void +free_framebuffer_state(struct pipe_framebuffer_state *fb); + + static boolean delete_blend_state(struct cso_context *ctx, void *state) { struct cso_blend *cso = (struct cso_blend *)state; @@ -252,6 +256,9 @@ void cso_release_all( struct cso_context *ctx ) pipe_texture_reference(&ctx->textures_saved[i], NULL); } + free_framebuffer_state(&ctx->fb); + free_framebuffer_state(&ctx->fb_saved); + if (ctx->cache) { cso_cache_delete( ctx->cache ); ctx->cache = NULL; @@ -784,6 +791,18 @@ copy_framebuffer_state(struct pipe_framebuffer_state *dst, } +static void +free_framebuffer_state(struct pipe_framebuffer_state *fb) +{ + uint i; + + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + pipe_surface_reference(&fb->cbufs[i], NULL); + } + pipe_surface_reference(&fb->zsbuf, NULL); +} + + enum pipe_error cso_set_framebuffer(struct cso_context *ctx, const struct pipe_framebuffer_state *fb) { @@ -804,6 +823,7 @@ void cso_restore_framebuffer(struct cso_context *ctx) if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) { copy_framebuffer_state(&ctx->fb, &ctx->fb_saved); ctx->pipe->set_framebuffer_state(ctx->pipe, &ctx->fb); + free_framebuffer_state(&ctx->fb_saved); } } -- cgit v1.2.3 From 451888ee8f9d9749a2d52351374a14525c07ef2b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Sep 2008 22:24:45 +0900 Subject: util: Add missing p_debug.h include. --- src/gallium/auxiliary/util/u_math.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index 0b10622ee7..196aeb28fa 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -40,6 +40,7 @@ #include "pipe/p_compiler.h" +#include "pipe/p_debug.h" #ifdef __cplusplus -- cgit v1.2.3 From eb5c288df48fa818ecb2bbd71f263ec68ebbef8a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 18 Sep 2008 23:00:18 +0900 Subject: util: A few more memory debugging checks. --- src/gallium/auxiliary/util/p_debug_mem.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/p_debug_mem.c index ed18c6540e..9511479cbb 100644 --- a/src/gallium/auxiliary/util/p_debug_mem.c +++ b/src/gallium/auxiliary/util/p_debug_mem.c @@ -122,8 +122,12 @@ debug_malloc(const char *file, unsigned line, const char *function, struct debug_memory_footer *ftr; hdr = real_malloc(sizeof(*hdr) + size + sizeof(*ftr)); - if(!hdr) + if(!hdr) { + debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n", + file, line, function, + (long unsigned)size); return NULL; + } hdr->no = last_no++; hdr->file = file; @@ -219,8 +223,12 @@ debug_realloc(const char *file, unsigned line, const char *function, /* alloc new */ new_hdr = real_malloc(sizeof(*new_hdr) + new_size + sizeof(*new_ftr)); - if(!new_hdr) + if(!new_hdr) { + debug_printf("%s:%u:%s: out of memory when trying to allocate %lu bytes\n", + file, line, function, + (long unsigned)new_size); return NULL; + } new_hdr->no = old_hdr->no; new_hdr->file = old_hdr->file; new_hdr->line = old_hdr->line; @@ -261,8 +269,19 @@ debug_memory_end(unsigned long start_no) for (; entry != &list; entry = entry->prev) { struct debug_memory_header *hdr; void *ptr; + struct debug_memory_footer *ftr; + hdr = LIST_ENTRY(struct debug_memory_header, entry, head); ptr = data_from_header(hdr); + ftr = footer_from_header(hdr); + + if(hdr->magic != DEBUG_MEMORY_MAGIC) { + debug_printf("%s:%u:%s: bad or corrupted memory %p\n", + hdr->file, hdr->line, hdr->function, + ptr); + debug_assert(0); + } + if((start_no <= hdr->no && hdr->no < last_no) || (last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))) { debug_printf("%s:%u:%s: %u bytes at %p not freed\n", @@ -270,7 +289,15 @@ debug_memory_end(unsigned long start_no) hdr->size, ptr); total_size += hdr->size; } + + if(ftr->magic != DEBUG_MEMORY_MAGIC) { + debug_printf("%s:%u:%s: buffer overflow %p\n", + hdr->file, hdr->line, hdr->function, + ptr); + debug_assert(0); + } } + if(total_size) { debug_printf("Total of %u KB of system memory apparently leaked\n", (total_size + 1023)/1024); -- cgit v1.2.3 From 0b8e19ffc51c29543796d4f1e3243e97d8c32671 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Sep 2008 16:28:16 +0200 Subject: tgsi: Build tgsi_text with make --- src/gallium/auxiliary/tgsi/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile index c5d2082087..c7155a9316 100644 --- a/src/gallium/auxiliary/tgsi/Makefile +++ b/src/gallium/auxiliary/tgsi/Makefile @@ -13,6 +13,7 @@ C_SOURCES = \ tgsi_parse.c \ tgsi_scan.c \ tgsi_sse2.c \ + tgsi_text.c \ tgsi_transform.c \ tgsi_util.c -- cgit v1.2.3