From: Brian Date: Thu, 22 Feb 2007 15:53:33 +0000 (-0700) Subject: Merge branch 'origin' into glsl-compiler-1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=29c471aafc6a3fef23d553e31a555d1782854a77;p=mesa.git Merge branch 'origin' into glsl-compiler-1 Conflicts: src/mesa/main/state.c src/mesa/shader/program.c src/mesa/shader/program.h src/mesa/shader/programopt.c src/mesa/shader/slang/slang_execute.c src/mesa/sources src/mesa/swrast/s_arbshader.c src/mesa/swrast/s_context.c src/mesa/swrast/s_span.c src/mesa/swrast/s_zoom.c src/mesa/tnl/t_context.c src/mesa/tnl/t_save_api.c src/mesa/tnl/t_vb_arbprogram.c src/mesa/tnl/t_vp_build.c src/mesa/tnl/t_vtx_eval.c --- 29c471aafc6a3fef23d553e31a555d1782854a77 diff --cc src/mesa/main/imports.c index 9c7ebf9287d,890d1a4e32e..e2d44fa07c4 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@@ -913,33 -846,21 +846,29 @@@ _mesa_strcmp( const char *s1, const cha int _mesa_strncmp( const char *s1, const char *s2, size_t n ) { - #if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strncmp(s1, s2, n); - #else return strncmp(s1, s2, n); - #endif } -/** Implemented using _mesa_malloc() and _mesa_strcpy */ +/** + * Implemented using _mesa_malloc() and _mesa_strcpy. + * Note that NULL is handled accordingly. + */ char * _mesa_strdup( const char *s ) { - size_t l = _mesa_strlen(s); - char *s2 = (char *) _mesa_malloc(l + 1); - if (s2) - _mesa_strcpy(s2, s); - return s2; + if (s) { + size_t l = _mesa_strlen(s); + char *s2 = (char *) _mesa_malloc(l + 1); + if (s2) + _mesa_strcpy(s2, s); + return s2; + } + else { + return NULL; + } } - /** Wrapper around either atoi() or xf86atoi() */ + /** Wrapper around atoi() */ int _mesa_atoi(const char *s) { diff --cc src/mesa/main/state.c index 947d3136d5b,f4f73a5089f..6ed7ae6c7dd --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@@ -1045,7 -1003,79 +1035,80 @@@ update_color(GLcontext *ctx } + + /** + * Update the ctx->_TriangleCaps bitfield. + * XXX that bitfield should really go away someday! + * This function must be called after other update_*() functions since + * there are dependencies on some other derived values. + */ + static void + update_tricaps(GLcontext *ctx, GLbitfield new_state) + { + ctx->_TriangleCaps = 0; + + /* + * Points + */ + if (new_state & _NEW_POINT) { + if (ctx->Point.SmoothFlag) + ctx->_TriangleCaps |= DD_POINT_SMOOTH; + if (ctx->Point._Size != 1.0F) + ctx->_TriangleCaps |= DD_POINT_SIZE; + if (ctx->Point._Attenuated) + ctx->_TriangleCaps |= DD_POINT_ATTEN; + } + + /* + * Lines + */ + if (new_state & _NEW_LINE) { + if (ctx->Line.SmoothFlag) + ctx->_TriangleCaps |= DD_LINE_SMOOTH; + if (ctx->Line.StippleFlag) + ctx->_TriangleCaps |= DD_LINE_STIPPLE; + if (ctx->Line._Width != 1.0) + ctx->_TriangleCaps |= DD_LINE_WIDTH; + } + + /* + * Polygons + */ + if (new_state & _NEW_POLYGON) { + if (ctx->Polygon.SmoothFlag) + ctx->_TriangleCaps |= DD_TRI_SMOOTH; + if (ctx->Polygon.StippleFlag) + ctx->_TriangleCaps |= DD_TRI_STIPPLE; + if (ctx->Polygon.FrontMode != GL_FILL + || ctx->Polygon.BackMode != GL_FILL) + ctx->_TriangleCaps |= DD_TRI_UNFILLED; + if (ctx->Polygon.CullFlag + && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) + ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) + ctx->_TriangleCaps |= DD_TRI_OFFSET; + } + + /* + * Lighting and shading + */ + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; + if (ctx->Light.ShadeModel == GL_FLAT) + ctx->_TriangleCaps |= DD_FLATSHADE; + if (NEED_SECONDARY_COLOR(ctx)) + ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; + + /* + * Stencil + */ + if (ctx->Stencil._TestTwoSide) + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; + } + + /** * Compute derived GL state. * If __GLcontextRec::NewState is non-zero then this function \b must @@@ -1108,7 -1129,11 +1162,11 @@@ _mesa_update_state_locked( GLcontext *c if (new_state & _NEW_COLOR) update_color( ctx ); + if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT + | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) + update_tricaps( ctx, new_state ); + - if (ctx->_MaintainTexEnvProgram) { + if (ctx->FragmentProgram._MaintainTexEnvProgram) { if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG)) _mesa_UpdateTexEnvProgram(ctx); } diff --cc src/mesa/shader/programopt.c index ca11a4e547c,dca44c853d8..05a05cd3697 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@@ -125,19 -126,15 +125,15 @@@ _mesa_insert_mvp_code(GLcontext *ctx, s void _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog) { - static const GLint fogParamsState[] - = { STATE_FOG, STATE_FOG_PARAMS, 0, 0, 0 }; - static const GLint fogColorState[] - = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0 }; + static const GLint fogPStateOpt[] = { STATE_INTERNAL, + STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; - static const GLint fogColorState[] = { STATE_FOG_COLOR, 0, 0, 0, 0 }; ++ static const GLint fogColorState[] = { STATE_FOG, STATE_FOG_COLOR, 0, 0, 0}; struct prog_instruction *newInst, *inst; const GLuint origLen = fprog->Base.NumInstructions; - const GLuint newLen = origLen + 6; + const GLuint newLen = origLen + 5; GLuint i; - GLint fogParamsRef, fogColorRef; /* state references */ + GLint fogPRefOpt, fogColorRef; /* state references */ GLuint colorTemp, fogFactorTemp; /* temporary registerss */ - GLfloat fogVals[4]; - GLuint fogConsts; /* constant values for EXP, EXP2 mode */ - GLuint swizzle; if (fprog->FogOption == GL_NONE) { _mesa_problem(ctx, "_mesa_append_fog_code() called for fragment program" diff --cc src/mesa/sources index 55c282cad90,6d6d22861c0..a15c5c479fe --- a/src/mesa/sources +++ b/src/mesa/sources @@@ -119,15 -115,12 +115,11 @@@ SWRAST_SETUP_SOURCES = swrast_setup/ss_triangle.c TNL_SOURCES = \ - tnl/t_array_api.c \ - tnl/t_array_import.c \ tnl/t_context.c \ tnl/t_pipeline.c \ - tnl/t_save_api.c \ - tnl/t_save_loopback.c \ - tnl/t_save_playback.c \ + tnl/t_draw.c \ tnl/t_vb_arbprogram.c \ tnl/t_vb_arbprogram_sse.c \ - tnl/t_vb_arbshader.c\ tnl/t_vb_program.c \ tnl/t_vb_render.c \ tnl/t_vb_texgen.c \ diff --cc src/mesa/swrast/s_readpix.c index 75134ab4623,27f4736c396..a7b25a46339 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@@ -394,10 -396,11 +396,11 @@@ read_rgba_pixels( GLcontext *ctx /* no convolution */ const GLint dstStride = _mesa_image_row_stride(packing, width, format, type); - GLfloat (*rgba)[4] = swrast->SpanArrays->color.sz4.rgba; + GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0]; GLint row; - GLubyte *dst = _mesa_image_address2d(packing, pixels, width, height, - format, type, 0, 0); + GLubyte *dst + = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, + format, type, 0, 0); for (row = 0; row < height; row++, y++) { diff --cc src/mesa/tnl/t_context.c index 3887f18213a,d9458b74eca..3b2f91acbaf --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@@ -80,13 -58,9 +58,9 @@@ _tnl_CreateContext( GLcontext *ctx tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES; - /* Initialize tnl state and tnl->vtxfmt. + /* Initialize tnl state. */ - _tnl_save_init( ctx ); - _tnl_array_init( ctx ); - _tnl_vtx_init( ctx ); - - if (ctx->_MaintainTnlProgram) { + if (ctx->VertexProgram._MaintainTnlProgram) { _tnl_ProgramCacheInit( ctx ); _tnl_install_pipeline( ctx, _tnl_vp_pipeline ); } else { @@@ -130,13 -88,9 +88,9 @@@ _tnl_DestroyContext( GLcontext *ctx { TNLcontext *tnl = TNL_CONTEXT(ctx); - _tnl_array_destroy( ctx ); - _tnl_vtx_destroy( ctx ); - _tnl_save_destroy( ctx ); _tnl_destroy_pipeline( ctx ); - _ae_destroy_context( ctx ); - if (ctx->_MaintainTnlProgram) + if (ctx->VertexProgram._MaintainTnlProgram) _tnl_ProgramCacheDestroy( ctx ); FREE(tnl); diff --cc src/mesa/tnl/t_context.h index ea2a6bed546,a872f261775..733b3a5fe1a --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@@ -422,9 -217,9 +217,9 @@@ struct vertex_buffe GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */ GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */ GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */ - GLvector4f *VaryingPtr[MAX_VARYING_VECTORS]; + GLvector4f *VaryingPtr[MAX_VARYING]; - struct tnl_prim *Primitive; + const struct _mesa_prim *Primitive; GLuint PrimitiveCount; /* Inputs to the vertex program stage */ diff --cc src/mesa/tnl/t_vb_arbprogram.c index 0a443b3e017,4c8f967fdff..97ff4c7f102 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@@ -1096,18 -1056,8 +1096,18 @@@ static void compile_vertex_program( str { struct compilation cp; struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program); - GLuint i; + GLint i; +#if 1 + if (!program->IsNVProgram && program->IsPositionInvariant) { + printf("Adding MVP code\n"); + if (!program->Base.Parameters) + program->Base.Parameters = _mesa_new_parameter_list(); + _mesa_insert_mvp_code(NULL, program); + program->IsPositionInvariant = 0; + } +#endif + if (program->TnlData) free_tnl_data( program ); @@@ -1325,7 -1279,7 +1323,13 @@@ run_arb_vertex_program(GLcontext *ctx, case 2: m->File[0][idx][1] = m->input[j].data[1]; case 1: m->File[0][idx][0] = m->input[j].data[0]; } -- ++#if 0 ++ printf(" attr %d/%d: %g %g %g %g\n", j, idx-REG_IN0, ++ m->input[j].data[0], ++ m->input[j].data[1], ++ m->input[j].data[2], ++ m->input[j].data[3]); ++#endif STRIDE_F(m->input[j].data, m->input[j].stride); }