[Mesa-dev] [PATCH 1/2] mesa: add active_texture() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu May 25 09:44:00 UTC 2017



On 05/25/2017 11:42 AM, Timothy Arceri wrote:
> On 23/05/17 20:41, Samuel Pitoiset wrote:
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>>   src/mesa/main/texstate.c | 24 ++++++++++++++----------
>>   1 file changed, 14 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
>> index 1aac3cdbd8b..32d5c0b7f7c 100644
>> --- a/src/mesa/main/texstate.c
>> +++ b/src/mesa/main/texstate.c
>> @@ -279,6 +279,19 @@ calculate_derived_texenv( struct 
>> gl_tex_env_combine_state *state,
>>   }
>> +static void active_texture(struct gl_context *ctx, const GLuint texUnit)
>> +{
>> +   if (ctx->Texture.CurrentUnit == texUnit)
>> +      return;
>> +
>> +   FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
>> +
>> +   ctx->Texture.CurrentUnit = texUnit;
>> +   if (ctx->Transform.MatrixMode == GL_TEXTURE) {
>> +      /* update current stack pointer */
>> +      ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
>> +   }
>> +}
>>   /* GL_ARB_multitexture */
>> @@ -293,9 +306,6 @@ _mesa_ActiveTexture(GLenum texture)
>>         _mesa_debug(ctx, "glActiveTexture %s\n",
>>                     _mesa_enum_to_string(texture));
>> -   if (ctx->Texture.CurrentUnit == texUnit)
>> -      return;
> 
> Its not a big deal but it would be nice if we could leave this where it is.
> 
> Since _mesa_ActiveTexture is small maybe we could just move the entire 
> thing to a helper and use the ALWAYS_INLINE pattern used elsewhere. 
> Thoughts?

Looks good to me.

> 
>> -
>>      k = _mesa_max_tex_unit(ctx);
>>      assert(k <= ARRAY_SIZE(ctx->Texture.Unit));
>> @@ -306,13 +316,7 @@ _mesa_ActiveTexture(GLenum texture)
>>         return;
>>      }
>> -   FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
>> -
>> -   ctx->Texture.CurrentUnit = texUnit;
>> -   if (ctx->Transform.MatrixMode == GL_TEXTURE) {
>> -      /* update current stack pointer */
>> -      ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
>> -   }
>> +   active_texture(ctx, texUnit);
>>   }
>>


More information about the mesa-dev mailing list