From b4bf8725856d571121e0a0fe644ec7b1877adacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 4 Oct 2020 01:31:30 -0400 Subject: [PATCH] mesa: reduce the size of gl_texture_attrib_node::Texture by about 90% Let's get rid of the big memcpy. Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/attrib.c | 20 +++++++++++++------- src/mesa/main/mtypes.h | 6 +++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 0972d9f30d8..4bb3c9f332c 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -226,7 +226,11 @@ _mesa_PushAttrib(GLbitfield mask) _mesa_lock_context_textures(ctx); /* copy/save the bulk of texture state here */ - memcpy(&head->Texture.Texture, &ctx->Texture, sizeof(ctx->Texture)); + head->Texture.CurrentUnit = ctx->Texture.CurrentUnit; + head->Texture._TexGenEnabled = ctx->Texture._TexGenEnabled; + head->Texture._GenFlags = ctx->Texture._GenFlags; + memcpy(&head->Texture.FixedFuncUnit, &ctx->Texture.FixedFuncUnit, + sizeof(ctx->Texture.FixedFuncUnit)); /* Save references to the currently bound texture objects so they don't * accidentally get deleted while referenced in the attribute stack. @@ -240,6 +244,8 @@ _mesa_PushAttrib(GLbitfield mask) /* copy state/contents of the currently bound texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + head->Texture.LodBias[u] = ctx->Texture.Unit[u].LodBias; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { struct gl_texture_object *dst = &head->Texture.SavedObj[u][tex]; struct gl_texture_object *src = ctx->Texture.Unit[u].CurrentTex[tex]; @@ -485,7 +491,7 @@ pop_texture_group(struct gl_context *ctx, struct gl_texture_attrib_node *texstat for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { const struct gl_fixedfunc_texture_unit *unit = - &texstate->Texture.FixedFuncUnit[u]; + &texstate->FixedFuncUnit[u]; struct gl_fixedfunc_texture_unit *destUnit = &ctx->Texture.FixedFuncUnit[u]; GLuint tgt; @@ -536,7 +542,7 @@ pop_texture_group(struct gl_context *ctx, struct gl_texture_attrib_node *texstat _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, - texstate->Texture.Unit[u].LodBias); + texstate->LodBias[u]); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, unit->Combine.ModeRGB); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, @@ -563,7 +569,7 @@ pop_texture_group(struct gl_context *ctx, struct gl_texture_attrib_node *texstat /* Fast path for other drivers. */ memcpy(destUnit, unit, sizeof(*unit)); destUnit->_CurrentCombine = NULL; - ctx->Texture.Unit[u].LodBias = texstate->Texture.Unit[u].LodBias; + ctx->Texture.Unit[u].LodBias = texstate->LodBias[u]; } /* Restore texture object state for each target */ @@ -591,11 +597,11 @@ pop_texture_group(struct gl_context *ctx, struct gl_texture_attrib_node *texstat } if (!ctx->Driver.TexEnv && !ctx->Driver.TexGen) { - ctx->Texture._TexGenEnabled = texstate->Texture._TexGenEnabled; - ctx->Texture._GenFlags = texstate->Texture._GenFlags; + ctx->Texture._TexGenEnabled = texstate->_TexGenEnabled; + ctx->Texture._GenFlags = texstate->_GenFlags; } - _mesa_ActiveTexture(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); + _mesa_ActiveTexture(GL_TEXTURE0_ARB + texstate->CurrentUnit); _mesa_reference_shared_state(ctx, &texstate->SharedRef, NULL); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index fdf75499c84..5993ae25172 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -5035,7 +5035,11 @@ struct gl_enable_attrib_node */ struct gl_texture_attrib_node { - struct gl_texture_attrib Texture; /**< The usual context state */ + GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ + GLbitfield8 _TexGenEnabled; + GLbitfield8 _GenFlags; + struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS]; + GLfloat LodBias[MAX_TEXTURE_UNITS]; /** to save per texture object state (wrap modes, filters, etc): */ struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS];