aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2016-01-12 16:37:27 -0800
committerIan Romanick <[email protected]>2016-01-25 10:43:47 -0800
commit2542871387393e855f6afe6c94d44611eefaf6eb (patch)
tree32123da7e1c57c689534a7e1d0572fa409ea9dfd /src
parent18b0ba340b9229e7afd5e38b5d825fde3a435b63 (diff)
meta: Use internal functions to set texture parameters
_mesa_texture_parameteriv is used because (the more obvious) _mesa_texture_parameteri just stuffs the parameter in an array and calls _mesa_texture_parameteriv. This just cuts out the middleman. As a side bonus we no longer need check that ARB_stencil_texturing is supported. The test doesn't allow non-supporting implementations to avoid any work, and it's redundant with the value-changed test. Fix bug #93717 because the state restore commands at the bottom of _mesa_meta_GenerateMipmap no longer depend on the bound state. Fixes piglit arb_direct_state_access-generatetexturemipmap with the changes recently sent to the piglit mailing list. See the bugzilla entry for more info. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93717 Cc: "11.0 11.1" <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/common/meta.c12
-rw-r--r--src/mesa/drivers/common/meta.h2
-rw-r--r--src/mesa/drivers/common/meta_blit.c33
-rw-r--r--src/mesa/drivers/common/meta_generate_mipmap.c26
4 files changed, 49 insertions, 24 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 1ed0e4d1f59..5f2e79637c2 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3179,8 +3179,10 @@ decompress_texture_image(struct gl_context *ctx,
/* restrict sampling to the texture level of interest */
if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, texImage->Level);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, texImage->Level);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
+ (GLint *) &texImage->Level, false);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ (GLint *) &texImage->Level, false);
}
/* render quad w/ texture into renderbuffer */
@@ -3190,8 +3192,10 @@ decompress_texture_image(struct gl_context *ctx,
* be restored by _mesa_meta_end().
*/
if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
+ &baseLevelSave, false);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ &maxLevelSave, false);
}
}
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 3691e7d6123..074f70da6cd 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -469,7 +469,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
struct gl_sampler_object *
_mesa_meta_setup_sampler(struct gl_context *ctx,
- const struct gl_texture_object *texObj,
+ struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel);
extern GLbitfield
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 78ecfe2db59..5d80f7d8fe1 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -828,22 +828,29 @@ void
_mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
struct fb_tex_blit_state *blit)
{
+ struct gl_texture_object *const texObj =
+ _mesa_get_current_tex_object(ctx, target);
+
/* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, blit->baseLevelSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, blit->maxLevelSave);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
+ &blit->baseLevelSave, false);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ &blit->maxLevelSave, false);
}
- if (ctx->Extensions.ARB_stencil_texturing) {
- const struct gl_texture_object *texObj =
- _mesa_get_current_tex_object(ctx, target);
+ /* If ARB_stencil_texturing is not supported, the mode won't have changed. */
+ if (texObj->StencilSampling != blit->stencilSamplingSave) {
+ /* GLint so the compiler won't complain about type signedness mismatch
+ * in the call to _mesa_texture_parameteriv below.
+ */
+ const GLint param = blit->stencilSamplingSave ?
+ GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
- if (texObj->StencilSampling != blit->stencilSamplingSave)
- _mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,
- blit->stencilSamplingSave ?
- GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
+ _mesa_texture_parameteriv(ctx, texObj, GL_DEPTH_STENCIL_TEXTURE_MODE,
+ &param, false);
}
_mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, blit->samp_obj_save);
@@ -895,7 +902,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
struct gl_sampler_object *
_mesa_meta_setup_sampler(struct gl_context *ctx,
- const struct gl_texture_object *texObj,
+ struct gl_texture_object *texObj,
GLenum target, GLenum filter, GLuint srcLevel)
{
struct gl_sampler_object *samp_obj;
@@ -915,8 +922,10 @@ _mesa_meta_setup_sampler(struct gl_context *ctx,
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
- _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_BASE_LEVEL,
+ (GLint *) &srcLevel, false);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ (GLint *) &srcLevel, false);
}
return samp_obj;
diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c
index f20fcac68d6..27435b2b722 100644
--- a/src/mesa/drivers/common/meta_generate_mipmap.c
+++ b/src/mesa/drivers/common/meta_generate_mipmap.c
@@ -185,6 +185,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
GLint swizzle[4];
GLboolean swizzleSaved = GL_FALSE;
+ /* GLint so the compiler won't complain about type signedness mismatch in
+ * the calls to _mesa_texture_parameteriv below.
+ */
+ static const GLint always_false = GL_FALSE;
+ static const GLint always_true = GL_TRUE;
+
if (fallback_required(ctx, target, texObj)) {
_mesa_generate_mipmap(ctx, target, texObj);
return;
@@ -248,13 +254,14 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
assert(mipmap->FBO != 0);
_mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO);
- _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
+ _mesa_texture_parameteriv(ctx, texObj, GL_GENERATE_MIPMAP, &always_false, false);
if (texObj->_Swizzle != SWIZZLE_NOOP) {
static const GLint swizzleNoop[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
memcpy(swizzle, texObj->Swizzle, sizeof(swizzle));
swizzleSaved = GL_TRUE;
- _mesa_TexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzleNoop);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_SWIZZLE_RGBA,
+ swizzleNoop, false);
}
/* Silence valgrind warnings about reading uninitialized stack. */
@@ -309,7 +316,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
/* Allocate storage for the destination mipmap image(s) */
/* Set MaxLevel large enough to hold the new level when we allocate it */
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ (GLint *) &dstLevel, false);
if (!prepare_mipmap_level(ctx, texObj, dstLevel,
dstWidth, dstHeight, dstDepth,
@@ -323,7 +331,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
dstImage = _mesa_select_tex_image(texObj, faceTarget, dstLevel);
/* limit minification to src level */
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL,
+ (GLint *) &srcLevel, false);
/* setup viewport */
_mesa_set_viewport(ctx, 0, 0, 0, dstWidth, dstHeight);
@@ -373,9 +382,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
_mesa_meta_end(ctx);
- _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_MAX_LEVEL, &maxLevelSave,
+ false);
if (genMipmapSave)
- _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave);
+ _mesa_texture_parameteriv(ctx, texObj, GL_GENERATE_MIPMAP, &always_true,
+ false);
if (swizzleSaved)
- _mesa_TexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ _mesa_texture_parameteriv(ctx, texObj, GL_TEXTURE_SWIZZLE_RGBA, swizzle,
+ false);
}