summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Nieminen <pauli.nieminen@linux.intel.com>2012-06-09 11:44:07 +0300
committerPauli Nieminen <pauli.nieminen@linux.intel.com>2012-06-10 00:26:27 +0300
commitdbc3d0f753943b5d187678881068bc09ad47d8a2 (patch)
tree520397edcb3154a3f39eff52c1cd25ac336a4c00
parent74fee5dfcb535d50278c4cbb4ceca8ca590f2559 (diff)
meta: Use sampler object in framebuffer blitHEADmasterARB_sampler_object
Framebuffer blit needs to setup texture sampling to match application requested blit operation. Sampler object can be used to avoid changes to texture object. But caching sampler object doesn't make much sense when we need to synamically change it based on filtering parameters. Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
-rw-r--r--src/mesa/drivers/common/meta.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 83ae3d90ee..14e177bfe9 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1314,15 +1314,13 @@ blitframebuffer_texture(struct gl_context *ctx,
if (readAtt && readAtt->Texture) {
const struct gl_texture_object *texObj = readAtt->Texture;
const GLuint srcLevel = readAtt->TextureLevel;
- const GLenum minFilterSave = texObj->Sampler.MinFilter;
- const GLenum magFilterSave = texObj->Sampler.MagFilter;
const GLint baseLevelSave = texObj->BaseLevel;
const GLint maxLevelSave = texObj->MaxLevel;
- const GLenum wrapSSave = texObj->Sampler.WrapS;
- const GLenum wrapTSave = texObj->Sampler.WrapT;
- const GLenum srgbSave = texObj->Sampler.sRGBDecode;
const GLenum fbo_srgb_save = ctx->Color.sRGBEnabled;
const GLenum target = texObj->Target;
+ GLuint sampler, samplerSave =
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ?
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0;
if (drawAtt->Texture == readAtt->Texture) {
/* Can't use same texture as both the source and dest. We need
@@ -1337,6 +1335,9 @@ blitframebuffer_texture(struct gl_context *ctx,
return mask;
}
+ _mesa_GenSamplers(1, &sampler);
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
+
/*
printf("Blit from texture!\n");
printf(" srcAtt %p dstAtt %p\n", readAtt, drawAtt);
@@ -1345,18 +1346,18 @@ blitframebuffer_texture(struct gl_context *ctx,
/* Prepare src texture state */
_mesa_BindTexture(target, texObj->Name);
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, filter);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, filter);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, srcLevel);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
}
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* Always do our blits with no sRGB decode or encode.*/
if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
GL_SKIP_DECODE_EXT);
}
if (ctx->Extensions.EXT_framebuffer_sRGB) {
@@ -1416,21 +1417,17 @@ blitframebuffer_texture(struct gl_context *ctx,
/* Restore texture object state, the texture binding will
* be restored by _mesa_meta_end().
*/
- _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilterSave);
- _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilterSave);
if (target != GL_TEXTURE_RECTANGLE_ARB) {
_mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, baseLevelSave);
_mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
}
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave);
- _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave);
- if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave);
- }
if (ctx->Extensions.EXT_framebuffer_sRGB && fbo_srgb_save) {
_mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_TRUE);
}
+ _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
+ _mesa_DeleteSamplers(1, &sampler);
+
/* Done with color buffer */
mask &= ~GL_COLOR_BUFFER_BIT;
}