<p dir="ltr"><br>
On Jan 20, 2016 6:18 PM, "Ian Romanick" <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
><br>
> From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
><br>
> _mesa_texture_parameteriv is used because (the more obvious)<br>
> _mesa_texture_parameteri just stuffs the parameter in an array and calls<br>
> _mesa_texture_parameteriv. This just cuts out the middleman.<br>
><br>
> As a side bonus we no longer need check that ARB_stencil_texturing is<br>
> supported. The test doesn't allow non-supporting implementations to<br>
> avoid any work, and it's redundant with the value-changed test.<br>
><br>
> Fix bug #93717 because the state restore commands at the bottom of<br>
> _mesa_meta_GenerateMipmap no longer depend on the bound state.<br>
><br>
> Fixes piglit arb_direct_state_access-generatetexturemipmap with the<br>
> changes recently sent to the piglit mailing list. See the bugzilla<br>
> entry for more info.<br>
><br>
> Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=93717">https://bugs.freedesktop.org/show_bug.cgi?id=93717</a><br>
> Cc: "11.0 11.1" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a>><br>
> ---<br>
> src/mesa/drivers/common/meta.c | 12 ++++++----<br>
> src/mesa/drivers/common/meta.h | 2 +-<br>
> src/mesa/drivers/common/meta_blit.c | 33 ++++++++++++++++----------<br>
> src/mesa/drivers/common/meta_generate_mipmap.c | 26 ++++++++++++++------<br>
> 4 files changed, 49 insertions(+), 24 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c<br>
> index 1ed0e4d..5f2e796 100644<br>
> --- a/src/mesa/drivers/common/meta.c<br>
> +++ b/src/mesa/drivers/common/meta.c<br>
> @@ -3179,8 +3179,10 @@ decompress_texture_image(struct gl_context *ctx,<br>
><br>
> /* restrict sampling to the texture level of interest */<br>
> if (target != GL_TEXTURE_RECTANGLE_ARB) {<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage->Level);<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage->Level);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,<br>
> + (GLint *) &texImage->Level, false);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + (GLint *) &texImage->Level, false);<br>
> }<br>
><br>
> /* render quad w/ texture into renderbuffer */<br>
> @@ -3190,8 +3192,10 @@ decompress_texture_image(struct gl_context *ctx,<br>
> * be restored by _mesa_meta_end().<br>
> */<br>
> if (target != GL_TEXTURE_RECTANGLE_ARB) {<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,<br>
> + &baseLevelSave, false);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + &maxLevelSave, false);<br>
> }<br>
><br>
> }<br>
> diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h<br>
> index 3691e7d..074f70d 100644<br>
> --- a/src/mesa/drivers/common/meta.h<br>
> +++ b/src/mesa/drivers/common/meta.h<br>
> @@ -469,7 +469,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,<br>
><br>
> struct gl_sampler_object *<br>
> _mesa_meta_setup_sampler(struct gl_context *ctx,<br>
> - const struct gl_texture_object *texObj,<br>
> + struct gl_texture_object *texObj,</p>
<p dir="ltr">Wow... Good work us. It's const because the only thing we do with the pointer is look up the name so we can change it some other way. *sigh*</p>
<p dir="ltr">Series is</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></p>
<p dir="ltr">> GLenum target, GLenum filter, GLuint srcLevel);<br>
><br>
> extern GLbitfield<br>
> diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c<br>
> index 78ecfe2..5d80f7d 100644<br>
> --- a/src/mesa/drivers/common/meta_blit.c<br>
> +++ b/src/mesa/drivers/common/meta_blit.c<br>
> @@ -828,22 +828,29 @@ void<br>
> _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,<br>
> struct fb_tex_blit_state *blit)<br>
> {<br>
> + struct gl_texture_object *const texObj =<br>
> + _mesa_get_current_tex_object(ctx, target);<br>
> +<br>
> /* Restore texture object state, the texture binding will<br>
> * be restored by _mesa_meta_end().<br>
> */<br>
> if (target != GL_TEXTURE_RECTANGLE_ARB) {<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, blit->baseLevelSave);<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, blit->maxLevelSave);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,<br>
> + &blit->baseLevelSave, false);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + &blit->maxLevelSave, false);<br>
> }<br>
><br>
> - if (ctx->Extensions.ARB_stencil_texturing) {<br>
> - const struct gl_texture_object *texObj =<br>
> - _mesa_get_current_tex_object(ctx, target);<br>
> + /* If ARB_stencil_texturing is not supported, the mode won't have changed. */<br>
> + if (texObj->StencilSampling != blit->stencilSamplingSave) {<br>
> + /* GLint so the compiler won't complain about type signedness mismatch<br>
> + * in the call to _mesa_texture_parameteriv below.<br>
> + */<br>
> + const GLint param = blit->stencilSamplingSave ?<br>
> + GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;<br>
><br>
> - if (texObj->StencilSampling != blit->stencilSamplingSave)<br>
> - _mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,<br>
> - blit->stencilSamplingSave ?<br>
> - GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_DEPTH_STENCIL_TEXTURE_MODE,<br>
> + ¶m, false);<br>
> }<br>
><br>
> _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, blit->samp_obj_save);<br>
> @@ -895,7 +902,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,<br>
><br>
> struct gl_sampler_object *<br>
> _mesa_meta_setup_sampler(struct gl_context *ctx,<br>
> - const struct gl_texture_object *texObj,<br>
> + struct gl_texture_object *texObj,<br>
> GLenum target, GLenum filter, GLuint srcLevel)<br>
> {<br>
> struct gl_sampler_object *samp_obj;<br>
> @@ -915,8 +922,10 @@ _mesa_meta_setup_sampler(struct gl_context *ctx,<br>
> /* Prepare src texture state */<br>
> _mesa_BindTexture(target, texObj->Name);<br>
> if (target != GL_TEXTURE_RECTANGLE_ARB) {<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,<br>
> + (GLint *) &srcLevel, false);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + (GLint *) &srcLevel, false);<br>
> }<br>
><br>
> return samp_obj;<br>
> diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c<br>
> index f20fcac..27435b2 100644<br>
> --- a/src/mesa/drivers/common/meta_generate_mipmap.c<br>
> +++ b/src/mesa/drivers/common/meta_generate_mipmap.c<br>
> @@ -185,6 +185,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,<br>
> GLint swizzle[4];<br>
> GLboolean swizzleSaved = GL_FALSE;<br>
><br>
> + /* GLint so the compiler won't complain about type signedness mismatch in<br>
> + * the calls to _mesa_texture_parameteriv below.<br>
> + */<br>
> + static const GLint always_false = GL_FALSE;<br>
> + static const GLint always_true = GL_TRUE;<br>
> +<br>
> if (fallback_required(ctx, target, texObj)) {<br>
> _mesa_generate_mipmap(ctx, target, texObj);<br>
> return;<br>
> @@ -248,13 +254,14 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,<br>
> assert(mipmap->FBO != 0);<br>
> _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);<br>
><br>
> - _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_GENERATE_MIPMAP, &always_false, false);<br>
><br>
> if (texObj->_Swizzle != SWIZZLE_NOOP) {<br>
> static const GLint swizzleNoop[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };<br>
> memcpy(swizzle, texObj->Swizzle, sizeof(swizzle));<br>
> swizzleSaved = GL_TRUE;<br>
> - _mesa_TexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzleNoop);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_SWIZZLE_RGBA,<br>
> + swizzleNoop, false);<br>
> }<br>
><br>
> /* Silence valgrind warnings about reading uninitialized stack. */<br>
> @@ -309,7 +316,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,<br>
> /* Allocate storage for the destination mipmap image(s) */<br>
><br>
> /* Set MaxLevel large enough to hold the new level when we allocate it */<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + (GLint *) &dstLevel, false);<br>
><br>
> if (!prepare_mipmap_level(ctx, texObj, dstLevel,<br>
> dstWidth, dstHeight, dstDepth,<br>
> @@ -323,7 +331,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,<br>
> dstImage = _mesa_select_tex_image(texObj, faceTarget, dstLevel);<br>
><br>
> /* limit minification to src level */<br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,<br>
> + (GLint *) &srcLevel, false);<br>
><br>
> /* setup viewport */<br>
> _mesa_set_viewport(ctx, 0, 0, 0, dstWidth, dstHeight);<br>
> @@ -373,9 +382,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,<br>
><br>
> _mesa_meta_end(ctx);<br>
><br>
> - _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL, &maxLevelSave,<br>
> + false);<br>
> if (genMipmapSave)<br>
> - _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_GENERATE_MIPMAP, &always_true,<br>
> + false);<br>
> if (swizzleSaved)<br>
> - _mesa_TexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);<br>
> + _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_SWIZZLE_RGBA, swizzle,<br>
> + false);<br>
> }<br>
> --<br>
> 2.5.0<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>