diff options
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r-- | src/mesa/main/texstate.c | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index bcedcafe19e..bed2c1220a0 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 6.5.3 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -41,8 +41,6 @@ #include "texenvprogram.h" #include "mtypes.h" #include "math/m_xform.h" -#include "shaderobjects.h" - #define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) @@ -2919,11 +2917,18 @@ static void update_texture_state( GLcontext *ctx ) { GLuint unit; + struct gl_fragment_program *fprog; -#if FEATURE_ARB_fragment_shader - struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram; - GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS]; -#endif + if (ctx->Shader.CurrentProgram && + ctx->Shader.CurrentProgram->LinkStatus) { + fprog = ctx->Shader.CurrentProgram->FragmentProgram; + } + else if (ctx->FragmentProgram._Enabled) { + fprog = ctx->FragmentProgram.Current; + } + else { + fprog = NULL; + } ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are * actual changes. @@ -2934,17 +2939,6 @@ update_texture_state( GLcontext *ctx ) ctx->Texture._TexMatEnabled = 0; ctx->Texture._TexGenEnabled = 0; -#if FEATURE_ARB_fragment_shader - /* - * Grab texture image usage state from shader program. It must be - * grabbed every time uniform sampler changes, so maybe there is a - * better place to perform these rather expensive computations. - */ - if (ctx->ShaderObjects._FragmentShaderPresent) { - (**prog).GetTextureImageUsage (prog, progteximageusage); - } -#endif /* FEATURE_ARB_fragment_shader */ - /* * Update texture unit state. */ @@ -2956,15 +2950,14 @@ update_texture_state( GLcontext *ctx ) texUnit->_ReallyEnabled = 0; texUnit->_GenFlags = 0; - /* Get the bitmask of texture enables */ -#if FEATURE_ARB_fragment_shader - if (ctx->ShaderObjects._FragmentShaderPresent) { - enableBits = progteximageusage[unit]; - } - else -#endif - if (ctx->FragmentProgram._Enabled) { - enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit]; + /* Get the bitmask of texture enables. + * enableBits will be a mask of the TEXTURE_*_BIT flags indicating + * which texture targets are enabled (fixed function) or referenced + * by a fragment shader/program. When multiple flags are set, we'll + * settle on the one with highest priority (see texture_override below). + */ + if (fprog) { + enableBits = fprog->Base.TexturesUsed[unit]; } else { if (!texUnit->Enabled) @@ -3081,21 +3074,23 @@ update_texture_state( GLcontext *ctx ) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); } - ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits; - /* Fragment programs may need texture coordinates but not the - * corresponding texture images. - */ - if (ctx->ShaderObjects.CurrentProgram != NULL) { - ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1; + /* Determine which texture coordinate sets are actually needed */ + if (fprog) { + const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; + ctx->Texture._EnabledCoordUnits + = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; } - else if (ctx->FragmentProgram._Enabled) { - ctx->Texture._EnabledCoordUnits |= - (ctx->FragmentProgram.Current->Base.InputsRead >> FRAG_ATTRIB_TEX0); + else { + ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits; } } -void _mesa_update_texture( GLcontext *ctx, GLuint new_state ) +/** + * Update texture-related derived state. + */ +void +_mesa_update_texture( GLcontext *ctx, GLuint new_state ) { if (new_state & _NEW_TEXTURE_MATRIX) update_texture_matrices( ctx ); |