From 47173cf67f0ed55012b0820397f6d620d8ad4473 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 09:55:33 +0100 Subject: mesa/dlist: shortcircuit some redundant statechanges at compile time Currently, state-changes in mesa display lists are more or less a verbatim recording of the GL calls made during compilation. This change introduces a minor optimization to recognize and eliminate cases where the application emits redundant state changes, eg: glShadeModel( GL_FLAT ); glBegin( prim ) ... glEnd() glShadeModel( GL_FLAT ); glBegin( prim ) ... glEnd() The big win is when we can eliminate all the statechanges between two primitive blocks and combine them into a single VBO node. This commit implements state-change elimination for Material and ShadeModel only. This is enough to make a start on debugging, etc. --- src/mesa/main/dlist.c | 63 +++++++++++++++++++++++++++++++++++--------------- src/mesa/main/mtypes.h | 7 ++++++ 2 files changed, 51 insertions(+), 19 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 782f847904..3647401a1b 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -3177,14 +3177,21 @@ save_ShadeModel(GLenum mode) { GET_CURRENT_CONTEXT(ctx); Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); + + if (ctx->ExecuteFlag) { + CALL_ShadeModel(ctx->Exec, (mode)); + } + + if (ctx->ListState.Current.ShadeModel == mode) + return; + + ctx->ListState.Current.ShadeModel = mode; + n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1); if (n) { n[1].e = mode; } - if (ctx->ExecuteFlag) { - CALL_ShadeModel(ctx->Exec, (mode)); - } } @@ -5146,14 +5153,21 @@ save_EdgeFlag(GLboolean x) save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0); } +static INLINE GLboolean compare4fv( const GLfloat *a, + const GLfloat *b, + GLuint count ) +{ + return memcmp( a, b, count * sizeof(GLfloat) ) == 0; +} + + static void GLAPIENTRY save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) { GET_CURRENT_CONTEXT(ctx); Node *n; int args, i; - - SAVE_FLUSH_VERTICES(ctx); + GLuint bitmask; switch (face) { case GL_BACK: @@ -5183,6 +5197,28 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) _mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)"); return; } + + if (ctx->ExecuteFlag) { + CALL_Materialfv(ctx->Exec, (face, pname, param)); + } + + bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); + + /* Try to eliminate redundant statechanges + */ + for (i = 0; i < MAT_ATTRIB_MAX; i++) { + if (bitmask & (1 << i)) { + if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END && + ctx->ListState.ActiveMaterialSize[i] == args && + compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) + return; + + ctx->ListState.ActiveMaterialSize[i] = args; + COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + } + } + + SAVE_FLUSH_VERTICES(ctx); n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6); if (n) { @@ -5191,19 +5227,6 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) for (i = 0; i < args; i++) n[3 + i].f = param[i]; } - - { - GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - for (i = 0; i < MAT_ATTRIB_MAX; i++) - if (bitmask & (1 << i)) { - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); - } - } - - if (ctx->ExecuteFlag) { - CALL_Materialfv(ctx->Exec, (face, pname, param)); - } } static void GLAPIENTRY @@ -6812,6 +6835,8 @@ _mesa_NewList(GLuint name, GLenum mode) for (i = 0; i < MAT_ATTRIB_MAX; i++) ctx->ListState.ActiveMaterialSize[i] = 0; + memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); + ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; ctx->Driver.NewList(ctx, name, mode); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 84a082b253..bdaa4977b7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2806,6 +2806,13 @@ struct gl_dlist_state GLubyte ActiveEdgeFlag; GLboolean CurrentEdgeFlag; + + struct { + /* State known to have been set by the currently-compiling display + * list. Used to eliminate some redundant state changes. + */ + GLenum ShadeModel; + } Current; }; -- cgit v1.2.3 From aa688d1579776494640475f4a5b93f3d7fae4fcd Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 12:13:50 +0100 Subject: mesa: add debug printer for primitive name Add a simple version of _mesa_lookup_enum_by_nr() which expects a primitive enum (GL_POINTS..GL_POLYGON). This avoids some annoying duplicates when looking up primitives, such as the GL_FALSE/GL_POINTS clash. --- src/mesa/main/enums.c | 22 ++++++++++++++++++++++ src/mesa/main/enums.h | 6 ++++++ 2 files changed, 28 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index cf893fdac5..417cee8fb2 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -5059,6 +5059,28 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } } +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ) +{ + switch (nr) { + case GL_POINTS: return "GL_POINTS"; + case GL_LINES: return "GL_LINES"; + case GL_LINE_STRIP: return "GL_LINE_STRIP"; + case GL_LINE_LOOP: return "GL_LINE_LOOP"; + case GL_TRIANGLES: return "GL_TRIANGLES"; + case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; + case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; + case GL_QUADS: return "GL_QUADS"; + case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; + case GL_POLYGON: return "GL_POLYGON"; + case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; + default: return ""; + } +} + + int _mesa_lookup_enum_by_name( const char *symbol ) { enum_elt * f = NULL; diff --git a/src/mesa/main/enums.h b/src/mesa/main/enums.h index 23a4767f35..b5f69001b8 100644 --- a/src/mesa/main/enums.h +++ b/src/mesa/main/enums.h @@ -40,6 +40,12 @@ #if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL extern const char *_mesa_lookup_enum_by_nr( int nr ); + +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ); + extern int _mesa_lookup_enum_by_name( const char *symbol ); #else -- cgit v1.2.3 From 0846c88ec3a63ac5e4096aedcdc107cbe71f306b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 12:16:41 +0100 Subject: mesa/vbo: use _lookup_prim_by_nr for debugging Switch over to specialized enum lookup for primitives --- src/mesa/vbo/vbo_exec_draw.c | 2 +- src/mesa/vbo/vbo_save_api.c | 2 +- src/mesa/vbo/vbo_save_loopback.c | 2 +- src/mesa/vbo/vbo_split_copy.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index da2d849ded..e238d55c82 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -50,7 +50,7 @@ static void vbo_exec_debug_verts( struct vbo_exec_context *exec ) struct _mesa_prim *prim = &exec->vtx.prim[i]; _mesa_printf(" prim %d: %s%s %d..%d %s %s\n", i, - _mesa_lookup_enum_by_nr(prim->mode), + _mesa_lookup_prim_by_nr(prim->mode), prim->weak ? " (weak)" : "", prim->start, prim->start + prim->count, diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 868226075a..971a338af4 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1148,7 +1148,7 @@ static void vbo_print_vertex_list( GLcontext *ctx, void *data ) struct _mesa_prim *prim = &node->prim[i]; _mesa_debug(NULL, " prim %d: %s%s %d..%d %s %s\n", i, - _mesa_lookup_enum_by_nr(prim->mode), + _mesa_lookup_prim_by_nr(prim->mode), prim->weak ? " (weak)" : "", prim->start, prim->start + prim->count, diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 92ca4ea95d..b7a74e4535 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -97,7 +97,7 @@ static void loopback_prim( GLcontext *ctx, if (0) _mesa_printf("loopback prim %s(%s,%s) verts %d..%d\n", - _mesa_lookup_enum_by_nr(prim->mode), + _mesa_lookup_prim_by_nr(prim->mode), prim->begin ? "begin" : "..", prim->end ? "end" : "..", start, diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 5fb66d3318..b9a5c56987 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -180,7 +180,7 @@ static void begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag { struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; -/* _mesa_printf("begin %s (%d)\n", _mesa_lookup_enum_by_nr(mode), begin_flag); */ +/* _mesa_printf("begin %s (%d)\n", _mesa_lookup_prim_by_nr(mode), begin_flag); */ prim->mode = mode; prim->begin = begin_flag; -- cgit v1.2.3 From 00438bb94a9ee03f8a4d5472d7ae598fcbdb1572 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 12:19:11 +0100 Subject: mesa/dlist: restore missing SAVE_FLUSH_VERTICES in save_ShadeModel Reorganization of ShadeModel to avoid flushing vertices too often ended up never flushing vertices due to omitted line of code. --- src/mesa/main/dlist.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 3647401a1b..93b8a8f56d 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -3186,6 +3186,7 @@ save_ShadeModel(GLenum mode) if (ctx->ListState.Current.ShadeModel == mode) return; + SAVE_FLUSH_VERTICES(ctx); ctx->ListState.Current.ShadeModel = mode; n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1); -- cgit v1.2.3 From e5cb11addad31f698dc8261e7f96d5e3af4a85d6 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 19:52:44 +0100 Subject: mesa/vbo: fix compile and replay of nodes ending in a FALLBACK Where vbo save nodes are terminated with a call to DO_FALLBACK(), as in the case of a recursive CallList which is itself within a Begin/End pair, there two problems: 1) The display list node's primitive information was incorrect, stating the cut-off prim had zero vertices 2) On replay, we would get confused by a primitive that started in a node, but was terminated by individual opcodes. This change fixes the first problem by correctly terminating the last primitive on fallback, and the second by forcing the display list to use the Loopback path, converting all nodes into immediate-mode rendering. The loopback fix is a performance hit, but avoiding this would require a fairly large rework of this code. --- progs/trivial/Makefile | 1 + progs/trivial/dlist-begin-call-end.c | 159 +++++++++++++++++++++++++++++++++++ src/mesa/vbo/vbo_save_api.c | 40 ++++++--- 3 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 progs/trivial/dlist-begin-call-end.c (limited to 'src/mesa') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index de862b067c..fa200dbf89 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -19,6 +19,7 @@ SOURCES = \ clear-random.c \ clear.c \ dlist-dangling.c \ + dlist-begin-call-end.c \ dlist-edgeflag-dangling.c \ dlist-edgeflag.c \ dlist-degenerate.c \ diff --git a/progs/trivial/dlist-begin-call-end.c b/progs/trivial/dlist-begin-call-end.c new file mode 100644 index 0000000000..0d0aed7c72 --- /dev/null +++ b/progs/trivial/dlist-begin-call-end.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; +GLint first_list, list; + +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); + + glClearColor(0.0, 0.0, 1.0, 0.0); + + /* First list will disrupt state which might potentially be + * short-circuited in calling list: + */ + first_list = glGenLists(1); + glNewList(first_list, GL_COMPILE); +// glColor3f(0,1,0); + glEndList(); + + + /* List that looks like it might have redundant state: + */ + list = glGenLists(1); + glNewList(list, GL_COMPILE); + + glShadeModel(GL_FLAT); + glBegin(GL_TRIANGLES); + glColor3f(1,0,0); + glVertex3f( -0.9, 0.9, -30.0); + glVertex3f( -0.9, -0.9, -30.0); + glCallList( first_list ); + glVertex3f( 0.9, 0.0, -30.0); + glEnd(); + glEndList(); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)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: + return; + } + + glutPostRedisplay(); +} + + + + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glShadeModel( GL_SMOOTH ); + glCallList(list); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 868226075a..7dcb5c8242 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -667,19 +667,33 @@ do { \ * -- Flush current buffer * -- Fallback to opcodes for the rest of the begin/end object. */ -#define DO_FALLBACK(ctx) \ -do { \ - struct vbo_save_context *save = &vbo_context(ctx)->save; \ - \ - if (save->vert_count || save->prim_count) \ - _save_compile_vertex_list( ctx ); \ - \ - _save_copy_to_current( ctx ); \ - _save_reset_vertex( ctx ); \ - _save_reset_counters( ctx ); \ - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \ - ctx->Driver.SaveNeedFlush = 0; \ -} while (0) +static void DO_FALLBACK( GLcontext *ctx ) +{ + struct vbo_save_context *save = &vbo_context(ctx)->save; + + if (save->vert_count || save->prim_count) { + GLint i = save->prim_count - 1; + + /* Close off in-progress primitive. + */ + save->prim[i].count = (save->vert_count - + save->prim[i].start); + + /* Need to replay this display list with loopback, + * unfortunately, otherwise this primitive won't be handled + * properly: + */ + save->dangling_attr_ref = 1; + + _save_compile_vertex_list( ctx ); + } + + _save_copy_to_current( ctx ); + _save_reset_vertex( ctx ); + _save_reset_counters( ctx ); + _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); + ctx->Driver.SaveNeedFlush = 0; +} static void GLAPIENTRY _save_EvalCoord1f( GLfloat u ) { -- cgit v1.2.3 From c72261f2a886e1f53025c2cf4b38b33ccfd62857 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 29 Jun 2009 18:48:27 -0700 Subject: i915: Fix assertion failure on remapping a non-BO-backed VBO. Failure to set the obj->Pointer back to null tripped up the assertion. Bug #22428. (cherry picked from commit 57a06d3a48c9af1067ec05e3ad96c58f4b9b99be) --- src/mesa/drivers/dri/intel/intel_buffer_objects.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index c31fe91ad6..2e6b77824d 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -265,7 +265,10 @@ intel_bufferobj_unmap(GLcontext * ctx, struct intel_buffer_object *intel_obj = intel_buffer_object(obj); assert(intel_obj); - if (intel_obj->buffer != NULL) { + if (intel_obj->sys_buffer != NULL) { + assert(obj->Pointer); + obj->Pointer = NULL; + } else if (intel_obj->buffer != NULL) { assert(obj->Pointer); if (intel_obj->mapped_gtt) { drm_intel_gem_bo_unmap_gtt(intel_obj->buffer); -- cgit v1.2.3 From 1c04731b8721850b6abb12a43a3eec616b850e86 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 1 Jul 2009 10:42:58 -0400 Subject: gallium: fix the front face semantics mesa allocates both frontface and pointcoord registers within the fog coordinate register, by using swizzling. to make it cleaner and easier for drivers we want each of them in its own register. so when doing compilation from the mesa IR to tgsi allocate new registers for both and add new semantics to the respective declarations. --- src/gallium/drivers/softpipe/sp_setup.c | 27 +++++++++++-------------- src/gallium/drivers/softpipe/sp_state_derived.c | 1 + src/gallium/include/pipe/p_shader_tokens.h | 3 ++- src/mesa/state_tracker/st_atom_shader.c | 19 +++++++++++++++-- src/mesa/state_tracker/st_mesa_to_tgsi.c | 23 ++++++++++++++++++++- src/mesa/state_tracker/st_program.c | 7 ++++++- 6 files changed, 60 insertions(+), 20 deletions(-) (limited to 'src/mesa') diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index e5be65242d..1eb23cd6b6 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -785,11 +785,10 @@ static void setup_tri_coefficients( struct setup_context *setup ) assert(0); } - if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { - /* FOG.y = front/back facing XXX fix this */ - setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing; - setup->coef[fragSlot].dadx[1] = 0.0; - setup->coef[fragSlot].dady[1] = 0.0; + if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { + setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing; + setup->coef[fragSlot].dadx[0] = 0.0; + setup->coef[fragSlot].dady[0] = 0.0; } } } @@ -1096,11 +1095,10 @@ setup_line_coefficients(struct setup_context *setup, assert(0); } - if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { - /* FOG.y = front/back facing XXX fix this */ - setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing; - setup->coef[fragSlot].dadx[1] = 0.0; - setup->coef[fragSlot].dady[1] = 0.0; + if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { + setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing; + setup->coef[fragSlot].dadx[0] = 0.0; + setup->coef[fragSlot].dady[0] = 0.0; } } return TRUE; @@ -1342,11 +1340,10 @@ setup_point( struct setup_context *setup, assert(0); } - if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) { - /* FOG.y = front/back facing XXX fix this */ - setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing; - setup->coef[fragSlot].dadx[1] = 0.0; - setup->coef[fragSlot].dady[1] = 0.0; + if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) { + setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing; + setup->coef[fragSlot].dadx[0] = 0.0; + setup->coef[fragSlot].dady[0] = 0.0; } } diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index 6b6a4c3ff3..75551000c9 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -110,6 +110,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe) break; case TGSI_SEMANTIC_GENERIC: + case TGSI_SEMANTIC_FACE: /* this includes texcoords and varying vars */ src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC, spfs->info.input_semantic_index[i]); diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index 4dafdd6f0a..b00cfe3423 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -131,7 +131,8 @@ struct tgsi_declaration_range #define TGSI_SEMANTIC_PSIZE 4 #define TGSI_SEMANTIC_GENERIC 5 #define TGSI_SEMANTIC_NORMAL 6 -#define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */ +#define TGSI_SEMANTIC_FACE 7 +#define TGSI_SEMANTIC_COUNT 8 /**< number of semantic values */ struct tgsi_declaration_semantic { diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index ee649be885..c02ccc3528 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -137,8 +137,23 @@ find_translated_vp(struct st_context *st, for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) { if (fragInputsRead & (1 << inAttr)) { - stfp->input_to_slot[inAttr] = numIn; - numIn++; + if ((fragInputsRead & FRAG_BIT_FOGC)) { + if (stfp->Base.UsesPointCoord) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + if (stfp->Base.UsesFrontFacing) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + if (stfp->Base.UsesFogFragCoord) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + } else { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } } else { stfp->input_to_slot[inAttr] = UNUSED; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 43c9afccc3..3140ebe04a 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -101,8 +101,10 @@ map_register_file( */ static GLuint map_register_file_index( + GLuint procType, GLuint file, GLuint index, + GLuint *swizzle, const GLuint inputMapping[], const GLuint outputMapping[], const GLuint immediateMapping[], @@ -110,6 +112,20 @@ map_register_file_index( { switch( file ) { case TGSI_FILE_INPUT: + if (procType == TGSI_PROCESSOR_FRAGMENT && + index == FRAG_ATTRIB_FOGC) { + if (GET_SWZ(*swizzle, 0) == SWIZZLE_X) { + /* do nothing we're, ok */ + } else if (GET_SWZ(*swizzle, 0) == SWIZZLE_Y) { + /* replace the swizzle with xxxx */ + *swizzle = MAKE_SWIZZLE4(SWIZZLE_X, + SWIZZLE_X, + SWIZZLE_X, + SWIZZLE_X); + } else { + /* fixme: point coord */ + } + } /* inputs are mapped according to the user-defined map */ return inputMapping[index]; @@ -236,8 +252,10 @@ compile_instruction( fulldst = &fullinst->FullDstRegisters[0]; fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL, GL_FALSE ); fulldst->DstRegister.Index = map_register_file_index( + procType, fulldst->DstRegister.File, inst->DstReg.Index, + NULL, inputMapping, outputMapping, NULL, @@ -246,6 +264,7 @@ compile_instruction( for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) { GLuint j; + GLuint swizzle = inst->SrcReg[i].Swizzle; fullsrc = &fullinst->FullSrcRegisters[i]; @@ -264,8 +283,10 @@ compile_instruction( immediateMapping, indirectAccess ); fullsrc->SrcRegister.Index = map_register_file_index( + procType, fullsrc->SrcRegister.File, inst->SrcReg[i].Index, + &swizzle, inputMapping, outputMapping, immediateMapping, @@ -278,7 +299,7 @@ compile_instruction( GLboolean extended = (inst->SrcReg[i].Negate != NEGATE_NONE && inst->SrcReg[i].Negate != NEGATE_XYZW); for( j = 0; j < 4; j++ ) { - swz[j] = GET_SWZ( inst->SrcReg[i].Swizzle, j ); + swz[j] = GET_SWZ( swizzle, j ); if (swz[j] > SWIZZLE_W) extended = GL_TRUE; } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 72ca852458..9a346fbde0 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -437,11 +437,16 @@ st_translate_fragment_program(struct st_context *st, if (stfp->Base.UsesPointCoord) { stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; stfp->input_semantic_index[slot] = num_generic++; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; + } else if (stfp->Base.UsesFrontFacing) { + stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FACE; + stfp->input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_CONSTANT; } else { stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; stfp->input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } - interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: -- cgit v1.2.3 From e2a8ef4430e153589a9d1a284c8f2005a4a98410 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 1 Jul 2009 19:06:54 +0100 Subject: mesa: Unbind depth/stencil surface from pipe_framebuffer when none is attached. --- src/mesa/state_tracker/st_atom_framebuffer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 536293683e..3ef919a45e 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -147,6 +147,8 @@ update_framebuffer_state( struct st_context *st ) assert(strb->surface); pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } + else + pipe_surface_reference(&framebuffer->zsbuf, NULL); } cso_set_framebuffer(st->cso_context, framebuffer); -- cgit v1.2.3 From a4fd94a54a75a3418462c30f1240ab50b5f24090 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 30 Jun 2009 07:33:54 +0200 Subject: st/gl: Add support for glCompressedTexSubImage --- src/mesa/state_tracker/st_cb_texture.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 14b78d1253..5845b7940c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1169,6 +1169,63 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + struct st_texture_image *stImage = st_texture_image(texImage); + struct pipe_format_block block; + int srcBlockStride; + int dstBlockStride; + int y; + + if (stImage->pt) { + st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level, + PIPE_TRANSFER_WRITE); + texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + PIPE_TRANSFER_WRITE, + xoffset, yoffset, + width, height); + + block = stImage->pt->block; + srcBlockStride = pf_get_stride(&block, width); + dstBlockStride = stImage->transfer->stride; + } else { + assert(stImage->pt); + /* TODO find good values for block and strides */ + /* TODO also adjust texImage->data for yoffset/xoffset */ + return; + } + + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage"); + return; + } + + assert(xoffset % block.width == 0); + assert(yoffset % block.height == 0); + assert(width % block.width == 0); + assert(height % block.height == 0); + + for (y = 0; y < height; y += block.height) { + /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */ + const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(&block, y); + char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(&block, y); + memcpy(dst, src, pf_get_stride(&block, width)); + } + + if (stImage->pt) { + st_texture_image_unmap(ctx->st, stImage); + texImage->Data = NULL; + } +} + + /** * Do a CopyTexSubImage operation using a read transfer from the source, @@ -1818,6 +1875,7 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexSubImage1D = st_TexSubImage1D; functions->TexSubImage2D = st_TexSubImage2D; functions->TexSubImage3D = st_TexSubImage3D; + functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; functions->CopyTexImage1D = st_CopyTexImage1D; functions->CopyTexImage2D = st_CopyTexImage2D; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; -- cgit v1.2.3 From 578230dbbffbf5317d6002d1023dcd62b57186f5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 30 Jun 2009 13:59:45 +0200 Subject: st/gl: Add stubs for CompressedTexSubImage[1D|3D] --- src/mesa/state_tracker/st_cb_texture.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 5845b7940c..a2211ce302 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1169,6 +1169,18 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage1D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + static void st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, @@ -1226,6 +1238,19 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage3D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + /** * Do a CopyTexSubImage operation using a read transfer from the source, @@ -1875,7 +1900,9 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexSubImage1D = st_TexSubImage1D; functions->TexSubImage2D = st_TexSubImage2D; functions->TexSubImage3D = st_TexSubImage3D; + functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D; functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; + functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D; functions->CopyTexImage1D = st_CopyTexImage1D; functions->CopyTexImage2D = st_CopyTexImage2D; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; -- cgit v1.2.3 From f6c8ca06f649ae1367f61eca6fb7635862bd5584 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 31 May 2009 19:01:55 -0700 Subject: mesa: fix material inputs in ffvertex_prog.c Varying material inputs were not being picked up from the same slots where the VBO code is currently placing them (GENERIC0 and above). Most often they were just being ignored. --- src/mesa/main/ffvertex_prog.c | 54 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 43325b1352..b939401de1 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -48,11 +48,9 @@ struct state_key { unsigned light_color_material_mask:12; - unsigned light_material_mask:12; unsigned light_global_enabled:1; unsigned light_local_viewer:1; unsigned light_twoside:1; - unsigned light_color_material:1; unsigned material_shininess_is_zero:1; unsigned need_eye_coords:1; unsigned normalize:1; @@ -125,27 +123,6 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode ) } -/** - * Returns bitmask of flags indicating which materials are set per-vertex - * in the current VB. - * XXX get these from the VBO... - */ -static GLbitfield -tnl_get_per_vertex_materials(GLcontext *ctx) -{ - GLbitfield mask = 0x0; -#if 0 - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - - for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) - if (VB->AttribPtr[i] && VB->AttribPtr[i]->stride) - mask |= 1 << (i - _TNL_FIRST_MAT); -#endif - return mask; -} - /** * Should fog be computed per-vertex? @@ -168,10 +145,11 @@ static GLboolean check_active_shininess( GLcontext *ctx, { GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side); - if (key->light_color_material_mask & bit) + if ((key->varying_vp_inputs & VERT_BIT_COLOR0) && + (key->light_color_material_mask & bit)) return GL_TRUE; - if (key->light_material_mask & bit) + if (key->varying_vp_inputs & (bit << 16)) return GL_TRUE; if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 0.0F) @@ -216,12 +194,9 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) key->light_twoside = 1; if (ctx->Light.ColorMaterialEnabled) { - key->light_color_material = 1; key->light_color_material_mask = ctx->Light.ColorMaterialBitmask; } - key->light_material_mask = tnl_get_per_vertex_materials(ctx); - for (i = 0; i < MAX_LIGHTS; i++) { struct gl_light *light = &ctx->Light.Light[i]; @@ -481,9 +456,9 @@ static struct ureg register_param5(struct tnl_program *p, */ static struct ureg register_input( struct tnl_program *p, GLuint input ) { - /* Material attribs are passed here as inputs >= 32 - */ - if (input >= 32 || (p->state->varying_vp_inputs & (1<state->varying_vp_inputs & (1<program->Base.InputsRead |= (1<color_materials = 0; p->materials = 0; - if (p->state->light_color_material) { - p->materials = + if (p->state->varying_vp_inputs & VERT_BIT_COLOR0) { + p->materials = p->color_materials = p->state->light_color_material_mask; } - p->materials |= p->state->light_material_mask; + p->materials |= (p->state->varying_vp_inputs >> 16); } -/* XXX temporary!!! */ -#define _TNL_ATTRIB_MAT_FRONT_AMBIENT 32 - static struct ureg get_material( struct tnl_program *p, GLuint side, GLuint property ) { @@ -922,8 +894,12 @@ static struct ureg get_material( struct tnl_program *p, GLuint side, if (p->color_materials & (1<materials & (1<materials & (1< Date: Sun, 31 May 2009 19:03:02 -0700 Subject: mesa: remove dead vertex fog code from ffvertex_prog.c --- src/mesa/main/ffvertex_prog.c | 87 ++----------------------------------------- 1 file changed, 3 insertions(+), 84 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index b939401de1..a8e48253a5 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -57,9 +57,7 @@ struct state_key { unsigned rescale_normals:1; unsigned fog_source_is_depth:1; - unsigned tnl_do_vertex_fog:1; unsigned separate_specular:1; - unsigned fog_mode:2; unsigned point_attenuated:1; unsigned point_array:1; unsigned texture_enabled_global:1; @@ -83,23 +81,6 @@ struct state_key { }; - -#define FOG_NONE 0 -#define FOG_LINEAR 1 -#define FOG_EXP 2 -#define FOG_EXP2 3 - -static GLuint translate_fog_mode( GLenum mode ) -{ - switch (mode) { - case GL_LINEAR: return FOG_LINEAR; - case GL_EXP: return FOG_EXP; - case GL_EXP2: return FOG_EXP2; - default: return FOG_NONE; - } -} - - #define TXG_NONE 0 #define TXG_OBJ_LINEAR 1 #define TXG_EYE_LINEAR 2 @@ -124,21 +105,6 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode ) -/** - * Should fog be computed per-vertex? - */ -static GLboolean -tnl_get_per_vertex_fog(GLcontext *ctx) -{ -#if 0 - TNLcontext *tnl = TNL_CONTEXT(ctx); - return tnl->_DoVertexFog; -#else - return GL_FALSE; -#endif -} - - static GLboolean check_active_shininess( GLcontext *ctx, const struct state_key *key, GLuint side ) @@ -234,12 +200,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) if (ctx->Transform.RescaleNormals) key->rescale_normals = 1; - key->fog_mode = translate_fog_mode(fp->FogOption); - if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) key->fog_source_is_depth = 1; - - key->tnl_do_vertex_fog = tnl_get_per_vertex_fog(ctx); if (ctx->Point._Attenuated) key->point_attenuated = 1; @@ -1344,52 +1306,10 @@ static void build_fog( struct tnl_program *p ) input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); } - if (p->state->fog_mode && p->state->tnl_do_vertex_fog) { - struct ureg params = register_param2(p, STATE_INTERNAL, - STATE_FOG_PARAMS_OPTIMIZED); - struct ureg tmp = get_temp(p); - GLboolean useabs = (p->state->fog_mode != FOG_EXP2); - - if (useabs) { - emit_op1(p, OPCODE_ABS, tmp, 0, input); - } - - switch (p->state->fog_mode) { - case FOG_LINEAR: { - struct ureg id = get_identity_param(p); - emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input, - swizzle1(params,X), swizzle1(params,Y)); - emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */ - emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W)); - break; - } - case FOG_EXP: - emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input, - swizzle1(params,Z)); - emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); - break; - case FOG_EXP2: - emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W)); - emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); - emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); - break; - } - - release_temp(p, tmp); - } - else { - /* results = incoming fog coords (compute fog per-fragment later) - * - * KW: Is it really necessary to do anything in this case? - * BP: Yes, we always need to compute the absolute value, unless - * we want to push that down into the fragment program... - */ - GLboolean useabs = GL_TRUE; - emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input); - } + emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); } - + static void build_reflect_texgen( struct tnl_program *p, struct ureg dest, GLuint writemask ) @@ -1646,8 +1566,7 @@ static void build_tnl_program( struct tnl_program *p ) } } - if ((p->state->fragprog_inputs_read & FRAG_BIT_FOGC) || - p->state->fog_mode != FOG_NONE) + if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC) build_fog(p); if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY) -- cgit v1.2.3 From cea259f0392766e8a2e4749c6d5277d866abbc3b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 31 May 2009 19:03:46 -0700 Subject: mesa: remove dead constant pointsize code from ffvertex_prog.c --- src/mesa/main/ffvertex_prog.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index a8e48253a5..c38dba04c7 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -1524,17 +1524,6 @@ static void build_atten_pointsize( struct tnl_program *p ) } -/** - * Emit constant point size. - */ -static void build_constant_pointsize( struct tnl_program *p ) -{ - struct ureg state_size = register_param1(p, STATE_POINT_SIZE); - struct ureg out = register_output(p, VERT_RESULT_PSIZ); - emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, state_size); -} - - /** * Pass-though per-vertex point size, from user's point size array. */ @@ -1576,12 +1565,6 @@ static void build_tnl_program( struct tnl_program *p ) build_atten_pointsize(p); else if (p->state->point_array) build_array_pointsize(p); -#if 0 - else - build_constant_pointsize(p); -#else - (void) build_constant_pointsize; -#endif /* Finish up: */ -- cgit v1.2.3 From 6dfb89e4a09a269cbd5c4dc725881fbd42eaa18a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 31 May 2009 19:04:06 -0700 Subject: mesa: remove whitespace --- src/mesa/main/ffvertex_prog.c | 216 +++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 108 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index c38dba04c7..80dde4b5aa 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * 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"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /** @@ -69,7 +69,7 @@ struct state_key { unsigned light_enabled:1; unsigned light_eyepos3_is_zero:1; unsigned light_spotcutoff_is_180:1; - unsigned light_attenuated:1; + unsigned light_attenuated:1; unsigned texunit_really_enabled:1; unsigned texmat_enabled:1; unsigned texgen_enabled:4; @@ -171,7 +171,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) if (light->EyePosition[3] == 0.0) key->unit[i].light_eyepos3_is_zero = 1; - + if (light->SpotCutoff == 180.0) key->unit[i].light_spotcutoff_is_180 = 1; @@ -215,29 +215,29 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) ctx->Texture._TexMatEnabled || ctx->Texture._EnabledUnits) key->texture_enabled_global = 1; - + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; if (texUnit->_ReallyEnabled) key->unit[i].texunit_really_enabled = 1; - if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) + if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) key->unit[i].texmat_enabled = 1; - + if (texUnit->TexGenEnabled) { key->unit[i].texgen_enabled = 1; - - key->unit[i].texgen_mode0 = + + key->unit[i].texgen_mode0 = translate_texgen( texUnit->TexGenEnabled & (1<<0), texUnit->GenS.Mode ); - key->unit[i].texgen_mode1 = + key->unit[i].texgen_mode1 = translate_texgen( texUnit->TexGenEnabled & (1<<1), texUnit->GenT.Mode ); - key->unit[i].texgen_mode2 = + key->unit[i].texgen_mode2 = translate_texgen( texUnit->TexGenEnabled & (1<<2), texUnit->GenR.Mode ); - key->unit[i].texgen_mode3 = + key->unit[i].texgen_mode3 = translate_texgen( texUnit->TexGenEnabled & (1<<3), texUnit->GenQ.Mode ); } @@ -245,7 +245,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) } - + /* Very useful debugging tool - produces annotated listing of * generated program with line/function references for each * instruction back into this file: @@ -254,7 +254,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) /* Use uregs to represent registers internally, translate to Mesa's - * expected formats on emit. + * expected formats on emit. * * NOTE: These are passed by value extensively in this file rather * than as usual by pointer reference. If this disturbs you, try @@ -280,10 +280,10 @@ struct tnl_program { struct gl_vertex_program *program; GLint max_inst; /** number of instructions allocated for program */ GLboolean mvp_with_dp4; - + GLuint temp_in_use; GLuint temp_reserved; - + struct ureg eye_position; struct ureg eye_position_z; struct ureg eye_position_normalized; @@ -387,7 +387,7 @@ static void release_temps( struct tnl_program *p ) } -static struct ureg register_param5(struct tnl_program *p, +static struct ureg register_param5(struct tnl_program *p, GLint s0, GLint s1, GLint s2, @@ -440,7 +440,7 @@ static struct ureg register_output( struct tnl_program *p, GLuint output ) } -static struct ureg register_const4f( struct tnl_program *p, +static struct ureg register_const4f( struct tnl_program *p, GLfloat s0, GLfloat s1, GLfloat s2, @@ -472,7 +472,7 @@ static GLboolean is_undef( struct ureg reg ) static struct ureg get_identity_param( struct tnl_program *p ) { - if (is_undef(p->identity)) + if (is_undef(p->identity)) p->identity = register_const4f(p, 0,0,0,1); return p->identity; @@ -491,7 +491,7 @@ static void register_matrix_param5( struct tnl_program *p, /* This is a bit sad as the support is there to pull the whole * matrix out in one go: */ - for (i = 0; i <= s3 - s2; i++) + for (i = 0; i <= s3 - s2; i++) matrix[i] = register_param5( p, s0, s1, i, i, s4 ); } @@ -516,7 +516,7 @@ static void emit_dst( struct prog_dst_register *dst, dst->File = reg.file; dst->Index = reg.idx; /* allow zero as a shorthand for xyzw */ - dst->WriteMask = mask ? mask : WRITEMASK_XYZW; + dst->WriteMask = mask ? mask : WRITEMASK_XYZW; dst->CondMask = COND_TR; /* always pass cond test */ dst->CondSwizzle = SWIZZLE_NOOP; dst->CondSrc = 0; @@ -531,12 +531,12 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, { if (DISASSEM) { static const char *last_fn; - + if (fn != last_fn) { last_fn = fn; _mesa_printf("%s:\n", fn); } - + _mesa_printf("%d:\t", line); _mesa_print_instruction(inst); } @@ -555,7 +555,7 @@ static void emit_op3fn(struct tnl_program *p, { GLuint nr; struct prog_instruction *inst; - + assert((GLint) p->program->Base.NumInstructions <= p->max_inst); if (p->program->Base.NumInstructions == p->max_inst) { @@ -580,16 +580,16 @@ static void emit_op3fn(struct tnl_program *p, p->program->Base.Instructions = newInst; } - + nr = p->program->Base.NumInstructions++; inst = &p->program->Base.Instructions[nr]; - inst->Opcode = (enum prog_opcode) op; + inst->Opcode = (enum prog_opcode) op; inst->Data = 0; - + emit_arg( &inst->SrcReg[0], src0 ); emit_arg( &inst->SrcReg[1], src1 ); - emit_arg( &inst->SrcReg[2], src2 ); + emit_arg( &inst->SrcReg[2], src2 ); emit_dst( &inst->DstReg, dest, mask ); @@ -609,7 +609,7 @@ static void emit_op3fn(struct tnl_program *p, static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) { - if (reg.file == PROGRAM_TEMPORARY && + if (reg.file == PROGRAM_TEMPORARY && !(p->temp_reserved & (1<eye_position)) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); struct ureg modelview[4]; p->eye_position = reserve_temp(p); @@ -720,18 +720,18 @@ static struct ureg get_eye_position( struct tnl_program *p ) emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); } } - + return p->eye_position; } static struct ureg get_eye_position_z( struct tnl_program *p ) { - if (!is_undef(p->eye_position)) + if (!is_undef(p->eye_position)) return swizzle1(p->eye_position, Z); if (is_undef(p->eye_position_z)) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); struct ureg modelview[4]; p->eye_position_z = reserve_temp(p); @@ -741,10 +741,10 @@ static struct ureg get_eye_position_z( struct tnl_program *p ) emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]); } - + return p->eye_position_z; } - + static struct ureg get_eye_position_normalized( struct tnl_program *p ) { @@ -753,7 +753,7 @@ static struct ureg get_eye_position_normalized( struct tnl_program *p ) p->eye_position_normalized = reserve_temp(p); emit_normalize_vec3(p, p->eye_position_normalized, eye); } - + return p->eye_position_normalized; } @@ -767,7 +767,7 @@ static struct ureg get_transformed_normal( struct tnl_program *p ) { p->transformed_normal = register_input(p, VERT_ATTRIB_NORMAL ); } - else if (is_undef(p->transformed_normal)) + else if (is_undef(p->transformed_normal)) { struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); struct ureg mvinv[3]; @@ -798,7 +798,7 @@ static struct ureg get_transformed_normal( struct tnl_program *p ) emit_op2( p, OPCODE_MUL, transformed_normal, 0, normal, rescale ); normal = transformed_normal; } - + assert(normal.file == PROGRAM_TEMPORARY); p->transformed_normal = normal; } @@ -809,17 +809,17 @@ static struct ureg get_transformed_normal( struct tnl_program *p ) static void build_hpos( struct tnl_program *p ) { - struct ureg pos = register_input( p, VERT_ATTRIB_POS ); + struct ureg pos = register_input( p, VERT_ATTRIB_POS ); struct ureg hpos = register_output( p, VERT_RESULT_HPOS ); struct ureg mvp[4]; if (p->mvp_with_dp4) { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, 0, mvp ); emit_matrix_transform_vec4( p, hpos, mvp, pos ); } else { - register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, + register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, STATE_MATRIX_TRANSPOSE, mvp ); emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); } @@ -849,7 +849,7 @@ static void set_material_flags( struct tnl_program *p ) } -static struct ureg get_material( struct tnl_program *p, GLuint side, +static struct ureg get_material( struct tnl_program *p, GLuint side, GLuint property ) { GLuint attrib = material_attrib(side, property); @@ -890,7 +890,7 @@ static struct ureg get_scenecolor( struct tnl_program *p, GLuint side ) struct ureg material_ambient = get_material(p, side, STATE_AMBIENT); struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE); struct ureg tmp = make_temp(p, material_diffuse); - emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, + emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, material_ambient, material_emission); return tmp; } @@ -899,12 +899,12 @@ static struct ureg get_scenecolor( struct tnl_program *p, GLuint side ) } -static struct ureg get_lightprod( struct tnl_program *p, GLuint light, +static struct ureg get_lightprod( struct tnl_program *p, GLuint light, GLuint side, GLuint property ) { GLuint attrib = material_attrib(side, property); if (p->materials & (1<state->unit[i].light_attenuated) { /* 1/d,d,d,1/d */ - emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); + emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); /* 1,d,d*d,1/d */ - emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); + emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); /* 1/dist-atten */ - emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); + emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); if (!p->state->unit[i].light_spotcutoff_is_180) { /* dist-atten */ - emit_op1(p, OPCODE_RCP, dist, 0, dist); + emit_op1(p, OPCODE_RCP, dist, 0, dist); /* spot-atten * dist-atten */ - emit_op2(p, OPCODE_MUL, att, 0, dist, att); + emit_op2(p, OPCODE_MUL, att, 0, dist, att); } else { /* dist-atten */ - emit_op1(p, OPCODE_RCP, att, 0, dist); + emit_op1(p, OPCODE_RCP, att, 0, dist); } } return att; } - + /** * Compute: @@ -985,7 +985,7 @@ static void emit_degenerate_lit( struct tnl_program *p, /* MAX lit, id, dots; */ - emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots); + emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots); /* result[2] = (in > 0 ? 1 : 0) * SLT lit.z, id.z, dots; # lit.z = (0 < dots.z) ? 1 : 0 @@ -1018,10 +1018,10 @@ static void build_lighting( struct tnl_program *p ) * dots.w = front.shininess */ - for (i = 0; i < MAX_LIGHTS; i++) + for (i = 0; i < MAX_LIGHTS; i++) if (p->state->unit[i].light_enabled) nr_lights++; - + set_material_flags(p); { @@ -1044,7 +1044,7 @@ static void build_lighting( struct tnl_program *p ) * The negation will be un-done later in the back-face code below. */ struct ureg shininess = get_material(p, 1, STATE_SHININESS); - emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, + emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, negate(swizzle1(shininess,X))); release_temp(p, shininess); } @@ -1072,12 +1072,12 @@ static void build_lighting( struct tnl_program *p ) struct ureg res0 = register_output( p, VERT_RESULT_BFC0 ); emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); } - + if (twoside && separate) { struct ureg res1 = register_output( p, VERT_RESULT_BFC1 ); emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); } - + if (nr_lights == 0) { release_temps(p); return; @@ -1087,16 +1087,16 @@ static void build_lighting( struct tnl_program *p ) if (p->state->unit[i].light_enabled) { struct ureg half = undef; struct ureg att = undef, VPpli = undef; - + count++; if (p->state->unit[i].light_eyepos3_is_zero) { /* Can used precomputed constants in this case. * Attenuation never applies to infinite lights. */ - VPpli = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_POSITION_NORMALIZED, i); - + VPpli = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_POSITION_NORMALIZED, i); + if (!p->state->material_shininess_is_zero) { if (p->state->light_local_viewer) { struct ureg eye_hat = get_eye_position_normalized(p); @@ -1105,22 +1105,22 @@ static void build_lighting( struct tnl_program *p ) emit_normalize_vec3(p, half, half); } else { - half = register_param3(p, STATE_INTERNAL, + half = register_param3(p, STATE_INTERNAL, STATE_LIGHT_HALF_VECTOR, i); } } } else { - struct ureg Ppli = register_param3(p, STATE_INTERNAL, - STATE_LIGHT_POSITION, i); + struct ureg Ppli = register_param3(p, STATE_INTERNAL, + STATE_LIGHT_POSITION, i); struct ureg V = get_eye_position(p); struct ureg dist = get_temp(p); - VPpli = get_temp(p); - + VPpli = get_temp(p); + /* Calculate VPpli vector */ - emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); + emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); /* Normalize VPpli. The dist value also used in * attenuation below. @@ -1130,7 +1130,7 @@ static void build_lighting( struct tnl_program *p ) emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist); /* Calculate attenuation: - */ + */ if (!p->state->unit[i].light_spotcutoff_is_180 || p->state->unit[i].light_attenuated) { att = calculate_light_attenuation(p, i, VPpli, dist); @@ -1146,7 +1146,7 @@ static void build_lighting( struct tnl_program *p ) emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); } else { - struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); + struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir); } @@ -1215,7 +1215,7 @@ static void build_lighting( struct tnl_program *p ) emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0); emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1); - + release_temp(p, ambient); release_temp(p, diffuse); release_temp(p, specular); @@ -1229,7 +1229,7 @@ static void build_lighting( struct tnl_program *p ) struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR); struct ureg res0, res1; GLuint mask0, mask1; - + if (count == nr_lights) { if (separate) { mask0 = WRITEMASK_XYZ; @@ -1319,9 +1319,9 @@ static void build_reflect_texgen( struct tnl_program *p, struct ureg tmp = get_temp(p); /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); + emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); + emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); /* (-2n.u)n + u */ emit_op3(p, OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat); @@ -1350,22 +1350,22 @@ static void build_sphere_texgen( struct tnl_program *p, */ /* n.u */ - emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); + emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); /* 2n.u */ - emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); + emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); /* (-2n.u)n + u */ - emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); + emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); /* r + 0,0,1 */ - emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); + emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); /* rx^2 + ry^2 + (rz+1)^2 */ - emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); + emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); /* 2/m */ - emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); + emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); /* 1/m */ - emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); + emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); /* r/m + 1/2 */ - emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); - + emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); + release_temp(p, tmp); release_temp(p, r); release_temp(p, inv_m); @@ -1380,10 +1380,10 @@ static void build_texture_transform( struct tnl_program *p ) if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) continue; - - if (p->state->unit[i].texgen_enabled || + + if (p->state->unit[i].texgen_enabled || p->state->unit[i].texmat_enabled) { - + GLuint texmat_enabled = p->state->unit[i].texmat_enabled; struct ureg out = register_output(p, VERT_RESULT_TEX0 + i); struct ureg out_texgen = undef; @@ -1394,8 +1394,8 @@ static void build_texture_transform( struct tnl_program *p ) GLuint reflect_mask = 0; GLuint normal_mask = 0; GLuint modes[4]; - - if (texmat_enabled) + + if (texmat_enabled) out_texgen = get_temp(p); else out_texgen = out; @@ -1409,31 +1409,31 @@ static void build_texture_transform( struct tnl_program *p ) switch (modes[j]) { case TXG_OBJ_LINEAR: { struct ureg obj = register_input(p, VERT_ATTRIB_POS); - struct ureg plane = + struct ureg plane = register_param3(p, STATE_TEXGEN, i, STATE_TEXGEN_OBJECT_S + j); - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, + emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, obj, plane ); break; } case TXG_EYE_LINEAR: { struct ureg eye = get_eye_position(p); - struct ureg plane = - register_param3(p, STATE_TEXGEN, i, + struct ureg plane = + register_param3(p, STATE_TEXGEN, i, STATE_TEXGEN_EYE_S + j); - emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, + emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, eye, plane ); break; } - case TXG_SPHERE_MAP: + case TXG_SPHERE_MAP: sphere_mask |= WRITEMASK_X << j; break; case TXG_REFLECTION_MAP: reflect_mask |= WRITEMASK_X << j; break; - case TXG_NORMAL_MAP: + case TXG_NORMAL_MAP: normal_mask |= WRITEMASK_X << j; break; case TXG_NONE: @@ -1462,8 +1462,8 @@ static void build_texture_transform( struct tnl_program *p ) if (texmat_enabled) { struct ureg texmat[4]; - struct ureg in = (!is_undef(out_texgen) ? - out_texgen : + struct ureg in = (!is_undef(out_texgen) ? + out_texgen : register_input(p, VERT_ATTRIB_TEX0+i)); if (p->mvp_with_dp4) { register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, @@ -1596,7 +1596,7 @@ create_new_program( const struct state_key *key, p.identity = undef; p.temp_in_use = 0; p.mvp_with_dp4 = mvp_with_dp4; - + if (max_temps >= sizeof(int) * 8) p.temp_reserved = 0; else @@ -1639,14 +1639,14 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) */ prog = (struct gl_vertex_program *) _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)); - + if (!prog) { /* OK, we'll have to build a new one */ if (0) _mesa_printf("Build new TNL program\n"); - + prog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); if (!prog) return NULL; @@ -1656,7 +1656,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) #if 0 if (ctx->Driver.ProgramStringNotify) - ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, + ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB, &prog->Base ); #endif _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, -- cgit v1.2.3 From 7e91d035b9ef65adda39c8b164afa363477d7893 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 17:04:11 +0100 Subject: mesa/dlist: invalidate cached dlist compile state after CallList When compiling a display list containing a CallList, it is necessary to invalidate any assumption about the GL state after the recursive call completes. --- src/mesa/main/dlist.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 93b8a8f56d..3e8b5a9424 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -957,6 +957,20 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) } } +static void invalidate_saved_current_state( GLcontext *ctx ) +{ + GLint i; + + for (i = 0; i < VERT_ATTRIB_MAX; i++) + ctx->ListState.ActiveAttribSize[i] = 0; + + for (i = 0; i < MAT_ATTRIB_MAX; i++) + ctx->ListState.ActiveMaterialSize[i] = 0; + + memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); + + ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; +} void GLAPIENTRY _mesa_save_CallList(GLuint list) @@ -970,9 +984,10 @@ _mesa_save_CallList(GLuint list) n[1].ui = list; } - /* After this, we don't know what begin/end state we're in: + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: */ - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; + invalidate_saved_current_state( ctx ); if (ctx->ExecuteFlag) { _mesa_CallList(list); @@ -1015,9 +1030,10 @@ _mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists) } } - /* After this, we don't know what begin/end state we're in: + /* After this, we don't know what state we're in. Invalidate all + * cached information previously gathered: */ - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; + invalidate_saved_current_state( ctx ); if (ctx->ExecuteFlag) { CALL_CallLists(ctx->Exec, (n, type, lists)); @@ -6795,7 +6811,6 @@ void GLAPIENTRY _mesa_NewList(GLuint name, GLenum mode) { GET_CURRENT_CONTEXT(ctx); - GLint i; FLUSH_CURRENT(ctx, 0); /* must be called before assert */ ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -6823,22 +6838,15 @@ _mesa_NewList(GLuint name, GLenum mode) ctx->CompileFlag = GL_TRUE; ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); + /* Reset acumulated list state: + */ + invalidate_saved_current_state( ctx ); + /* Allocate new display list */ ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE); ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head; ctx->ListState.CurrentPos = 0; - /* Reset acumulated list state: - */ - for (i = 0; i < VERT_ATTRIB_MAX; i++) - ctx->ListState.ActiveAttribSize[i] = 0; - - for (i = 0; i < MAT_ATTRIB_MAX; i++) - ctx->ListState.ActiveMaterialSize[i] = 0; - - memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current); - - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; ctx->Driver.NewList(ctx, name, mode); ctx->CurrentDispatch = ctx->Save; -- cgit v1.2.3 From d6c2347d79c50ac18eab96378d79d989f3ffd0b7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 17:10:56 +0100 Subject: mesa/dlist: don't cache state which may not be replayed on CallList Statechanges which occur before the first End in a display list may not be replayed when the list is called, in particular if it is called from within a begin/end pair. Recognize vulnerable statechanges and do not use them to fill in the state cache. --- src/mesa/main/dlist.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 3e8b5a9424..2af0dd3c59 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -3203,7 +3203,11 @@ save_ShadeModel(GLenum mode) return; SAVE_FLUSH_VERTICES(ctx); - ctx->ListState.Current.ShadeModel = mode; + + /* Only save the value if we know the statechange will take effect: + */ + if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) + ctx->ListState.Current.ShadeModel = mode; n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1); if (n) { -- cgit v1.2.3 From 70ae7ba818e9d8a5485653b258e76f06c988654c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 18:40:20 +0100 Subject: mesa/dlist: fixes and improvements for material caching Only short-circuit material call if *all* statechanges from this call are cached. Some material calls (eg with FRONT_AND_BACK) change more than one piece of state -- need to check all of them before returning. Also, Material calls are legal inside begin/end pairs, so don't need to be as careful about begin/end state as with regular statechanges (like ShadeModel) when caching. Take advantage of this and do better caching. --- src/mesa/main/dlist.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 2af0dd3c59..c5a1c1f38f 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -5225,20 +5225,28 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param) bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL); - /* Try to eliminate redundant statechanges + /* Try to eliminate redundant statechanges. Because it is legal to + * call glMaterial even inside begin/end calls, don't need to worry + * about ctx->Driver.CurrentSavePrimitive here. */ for (i = 0; i < MAT_ATTRIB_MAX; i++) { if (bitmask & (1 << i)) { - if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END && - ctx->ListState.ActiveMaterialSize[i] == args && - compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) - return; - - ctx->ListState.ActiveMaterialSize[i] = args; - COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + if (ctx->ListState.ActiveMaterialSize[i] == args && + compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) { + bitmask &= ~(1 << i); + } + else { + ctx->ListState.ActiveMaterialSize[i] = args; + COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param); + } } } + /* If this call has effect, return early: + */ + if (bitmask == 0) + return; + SAVE_FLUSH_VERTICES(ctx); n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6); -- cgit v1.2.3 From 1fa4cde757cc94c0afa40d855309911247974e98 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 30 Jun 2009 19:52:44 +0100 Subject: mesa/vbo: fix compile and replay of nodes ending in a FALLBACK Where vbo save nodes are terminated with a call to DO_FALLBACK(), as in the case of a recursive CallList which is itself within a Begin/End pair, there two problems: 1) The display list node's primitive information was incorrect, stating the cut-off prim had zero vertices 2) On replay, we would get confused by a primitive that started in a node, but was terminated by individual opcodes. This change fixes the first problem by correctly terminating the last primitive on fallback, and the second by forcing the display list to use the Loopback path, converting all nodes into immediate-mode rendering. The loopback fix is a performance hit, but avoiding this would require a fairly large rework of this code. --- progs/trivial/Makefile | 1 + progs/trivial/dlist-begin-call-end.c | 159 +++++++++++++++++++++++++++++++++++ src/mesa/vbo/vbo_save_api.c | 40 ++++++--- 3 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 progs/trivial/dlist-begin-call-end.c (limited to 'src/mesa') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index bef1a57cd2..3bd8faff99 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -24,6 +24,7 @@ SOURCES = \ dlist-tri-flat-tri.c \ dlist-tri-mat-tri.c \ dlist-recursive-call.c \ + dlist-begin-call-end.c \ dlist-edgeflag-dangling.c \ dlist-edgeflag.c \ dlist-degenerate.c \ diff --git a/progs/trivial/dlist-begin-call-end.c b/progs/trivial/dlist-begin-call-end.c new file mode 100644 index 0000000000..0d0aed7c72 --- /dev/null +++ b/progs/trivial/dlist-begin-call-end.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; +GLint first_list, list; + +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); + + glClearColor(0.0, 0.0, 1.0, 0.0); + + /* First list will disrupt state which might potentially be + * short-circuited in calling list: + */ + first_list = glGenLists(1); + glNewList(first_list, GL_COMPILE); +// glColor3f(0,1,0); + glEndList(); + + + /* List that looks like it might have redundant state: + */ + list = glGenLists(1); + glNewList(list, GL_COMPILE); + + glShadeModel(GL_FLAT); + glBegin(GL_TRIANGLES); + glColor3f(1,0,0); + glVertex3f( -0.9, 0.9, -30.0); + glVertex3f( -0.9, -0.9, -30.0); + glCallList( first_list ); + glVertex3f( 0.9, 0.0, -30.0); + glEnd(); + glEndList(); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)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: + return; + } + + glutPostRedisplay(); +} + + + + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glShadeModel( GL_SMOOTH ); + glCallList(list); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 971a338af4..85cb79c71c 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -667,19 +667,33 @@ do { \ * -- Flush current buffer * -- Fallback to opcodes for the rest of the begin/end object. */ -#define DO_FALLBACK(ctx) \ -do { \ - struct vbo_save_context *save = &vbo_context(ctx)->save; \ - \ - if (save->vert_count || save->prim_count) \ - _save_compile_vertex_list( ctx ); \ - \ - _save_copy_to_current( ctx ); \ - _save_reset_vertex( ctx ); \ - _save_reset_counters( ctx ); \ - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \ - ctx->Driver.SaveNeedFlush = 0; \ -} while (0) +static void DO_FALLBACK( GLcontext *ctx ) +{ + struct vbo_save_context *save = &vbo_context(ctx)->save; + + if (save->vert_count || save->prim_count) { + GLint i = save->prim_count - 1; + + /* Close off in-progress primitive. + */ + save->prim[i].count = (save->vert_count - + save->prim[i].start); + + /* Need to replay this display list with loopback, + * unfortunately, otherwise this primitive won't be handled + * properly: + */ + save->dangling_attr_ref = 1; + + _save_compile_vertex_list( ctx ); + } + + _save_copy_to_current( ctx ); + _save_reset_vertex( ctx ); + _save_reset_counters( ctx ); + _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); + ctx->Driver.SaveNeedFlush = 0; +} static void GLAPIENTRY _save_EvalCoord1f( GLfloat u ) { -- cgit v1.2.3 From b3e8e1cd4c1584f735e35914861ae2e8ae5b6b2b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Jul 2009 11:28:56 +0100 Subject: mesa: ensure UsesFogFragCoord value is set for non-glsl shaders With recent changes to support frontfacing in glsl, it is necessary to ensure that the UsesFogFragCoord value is accurate in all shaders. We were previously not setting it for fixed-function and ARB_fs shaders. --- src/mesa/shader/arbprogparse.c | 7 +++++++ src/mesa/shader/programopt.c | 1 + 2 files changed, 8 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index bb4c5b38d4..f5053d3289 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -3922,6 +3922,13 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, if (program->FogOption) program->Base.InputsRead |= FRAG_BIT_FOGC; + + /* XXX: assume that ARB fragment programs don't have access to the + * FrontFacing and PointCoord values stuffed into the fog + * coordinate in GLSL shaders. + */ + if (program->Base.InputsRead & FRAG_BIT_FOGC) + program->UsesFogFragCoord = TRUE; if (program->Base.Instructions) _mesa_free(program->Base.Instructions); diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index f70c75cec8..ac5fe0f691 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -396,6 +396,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) fprog->Base.Instructions = newInst; fprog->Base.NumInstructions = inst - newInst; fprog->Base.InputsRead |= FRAG_BIT_FOGC; + fprog->UsesFogFragCoord = GL_TRUE; /* XXX do this? fprog->FogOption = GL_NONE; */ } -- cgit v1.2.3 From 798cd2a98d66a1b841930e121676ae1a8f9fb244 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Jul 2009 13:28:20 +0100 Subject: glapi: ensure _mesa_lookup_prim_by_nr() is not clobbered on regeneration Propogate changes to enums.c back up to the python source. --- src/mesa/glapi/gl_enums.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/glapi/gl_enums.py b/src/mesa/glapi/gl_enums.py index b32e012663..27ab119537 100644 --- a/src/mesa/glapi/gl_enums.py +++ b/src/mesa/glapi/gl_enums.py @@ -110,6 +110,29 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } } +/* Get the name of an enum given that it is a primitive type. Avoids + * GL_FALSE/GL_POINTS ambiguity and others. + */ +const char *_mesa_lookup_prim_by_nr( int nr ) +{ + switch (nr) { + case GL_POINTS: return "GL_POINTS"; + case GL_LINES: return "GL_LINES"; + case GL_LINE_STRIP: return "GL_LINE_STRIP"; + case GL_LINE_LOOP: return "GL_LINE_LOOP"; + case GL_TRIANGLES: return "GL_TRIANGLES"; + case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP"; + case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN"; + case GL_QUADS: return "GL_QUADS"; + case GL_QUAD_STRIP: return "GL_QUAD_STRIP"; + case GL_POLYGON: return "GL_POLYGON"; + case GL_POLYGON+1: return "OUTSIDE_BEGIN_END"; + default: return ""; + } +} + + + int _mesa_lookup_enum_by_name( const char *symbol ) { enum_elt * f = NULL; -- cgit v1.2.3 From 588c8625714c744047dd1d710d87b1dfcec48db7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Jul 2009 14:43:16 +0100 Subject: mesa: s/TRUE/GL_TRUE Fix compile breakage on Linux. --- src/mesa/shader/arbprogparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index f5053d3289..0d4f13c970 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -3928,7 +3928,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, * coordinate in GLSL shaders. */ if (program->Base.InputsRead & FRAG_BIT_FOGC) - program->UsesFogFragCoord = TRUE; + program->UsesFogFragCoord = GL_TRUE; if (program->Base.Instructions) _mesa_free(program->Base.Instructions); -- cgit v1.2.3 From 2a2236606fd6ae473a2f4db6ef6d3d5030261316 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 2 Jul 2009 17:24:25 +0100 Subject: mesa: Assume depth textures have a single level unless told otherwise. --- src/mesa/state_tracker/st_cb_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index a2211ce302..0a72784ce0 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -335,7 +335,9 @@ guess_and_alloc_texture(struct st_context *st, * pagetable arrangements. */ if ((stObj->base.MinFilter == GL_NEAREST || - stObj->base.MinFilter == GL_LINEAR) && + stObj->base.MinFilter == GL_LINEAR || + stImage->base._BaseFormat == GL_DEPTH_COMPONENT || + stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) && stImage->level == firstLevel) { lastLevel = firstLevel; } -- cgit v1.2.3 From b928d18398330d862ab162f687e224b93932824c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 3 Jul 2009 14:26:26 +0100 Subject: mesa/shaders: fix gl_NormalMatrix state parameters gl_NormalMatrix is the inverse transpose of the modelview matrix, but as every matrix here needs to be transposed, we end up with {MODELVIEW_MATRIX, INVERSE}. --- 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 83e76b77db..154609c26e 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -85,7 +85,7 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field, { "gl_TextureMatrixTranspose", STATE_TEXTURE_MATRIX, 0 }, { "gl_TextureMatrixInverseTranspose", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE }, - { "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE }, + { "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE }, { NULL, 0, 0 } }; -- cgit v1.2.3 From 94e1117c9ba259665cd8e790369dcd4c789a2f93 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 3 Jul 2009 17:50:15 +0200 Subject: intel: Also update stencil bits in intel_update_wrapper(). Fixes assertion failure when binding depth/stencil texture to FBO stencil attachment. --- src/mesa/drivers/dri/intel/intel_fbo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 52647ddf8b..30f58b1f44 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -515,6 +515,7 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb, irb->Base.BlueBits = texImage->TexFormat->BlueBits; irb->Base.AlphaBits = texImage->TexFormat->AlphaBits; irb->Base.DepthBits = texImage->TexFormat->DepthBits; + irb->Base.StencilBits = texImage->TexFormat->StencilBits; irb->Base.Delete = intel_delete_renderbuffer; irb->Base.AllocStorage = intel_nop_alloc_storage; -- cgit v1.2.3