mesa: avoid setting texObj->_Complete = GL_FALSE when there's no state change

Avoid a little bit of unneeded state validation and fixes a bug where the
texture complete flags was set to false, but we didn't signal _NEW_TEXTURE.

Fixes piglit tex1d-2dborder failure.
(cherry picked from commit aad3f546a0)
This commit is contained in:
Brian Paul 2009-02-09 13:58:32 -07:00 committed by Ian Romanick
parent 6ada1d47d9
commit 7122490982

View file

@ -3,7 +3,7 @@
* Version: 7.5
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. 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"),
@ -125,6 +125,20 @@ get_texobj(GLcontext *ctx, GLenum target)
}
/**
* This is called just prior to changing any texture object state.
* Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
* state flag and then mark the texture object as 'incomplete' so that any
* per-texture derived state gets recomputed.
*/
static INLINE void
flush(GLcontext *ctx, struct gl_texture_object *texObj)
{
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->_Complete = GL_FALSE;
}
/** Set an integer-valued texture parameter */
static void
set_tex_parameteri(GLcontext *ctx,
@ -138,7 +152,7 @@ set_tex_parameteri(GLcontext *ctx,
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MinFilter = params[0];
return;
case GL_NEAREST_MIPMAP_NEAREST:
@ -146,7 +160,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MinFilter = params[0];
return;
}
@ -162,7 +176,7 @@ set_tex_parameteri(GLcontext *ctx,
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MagFilter = params[0];
return;
default:
@ -174,7 +188,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapS == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->WrapS = params[0];
}
return;
@ -183,7 +197,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapT == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->WrapT = params[0];
}
return;
@ -192,7 +206,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapR == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->WrapR = params[0];
}
return;
@ -205,7 +219,7 @@ set_tex_parameteri(GLcontext *ctx,
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
return;
}
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->BaseLevel = params[0];
return;
@ -216,7 +230,7 @@ set_tex_parameteri(GLcontext *ctx,
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(param)");
return;
}
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MaxLevel = params[0];
return;
@ -247,7 +261,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->Extensions.SGIS_generate_mipmap) {
if (texObj->GenerateMipmap != params[0]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
}
}
@ -262,7 +276,7 @@ set_tex_parameteri(GLcontext *ctx,
(params[0] == GL_NONE ||
params[0] == GL_COMPARE_R_TO_TEXTURE_ARB)) {
if (texObj->CompareMode != params[0]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->CompareMode = params[0];
}
}
@ -279,7 +293,7 @@ set_tex_parameteri(GLcontext *ctx,
switch (params[0]) {
case GL_LEQUAL:
case GL_GEQUAL:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->CompareFunc = params[0];
return;
case GL_EQUAL:
@ -289,7 +303,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_ALWAYS:
case GL_NEVER:
if (ctx->Extensions.EXT_shadow_funcs) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->CompareFunc = params[0];
return;
}
@ -310,7 +324,7 @@ set_tex_parameteri(GLcontext *ctx,
params[0] == GL_INTENSITY ||
params[0] == GL_ALPHA)) {
if (texObj->DepthMode != params[0]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->DepthMode = params[0];
}
}
@ -345,19 +359,19 @@ set_tex_parameterf(GLcontext *ctx,
case GL_TEXTURE_MIN_LOD:
if (texObj->MinLod == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MinLod = params[0];
return;
case GL_TEXTURE_MAX_LOD:
if (texObj->MaxLod == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->MaxLod = params[0];
return;
case GL_TEXTURE_PRIORITY:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->Priority = CLAMP(params[0], 0.0F, 1.0F);
return;
@ -369,7 +383,7 @@ set_tex_parameterf(GLcontext *ctx,
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return;
}
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
/* clamp to max, that's what NVIDIA does */
texObj->MaxAnisotropy = MIN2(params[0],
ctx->Const.MaxTextureMaxAnisotropy);
@ -382,9 +396,9 @@ set_tex_parameterf(GLcontext *ctx,
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
if (ctx->Extensions.SGIX_shadow_ambient) {
if (texObj->CompareFailValue != params[0]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F);
if (texObj->ShadowAmbient != params[0]) {
flush(ctx, texObj);
texObj->ShadowAmbient = CLAMP(params[0], 0.0F, 1.0F);
}
}
else {
@ -397,14 +411,14 @@ set_tex_parameterf(GLcontext *ctx,
/* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
if (ctx->Extensions.EXT_texture_lod_bias) {
if (texObj->LodBias != params[0]) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->LodBias = params[0];
}
}
break;
case GL_TEXTURE_BORDER_COLOR:
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
flush(ctx, texObj);
texObj->BorderColor[RCOMP] = params[0];
texObj->BorderColor[GCOMP] = params[1];
texObj->BorderColor[BCOMP] = params[2];
@ -457,8 +471,6 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
set_tex_parameterf(ctx, texObj, pname, &param);
}
texObj->_Complete = GL_FALSE;
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
ctx->Driver.TexParameter(ctx, target, texObj, pname, &param);
}
@ -516,8 +528,6 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
set_tex_parameterf(ctx, texObj, pname, params);
}
texObj->_Complete = GL_FALSE;
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
ctx->Driver.TexParameter(ctx, target, texObj, pname, params);
}
@ -553,8 +563,6 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
set_tex_parameteri(ctx, texObj, pname, &param);
}
texObj->_Complete = GL_FALSE;
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
GLfloat fparam = (GLfloat) param;
ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam);
@ -602,8 +610,6 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
set_tex_parameteri(ctx, texObj, pname, params);
}
texObj->_Complete = GL_FALSE;
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
GLfloat fparams[4];
fparams[0] = INT_TO_FLOAT(params[0]);