From d68150f15d41756fa7153cd6b597ff52ec85a933 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 23 Mar 2017 22:42:56 +0100 Subject: [PATCH] mesa: split _NEW_TEXTURE into _NEW_TEXTURE_OBJECT & _NEW_TEXTURE_STATE MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit No performance testing has been done, because it makes sense to make this change regardless of that. Also, _NEW_TEXTURE is still used in many places, but the obvious occurences are replaced here. It's now possible to split _NEW_TEXTURE_OBJECT further. Reviewed-by: Edward O'Callaghan Reviewed-by: Timothy Arceri Reviewed-by: Nicolai Hähnle --- src/mesa/main/enable.c | 8 ++++---- src/mesa/main/ff_fragment_shader.cpp | 4 ++-- src/mesa/main/mipmap.c | 2 +- src/mesa/main/mtypes.h | 8 +++++--- src/mesa/main/samplerobj.c | 10 +++++----- src/mesa/main/shaderimage.h | 2 +- src/mesa/main/texenv.c | 18 +++++++++--------- src/mesa/main/texgen.c | 6 +++--- src/mesa/main/teximage.c | 6 +++--- src/mesa/main/texobj.c | 14 +++++++------- src/mesa/main/texparam.c | 10 +++++----- src/mesa/main/texstate.c | 2 +- src/mesa/main/uniform_query.cpp | 2 +- src/mesa/program/prog_statevars.c | 4 ++-- src/mesa/state_tracker/st_context.c | 2 +- 15 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index f0c5bb7f35c..d9d63a6b4ba 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -226,7 +226,7 @@ enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) if (texUnit->Enabled == newenabled) return GL_FALSE; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Enabled = newenabled; return GL_TRUE; } @@ -718,7 +718,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) newenabled |= coordBit; if (texUnit->TexGenEnabled == newenabled) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->TexGenEnabled = newenabled; } } @@ -739,7 +739,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) newenabled |= STR_BITS; if (texUnit->TexGenEnabled == newenabled) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->TexGenEnabled = newenabled; } } @@ -958,7 +958,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; CHECK_EXTENSION(ARB_seamless_cube_map, cap); if (ctx->Texture.CubeMapSeamless != state) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); ctx->Texture.CubeMapSeamless = state; } break; diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index be382fa3ae9..f007ac3b40f 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -338,7 +338,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) fp_inputs |= VARYING_BIT_COL1; } - /* _NEW_TEXTURE */ + /* _NEW_TEXTURE_STATE */ fp_inputs |= (ctx->Texture._TexGenEnabled | ctx->Texture._TexMatEnabled) << VARYING_SLOT_TEX0; @@ -404,7 +404,7 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) memset(key, 0, sizeof(*key)); - /* _NEW_TEXTURE */ + /* _NEW_TEXTURE_OBJECT */ mask = ctx->Texture._EnabledCoordUnits; while (mask) { const int i = u_bit_scan(&mask); diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 05c13fbba0c..8745dd93be5 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1867,7 +1867,7 @@ prepare_mipmap_level(struct gl_context *ctx, /* in case the mipmap level is part of an FBO: */ _mesa_update_fbo_texture(ctx, texObj, face, level); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index be78b96810d..91e1948c232 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4100,10 +4100,10 @@ struct gl_matrix_stack #define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */ #define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */ #define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */ -#define _NEW_TEXTURE (1u << 16) /**< gl_context::Texture */ +#define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */ #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */ #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */ -/* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */ +#define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */ #define _NEW_ARRAY (1u << 20) /**< gl_context::Array */ #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */ #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */ @@ -4124,8 +4124,10 @@ struct gl_matrix_stack * Composite state flags */ /*@{*/ +#define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE) + #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ - _NEW_TEXTURE | \ + _NEW_TEXTURE_STATE | \ _NEW_POINT | \ _NEW_PROGRAM | \ _NEW_MODELVIEW) diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index a36563a0182..183f1d2a862 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -226,7 +226,7 @@ _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers) /* If the sampler is currently bound, unbind it. */ for (j = 0; j < ctx->Const.MaxCombinedTextureImageUnits; j++) { if (ctx->Texture.Unit[j].Sampler == sampObj) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[j].Sampler, NULL); } } @@ -258,7 +258,7 @@ _mesa_bind_sampler(struct gl_context *ctx, GLuint unit, struct gl_sampler_object *sampObj) { if (ctx->Texture.Unit[unit].Sampler != sampObj) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); } _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler, @@ -374,7 +374,7 @@ _mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers) _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler, sampObj); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } } @@ -388,7 +388,7 @@ _mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers) _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler, NULL); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } } } @@ -430,7 +430,7 @@ validate_texture_wrap_mode(struct gl_context *ctx, GLenum wrap) static inline void flush(struct gl_context *ctx) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); } void diff --git a/src/mesa/main/shaderimage.h b/src/mesa/main/shaderimage.h index 2cf0b0abc72..99dddb77dfc 100644 --- a/src/mesa/main/shaderimage.h +++ b/src/mesa/main/shaderimage.h @@ -74,7 +74,7 @@ _mesa_init_image_units(struct gl_context *ctx); * should return zero and stores should have no effect. * * The result depends on context state other than the passed image unit, part - * of the _NEW_TEXTURE set. + * of the _NEW_TEXTURE_OBJECT set. */ GLboolean _mesa_is_image_unit_valid(struct gl_context *ctx, struct gl_image_unit *u); diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index de49566ec42..ee5171c5c6a 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -77,7 +77,7 @@ set_env_mode(struct gl_context *ctx, } if (legal) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->EnvMode = mode; } else { @@ -93,7 +93,7 @@ set_env_color(struct gl_context *ctx, { if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texUnit->EnvColorUnclamped, color); texUnit->EnvColor[0] = CLAMP(color[0], 0.0F, 1.0F); texUnit->EnvColor[1] = CLAMP(color[1], 0.0F, 1.0F); @@ -151,14 +151,14 @@ set_combiner_mode(struct gl_context *ctx, case GL_COMBINE_RGB: if (texUnit->Combine.ModeRGB == mode) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ModeRGB = mode; break; case GL_COMBINE_ALPHA: if (texUnit->Combine.ModeA == mode) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ModeA = mode; break; default: @@ -249,7 +249,7 @@ set_combiner_source(struct gl_context *ctx, return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); if (alpha) texUnit->Combine.SourceA[term] = param; @@ -331,7 +331,7 @@ set_combiner_operand(struct gl_context *ctx, return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); if (alpha) texUnit->Combine.OperandA[term] = param; @@ -366,13 +366,13 @@ set_combiner_scale(struct gl_context *ctx, case GL_RGB_SCALE: if (texUnit->Combine.ScaleShiftRGB == shift) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ScaleShiftRGB = shift; break; case GL_ALPHA_SCALE: if (texUnit->Combine.ScaleShiftA == shift) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ScaleShiftA = shift; break; default: @@ -444,7 +444,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) if (pname == GL_TEXTURE_LOD_BIAS_EXT) { if (texUnit->LodBias == param[0]) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->LodBias = param[0]; } else { diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index 24ba295746a..1b8d187cd3b 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -133,7 +133,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texgen->Mode = mode; texgen->_ModeBit = bit; } @@ -147,7 +147,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) } if (TEST_EQ_4V(texgen->ObjectPlane, params)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texgen->ObjectPlane, params); } break; @@ -169,7 +169,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) ctx->ModelviewMatrixStack.Top->inv); if (TEST_EQ_4V(texgen->EyePlane, tmp)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texgen->EyePlane, tmp); } break; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index efbf30b8280..1a00d251324 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3225,7 +3225,7 @@ _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims, check_gen_mipmap(ctx, target, texObj, level); - /* NOTE: Don't signal _NEW_TEXTURE since we've only changed + /* NOTE: Don't signal _NEW_TEXTURE_OBJECT since we've only changed * the texel data, not the texture format, size, etc. */ } @@ -3817,7 +3817,7 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims, check_gen_mipmap(ctx, target, texObj, level); - /* NOTE: Don't signal _NEW_TEXTURE since we've only changed + /* NOTE: Don't signal _NEW_TEXTURE_OBJECT since we've only changed * the texel data, not the texture format, size, etc. */ } @@ -4523,7 +4523,7 @@ _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims, check_gen_mipmap(ctx, target, texObj, level); - /* NOTE: Don't signal _NEW_TEXTURE since we've only changed + /* NOTE: Don't signal _NEW_TEXTURE_OBJECT since we've only changed * the texel data, not the texture format, size, etc. */ } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 25b959d1814..a5e64c3e57b 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -932,7 +932,7 @@ _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj) { texObj->_BaseComplete = GL_FALSE; texObj->_MipmapComplete = GL_FALSE; - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } @@ -1412,7 +1412,7 @@ unbind_textures_from_unit(struct gl_context *ctx, GLuint unit) ctx->Driver.BindTexture(ctx, unit, 0, texObj); texUnit->_BoundTextures &= ~(1 << index); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } } @@ -1482,7 +1482,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) _mesa_unlock_texture(ctx, delObj); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; /* The texture _name_ is now free for re-use. * Remove it from the hash table now. @@ -1531,7 +1531,7 @@ _mesa_delete_nameless_texture(struct gl_context *ctx, } _mesa_unlock_texture(ctx, texObj); - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; /* Unreference the texobj. If refcount hits zero, the texture * will be deleted. @@ -1634,7 +1634,7 @@ bind_texture(struct gl_context *ctx, } /* flush before changing binding */ - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); /* If the refcount on the previously bound texture is decremented to * zero, it'll be deleted here. @@ -1915,7 +1915,7 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, } } - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; } @@ -2019,7 +2019,7 @@ _mesa_lock_context_textures( struct gl_context *ctx ) mtx_lock(&ctx->Shared->TexMutex); if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) { - ctx->NewState |= _NEW_TEXTURE; + ctx->NewState |= _NEW_TEXTURE_OBJECT; ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp; } } diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 4db406fa9f6..25165e4eded 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -233,21 +233,21 @@ set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) static inline void flush(struct gl_context *ctx) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); } /** * This is called just prior to changing any texture object state which * could affect texture completeness (texture base level, max level). - * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE + * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE_OBJECT * state flag and then mark the texture object as 'incomplete' so that any * per-texture derived state gets recomputed. */ static inline void incomplete(struct gl_context *ctx, struct gl_texture_object *texObj) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); _mesa_dirty_texobj(ctx, texObj); } @@ -982,7 +982,7 @@ _mesa_texture_parameterIiv(struct gl_context *ctx, _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIiv(texture)"); return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); /* set the integer-valued border color */ COPY_4V(texObj->Sampler.BorderColor.i, params); break; @@ -1004,7 +1004,7 @@ _mesa_texture_parameterIuiv(struct gl_context *ctx, _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIuiv(texture)"); return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); /* set the unsigned integer-valued border color */ COPY_4V(texObj->Sampler.BorderColor.ui, params); break; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 70e014cab63..87c4d4a8881 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -306,7 +306,7 @@ _mesa_ActiveTexture(GLenum texture) return; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); ctx->Texture.CurrentUnit = texUnit; if (ctx->Transform.MatrixMode == GL_TEXTURE) { diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 4d06313565f..e613898713b 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -963,7 +963,7 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values, if (changed) { if (!flushed) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT | _NEW_PROGRAM); flushed = true; } diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 803d0afd8d3..91178e395cb 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -641,9 +641,9 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) return _NEW_LIGHT; case STATE_TEXGEN: - return _NEW_TEXTURE; + return _NEW_TEXTURE_STATE; case STATE_TEXENV_COLOR: - return _NEW_TEXTURE | _NEW_BUFFERS | _NEW_FRAG_CLAMP; + return _NEW_TEXTURE_STATE | _NEW_BUFFERS | _NEW_FRAG_CLAMP; case STATE_FOG_COLOR: return _NEW_FOG | _NEW_BUFFERS | _NEW_FRAG_CLAMP; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index c7d25ecd755..fb98a340010 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -258,7 +258,7 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state) st->active_states = st_get_active_states(ctx); } - if (new_state & _NEW_TEXTURE) { + if (new_state & _NEW_TEXTURE_OBJECT) { st->dirty |= st->active_states & (ST_NEW_SAMPLER_VIEWS | ST_NEW_SAMPLERS | -- 2.30.2