X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_context.c;h=ce37dc04282e12c78e50d94052ffefd96085b71e;hb=205e0e3e38b99c2fb0298755d99a38f111f0b96f;hp=f665485f422a77bf2ae5274f344eef41944d0ec4;hpb=23d31efc167f09d47635352f697ffcb087d3ebbd;p=mesa.git diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index f665485f422..ce37dc04282 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.2 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-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"), @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "mtypes.h" -#include "light.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/light.h" #include "tnl.h" #include "t_context.h" @@ -61,7 +61,6 @@ _tnl_CreateContext( GLcontext *ctx ) /* Initialize tnl state. */ if (ctx->VertexProgram._MaintainTnlProgram) { - _tnl_ProgramCacheInit( ctx ); _tnl_install_pipeline( ctx, _tnl_vp_pipeline ); } else { _tnl_install_pipeline( ctx, _tnl_default_pipeline ); @@ -79,6 +78,9 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->nr_blocks = 0; + /* plug in the VBO drawing function */ + vbo_set_draw_func(ctx, _tnl_draw_prims); + return GL_TRUE; } @@ -90,9 +92,6 @@ _tnl_DestroyContext( GLcontext *ctx ) _tnl_destroy_pipeline( ctx ); - if (ctx->VertexProgram._MaintainTnlProgram) - _tnl_ProgramCacheDestroy( ctx ); - FREE(tnl); ctx->swtnl_context = NULL; } @@ -102,11 +101,13 @@ void _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) { TNLcontext *tnl = TNL_CONTEXT(ctx); + const struct gl_vertex_program *vp = ctx->VertexProgram._Current; + const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; - if (new_state & (_NEW_HINT)) { + if (new_state & (_NEW_HINT | _NEW_PROGRAM)) { ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); - tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog; + tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) + || !tnl->AllowPixelFog) && !fp; } tnl->pipeline.new_state |= new_state; @@ -118,7 +119,9 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) RENDERINPUTS_ZERO( tnl->render_inputs_bitset ); RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS ); - RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); + if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) { + RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); + } for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (ctx->Texture._EnabledCoordUnits & (1 << i)) { RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) ); @@ -133,11 +136,19 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR_INDEX ); } - if (ctx->Fog.Enabled || - (ctx->FragmentProgram._Current && - (ctx->FragmentProgram._Current->FogOption != GL_NONE || - ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC))) + if (ctx->Fog.Enabled) { + /* fixed-function fog */ RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); + } + else if (ctx->FragmentProgram._Active || ctx->FragmentProgram._Current) { + struct gl_fragment_program *fp = ctx->FragmentProgram._Current; + if (fp) { + if (fp->FogOption != GL_NONE || (fp->Base.InputsRead & FRAG_BIT_FOGC)) { + /* fragment program needs fog coord */ + RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG ); + } + } + } if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) @@ -151,15 +162,12 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE ); /* check for varying vars which are written by the vertex program */ - { - struct gl_vertex_program *vp = ctx->VertexProgram._Current; - if (vp) { - GLuint i; - for (i = 0; i < MAX_VARYING; i++) { - if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { - RENDERINPUTS_SET(tnl->render_inputs_bitset, - _TNL_ATTRIB_GENERIC(i)); - } + if (vp) { + GLuint i; + for (i = 0; i < MAX_VARYING; i++) { + if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + RENDERINPUTS_SET(tnl->render_inputs_bitset, + _TNL_ATTRIB_GENERIC(i)); } } } @@ -201,8 +209,8 @@ _tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value ) { TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->AllowVertexFog = value; - tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog; + tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) + || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; } @@ -211,7 +219,7 @@ _tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value ) { TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->AllowPixelFog = value; - tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog; + tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) + || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; }