[Mesa-dev] [PATCH 06/18] meta/blit: Use internal functions for sampler object access

Ian Romanick idr at freedesktop.org
Fri Jan 8 18:59:12 PST 2016


From: Ian Romanick <ian.d.romanick at intel.com>

This requires tracking the sampler object using the gl_sampler_object*
instead of the object name.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/common/meta.h                    |  5 ++--
 src/mesa/drivers/common/meta_blit.c               | 35 +++++++++++++----------
 src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c |  4 +--
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 5b04755..268824c 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -309,7 +309,8 @@ struct blit_state
 struct fb_tex_blit_state
 {
    GLint baseLevelSave, maxLevelSave;
-   GLuint sampler, samplerSave, stencilSamplingSave;
+   struct gl_sampler_object *samp_obj;
+   GLuint samplerSave, stencilSamplingSave;
    GLuint tempTex;
 };
 
@@ -465,7 +466,7 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
                                 struct gl_texture_object **texObj,
                                 GLenum *target);
 
-GLuint
+struct gl_sampler_object *
 _mesa_meta_setup_sampler(struct gl_context *ctx,
                          const struct gl_texture_object *texObj,
                          GLenum target, GLenum filter, GLuint srcLevel);
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 4212150..6c03f5d 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -703,8 +703,8 @@ blitframebuffer_texture(struct gl_context *ctx,
      printf("  srcTex %p  dstText %p\n", texObj, drawAtt->Texture);
    */
 
-   fb_tex_blit.sampler = _mesa_meta_setup_sampler(ctx, texObj, target, filter,
-                                                  srcLevel);
+   fb_tex_blit.samp_obj = _mesa_meta_setup_sampler(ctx, texObj, target, filter,
+                                                   srcLevel);
 
    /* Always do our blits with no net sRGB decode or encode.
     *
@@ -725,13 +725,12 @@ blitframebuffer_texture(struct gl_context *ctx,
    if (ctx->Extensions.EXT_texture_sRGB_decode) {
       if (_mesa_get_format_color_encoding(rb->Format) == GL_SRGB &&
           drawFb->Visual.sRGBCapable) {
-         _mesa_SamplerParameteri(fb_tex_blit.sampler,
-                                 GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT);
+         _mesa_set_sampler_srgb_decode(ctx, fb_tex_blit.samp_obj,
+                                       GL_DECODE_EXT);
          _mesa_set_framebuffer_srgb(ctx, GL_TRUE);
       } else {
-         _mesa_SamplerParameteri(fb_tex_blit.sampler,
-                                 GL_TEXTURE_SRGB_DECODE_EXT,
-                                 GL_SKIP_DECODE_EXT);
+         _mesa_set_sampler_srgb_decode(ctx, fb_tex_blit.samp_obj,
+                                       GL_SKIP_DECODE_EXT);
          /* set_framebuffer_srgb was set by _mesa_meta_begin(). */
       }
    }
@@ -840,7 +839,9 @@ _mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
    }
 
    _mesa_BindSampler(ctx->Texture.CurrentUnit, blit->samplerSave);
-   _mesa_DeleteSamplers(1, &blit->sampler);
+   _mesa_DeleteSamplers(1, &blit->samp_obj->Name);
+   blit->samp_obj = NULL;
+
    if (blit->tempTex)
       _mesa_DeleteTextures(1, &blit->tempTex);
 }
@@ -884,22 +885,26 @@ _mesa_meta_bind_rb_as_tex_image(struct gl_context *ctx,
    return true;
 }
 
-GLuint
+struct gl_sampler_object *
 _mesa_meta_setup_sampler(struct gl_context *ctx,
                          const struct gl_texture_object *texObj,
                          GLenum target, GLenum filter, GLuint srcLevel)
 {
    GLuint sampler;
+   struct gl_sampler_object *samp_obj;
    GLenum tex_filter = (filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
                         filter == GL_SCALED_RESOLVE_NICEST_EXT) ?
                        GL_NEAREST : filter;
 
    _mesa_GenSamplers(1, &sampler);
-   _mesa_BindSampler(ctx->Texture.CurrentUnit, sampler);
-   _mesa_SamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, tex_filter);
-   _mesa_SamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, tex_filter);
-   _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   _mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+   samp_obj = _mesa_lookup_samplerobj(ctx, sampler);
+   assert(samp_obj != NULL && samp_obj->Name == sampler);
+
+   _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, samp_obj);
+   _mesa_set_sampler_filters(ctx, samp_obj, tex_filter, tex_filter);
+   _mesa_set_sampler_wrap(ctx, samp_obj, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
+                          samp_obj->WrapR);
 
    /* Prepare src texture state */
    _mesa_BindTexture(target, texObj->Name);
@@ -908,7 +913,7 @@ _mesa_meta_setup_sampler(struct gl_context *ctx,
       _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, srcLevel);
    }
 
-   return sampler;
+   return samp_obj;
 }
 
 /**
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index ed47172..c5f6c4f 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -409,8 +409,8 @@ set_read_rb_tex_image(struct gl_context *ctx, struct fb_tex_blit_state *blit,
    blit->baseLevelSave = tex_obj->BaseLevel;
    blit->maxLevelSave = tex_obj->MaxLevel;
    blit->stencilSamplingSave = tex_obj->StencilSampling;
-   blit->sampler = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
-                                            GL_NEAREST, level);
+   blit->samp_obj = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
+                                             GL_NEAREST, level);
    return true;
 }
 
-- 
2.5.0



More information about the mesa-dev mailing list