Mesa (master): intel: Add support for ARB_sampler_objects.

Eric Anholt anholt at kemper.freedesktop.org
Sat Apr 23 20:23:06 UTC 2011


Module: Mesa
Branch: master
Commit: 1f32c665c8af0622e2bbf451edb999ffbcd7d0fe
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f32c665c8af0622e2bbf451edb999ffbcd7d0fe

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Apr 20 11:48:31 2011 -0700

intel: Add support for ARB_sampler_objects.

This extension support consists of replacing
"gl_texture_obj->Sampler." with "_mesa_get_samplerobj(ctx, unit)->".
One instance of referencing the texture's base sampler remains in the
initial miptree allocation, where I'm not sure we have a clear
association with any texture unit.

Tested with piglit ARB_sampler_objects/sampler-objects.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/drivers/common/driverfuncs.c            |    3 ++
 src/mesa/drivers/dri/i915/i830_texstate.c        |   26 ++++++++------
 src/mesa/drivers/dri/i915/i915_texstate.c        |   40 +++++++++++----------
 src/mesa/drivers/dri/i965/brw_draw.c             |   16 +++++---
 src/mesa/drivers/dri/i965/brw_wm.c               |   10 +++--
 src/mesa/drivers/dri/i965/brw_wm_sampler_state.c |   35 ++++++++++---------
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |    6 ++-
 src/mesa/drivers/dri/intel/intel_extensions.c    |    1 +
 src/mesa/drivers/dri/intel/intel_tex_validate.c  |   11 ++++--
 src/mesa/main/samplerobj.h                       |    8 ++++
 src/mesa/state_tracker/st_atom_sampler.c         |    4 ++-
 src/mesa/state_tracker/st_atom_texture.c         |    4 ++-
 src/mesa/state_tracker/st_texture.h              |   15 --------
 13 files changed, 99 insertions(+), 80 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 854dea9..0dbc7c3 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -41,6 +41,7 @@
 #include "main/bufferobj.h"
 #include "main/fbobject.h"
 #include "main/texrender.h"
+#include "main/samplerobj.h"
 #include "main/syncobj.h"
 #include "main/texturebarrier.h"
 #include "main/transformfeedback.h"
@@ -200,6 +201,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
 
    _mesa_init_transform_feedback_functions(driver);
 
+   _mesa_init_sampler_object_functions(driver);
+
    /* T&L stuff */
    driver->NeedValidate = GL_FALSE;
    driver->ValidateTnlModule = NULL;
diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c
index 7554bd5..3298dbb 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -29,6 +29,7 @@
 #include "main/enums.h"
 #include "main/colormac.h"
 #include "main/macros.h"
+#include "main/samplerobj.h"
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
@@ -120,6 +121,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    struct gl_texture_object *tObj = tUnit->_Current;
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
    struct gl_texture_image *firstImage;
+   struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
    GLuint *state = i830->state.Tex[unit], format, pitch;
    GLint lodbias;
    GLubyte border[4];
@@ -193,7 +195,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
       float maxlod;
       uint32_t minlod_fixed, maxlod_fixed;
 
-      switch (tObj->Sampler.MinFilter) {
+      switch (sampler->MinFilter) {
       case GL_NEAREST:
          minFilt = FILTER_NEAREST;
          mipFilt = MIPFILTER_NONE;
@@ -222,12 +224,12 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
          return GL_FALSE;
       }
 
-      if (tObj->Sampler.MaxAnisotropy > 1.0) {
+      if (sampler->MaxAnisotropy > 1.0) {
          minFilt = FILTER_ANISOTROPIC;
          magFilt = FILTER_ANISOTROPIC;
       }
       else {
-         switch (tObj->Sampler.MagFilter) {
+         switch (sampler->MagFilter) {
          case GL_NEAREST:
             magFilt = FILTER_NEAREST;
             break;
@@ -239,7 +241,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
          }
       }
 
-      lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
+      lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
       if (lodbias < -64)
           lodbias = -64;
       if (lodbias > 63)
@@ -259,8 +261,8 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
        * addressable (smallest resolution) LOD.  Use it to cover both
        * MAX_LEVEL and MAX_LOD.
        */
-      minlod_fixed = U_FIXED(CLAMP(tObj->Sampler.MinLod, 0.0, 11), 4);
-      maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
+      minlod_fixed = U_FIXED(CLAMP(sampler->MinLod, 0.0, 11), 4);
+      maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
       if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM ||
 	  intel->intelScreen->deviceID == PCI_CHIP_I865_G) {
 	 maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2);
@@ -279,8 +281,8 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    }
 
    {
-      GLenum ws = tObj->Sampler.WrapS;
-      GLenum wt = tObj->Sampler.WrapT;
+      GLenum ws = sampler->WrapS;
+      GLenum wt = sampler->WrapT;
 
 
       /* 3D textures not available on i830
@@ -300,10 +302,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    }
 
    /* convert border color from float to ubyte */
-   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
-   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
-   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
-   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
+   CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
+   CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
+   CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
+   CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
 
    state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
 					      border[0],
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 742bb99..5aa2ea1 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -29,6 +29,7 @@
 #include "main/enums.h"
 #include "main/macros.h"
 #include "main/colormac.h"
+#include "main/samplerobj.h"
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
@@ -136,6 +137,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    struct gl_texture_object *tObj = tUnit->_Current;
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
    struct gl_texture_image *firstImage;
+   struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
    GLuint *state = i915->state.Tex[unit], format, pitch;
    GLint lodbias, aniso = 0;
    GLubyte border[4];
@@ -164,7 +166,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
    format = translate_texture_format(firstImage->TexFormat,
 				     firstImage->InternalFormat,
-				     tObj->Sampler.DepthMode);
+				     sampler->DepthMode);
    pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
 
    state[I915_TEXREG_MS3] =
@@ -181,7 +183,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
     * (lowest resolution) LOD.  Use it to cover both MAX_LEVEL and
     * MAX_LOD.
     */
-   maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
+   maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
    state[I915_TEXREG_MS4] =
       ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
        MS4_CUBE_FACE_ENA_MASK |
@@ -192,7 +194,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    {
       GLuint minFilt, mipFilt, magFilt;
 
-      switch (tObj->Sampler.MinFilter) {
+      switch (sampler->MinFilter) {
       case GL_NEAREST:
          minFilt = FILTER_NEAREST;
          mipFilt = MIPFILTER_NONE;
@@ -221,16 +223,16 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
          return GL_FALSE;
       }
 
-      if (tObj->Sampler.MaxAnisotropy > 1.0) {
+      if (sampler->MaxAnisotropy > 1.0) {
          minFilt = FILTER_ANISOTROPIC;
          magFilt = FILTER_ANISOTROPIC;
-         if (tObj->Sampler.MaxAnisotropy > 2.0)
+         if (sampler->MaxAnisotropy > 2.0)
             aniso = SS2_MAX_ANISO_4;
          else
             aniso = SS2_MAX_ANISO_2;
       }
       else {
-         switch (tObj->Sampler.MagFilter) {
+         switch (sampler->MagFilter) {
          case GL_NEAREST:
             magFilt = FILTER_NEAREST;
             break;
@@ -242,7 +244,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
          }
       }
 
-      lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
+      lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
       if (lodbias < -256)
           lodbias = -256;
       if (lodbias > 255)
@@ -258,14 +260,14 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
       /* Shadow:
        */
-      if (tObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
+      if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
           tObj->Target != GL_TEXTURE_3D) {
          if (tObj->Target == GL_TEXTURE_1D) 
             return GL_FALSE;
 
          state[I915_TEXREG_SS2] |=
             (SS2_SHADOW_ENABLE |
-             intel_translate_shadow_compare_func(tObj->Sampler.CompareFunc));
+             intel_translate_shadow_compare_func(sampler->CompareFunc));
 
          minFilt = FILTER_4X4_FLAT;
          magFilt = FILTER_4X4_FLAT;
@@ -278,9 +280,9 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    }
 
    {
-      GLenum ws = tObj->Sampler.WrapS;
-      GLenum wt = tObj->Sampler.WrapT;
-      GLenum wr = tObj->Sampler.WrapR;
+      GLenum ws = sampler->WrapS;
+      GLenum wt = sampler->WrapT;
+      GLenum wr = sampler->WrapR;
       float minlod;
 
       /* We program 1D textures as 2D textures, so the 2D texcoord could
@@ -298,8 +300,8 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
        * clamp_to_border.
        */
       if (tObj->Target == GL_TEXTURE_3D &&
-          (tObj->Sampler.MinFilter != GL_NEAREST ||
-           tObj->Sampler.MagFilter != GL_NEAREST) &&
+          (sampler->MinFilter != GL_NEAREST ||
+           sampler->MagFilter != GL_NEAREST) &&
           (ws == GL_CLAMP ||
            wt == GL_CLAMP ||
            wr == GL_CLAMP ||
@@ -322,7 +324,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
           (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
           (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
 
-      minlod = MIN2(tObj->Sampler.MinLod, tObj->_MaxLevel - tObj->BaseLevel);
+      minlod = MIN2(sampler->MinLod, tObj->_MaxLevel - tObj->BaseLevel);
       state[I915_TEXREG_SS3] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
       state[I915_TEXREG_SS3] |= (U_FIXED(CLAMP(minlod, 0.0, 11.0), 4) <<
 				 SS3_MIN_LOD_SHIFT);
@@ -330,10 +332,10 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
    }
 
    /* convert border color from float to ubyte */
-   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
-   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
-   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
-   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
+   CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
+   CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
+   CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
+   CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
 
    if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
       /* GL specs that border color for depth textures is taken from the
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 4dd0c82..a22e63c 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -29,6 +29,7 @@
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/condrender.h"
+#include "main/samplerobj.h"
 #include "main/state.h"
 #include "main/enums.h"
 #include "tnl/tnl.h"
@@ -279,22 +280,25 @@ static GLboolean check_fallbacks( struct brw_context *brw,
       int u;
       for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
          struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
+
          if (texUnit->Enabled) {
+	    struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, u);
+
             if (texUnit->Enabled & TEXTURE_1D_BIT) {
-               if (texUnit->CurrentTex[TEXTURE_1D_INDEX]->Sampler.WrapS == GL_CLAMP) {
+               if (sampler->WrapS == GL_CLAMP) {
                    return GL_TRUE;
                }
             }
             if (texUnit->Enabled & TEXTURE_2D_BIT) {
-               if (texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapS == GL_CLAMP ||
-                   texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapT == GL_CLAMP) {
+               if (sampler->WrapS == GL_CLAMP ||
+                   sampler->WrapT == GL_CLAMP) {
                    return GL_TRUE;
                }
             }
             if (texUnit->Enabled & TEXTURE_3D_BIT) {
-               if (texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapS == GL_CLAMP ||
-                   texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapT == GL_CLAMP ||
-                   texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapR == GL_CLAMP) {
+               if (sampler->WrapS == GL_CLAMP ||
+                   sampler->WrapT == GL_CLAMP ||
+                   sampler->WrapR == GL_CLAMP) {
                    return GL_TRUE;
                }
             }
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 65af227..c4b2157 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -33,6 +33,7 @@
 #include "brw_wm.h"
 #include "brw_state.h"
 #include "main/formats.h"
+#include "main/samplerobj.h"
 
 /** Return number of src args for given instruction */
 GLuint brw_wm_nr_args( GLuint opcode )
@@ -373,6 +374,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
       if (unit->_ReallyEnabled) {
          const struct gl_texture_object *t = unit->_Current;
          const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+	 struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, i);
 	 int swizzles[SWIZZLE_NIL + 1] = {
 	    SWIZZLE_X,
 	    SWIZZLE_Y,
@@ -388,14 +390,14 @@ static void brw_wm_populate_key( struct brw_context *brw,
 	  * well and our shadow compares always return the result in
 	  * all 4 channels.
 	  */
-	 if (t->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
-	    if (t->Sampler.DepthMode == GL_ALPHA) {
+	 if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+	    if (sampler->DepthMode == GL_ALPHA) {
 	       swizzles[0] = SWIZZLE_ZERO;
 	       swizzles[1] = SWIZZLE_ZERO;
 	       swizzles[2] = SWIZZLE_ZERO;
-	    } else if (t->Sampler.DepthMode == GL_LUMINANCE) {
+	    } else if (sampler->DepthMode == GL_LUMINANCE) {
 	       swizzles[3] = SWIZZLE_ONE;
-	    } else if (t->Sampler.DepthMode == GL_RED) {
+	    } else if (sampler->DepthMode == GL_RED) {
 	       /* See table 3.23 of the GL 3.0 spec. */
 	       swizzles[1] = SWIZZLE_ZERO;
 	       swizzles[2] = SWIZZLE_ZERO;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index cfc30d8..8e12e0c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -35,7 +35,7 @@
 #include "brw_defines.h"
 
 #include "main/macros.h"
-
+#include "main/samplerobj.h"
 
 
 /* Samplers aren't strictly wm state from the hardware's perspective,
@@ -278,6 +278,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 	 struct gl_texture_object *texObj = texUnit->_Current;
 	 struct gl_texture_image *firstImage =
 	    texObj->Image[0][texObj->BaseLevel];
+	 struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
 
 	 memset(last_entry_end, 0, 
 		(char*)entry - last_entry_end + sizeof(*entry));
@@ -288,26 +289,26 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 	 entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
 	    ? ctx->Texture.CubeMapSeamless : GL_FALSE;
 
-	 entry->wrap_r = texObj->Sampler.WrapR;
-	 entry->wrap_s = texObj->Sampler.WrapS;
-	 entry->wrap_t = texObj->Sampler.WrapT;
+	 entry->wrap_r = sampler->WrapR;
+	 entry->wrap_s = sampler->WrapS;
+	 entry->wrap_t = sampler->WrapT;
 
-	 entry->maxlod = texObj->Sampler.MaxLod;
-	 entry->minlod = texObj->Sampler.MinLod;
-	 entry->lod_bias = texUnit->LodBias + texObj->Sampler.LodBias;
-	 entry->max_aniso = texObj->Sampler.MaxAnisotropy;
-	 entry->minfilter = texObj->Sampler.MinFilter;
-	 entry->magfilter = texObj->Sampler.MagFilter;
-	 entry->comparemode = texObj->Sampler.CompareMode;
-         entry->comparefunc = texObj->Sampler.CompareFunc;
+	 entry->maxlod = sampler->MaxLod;
+	 entry->minlod = sampler->MinLod;
+	 entry->lod_bias = texUnit->LodBias + sampler->LodBias;
+	 entry->max_aniso = sampler->MaxAnisotropy;
+	 entry->minfilter = sampler->MinFilter;
+	 entry->magfilter = sampler->MagFilter;
+	 entry->comparemode = sampler->CompareMode;
+         entry->comparefunc = sampler->CompareFunc;
 
 	 drm_intel_bo_unreference(brw->wm.sdc_bo[unit]);
 	 if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
 	    float bordercolor[4] = {
-	       texObj->Sampler.BorderColor.f[0],
-	       texObj->Sampler.BorderColor.f[0],
-	       texObj->Sampler.BorderColor.f[0],
-	       texObj->Sampler.BorderColor.f[0]
+	       sampler->BorderColor.f[0],
+	       sampler->BorderColor.f[0],
+	       sampler->BorderColor.f[0],
+	       sampler->BorderColor.f[0]
 	    };
 	    /* GL specs that border color for depth textures is taken from the
 	     * R channel, while the hardware uses A.  Spam R into all the
@@ -316,7 +317,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 	    brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
 	 } else {
 	    brw->wm.sdc_bo[unit] = upload_default_color(brw,
-							texObj->Sampler.BorderColor.f);
+							sampler->BorderColor.f);
 	 }
 	 key->sampler_count = unit + 1;
       }
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index a03c652..f1a9d86 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -31,6 +31,7 @@
                    
 
 #include "main/mtypes.h"
+#include "main/samplerobj.h"
 #include "main/texstore.h"
 #include "program/prog_parameter.h"
 
@@ -217,6 +218,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
    struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
    struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
+   struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
    const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
    struct brw_surface_state *surf;
 
@@ -228,8 +230,8 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
    surf->ss0.surface_type = translate_tex_target(tObj->Target);
    surf->ss0.surface_format = translate_tex_format(firstImage->TexFormat,
                                                    firstImage->InternalFormat,
-                                                   tObj->Sampler.DepthMode,
-                                                   tObj->Sampler.sRGBDecode);
+                                                   sampler->DepthMode,
+                                                   sampler->sRGBDecode);
 
    /* This is ok for all textures with channel width 8bit or less:
     */
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index c24bc99..3fd987a 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -91,6 +91,7 @@ static const struct dri_extension card_extensions[] = {
    { "GL_ARB_pixel_buffer_object",      NULL },
    { "GL_ARB_point_parameters",           GL_ARB_point_parameters_functions },
    { "GL_ARB_point_sprite",               NULL },
+   { "GL_ARB_sampler_objects",            NULL },
    { "GL_ARB_shader_objects",             GL_ARB_shader_objects_functions },
    { "GL_ARB_shading_language_100",       GL_VERSION_2_0_functions },
    { "GL_ARB_sync",                       GL_ARB_sync_functions },
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index 5e705c9..27f2646 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -1,5 +1,6 @@
 #include "main/mtypes.h"
 #include "main/macros.h"
+#include "main/samplerobj.h"
 
 #include "intel_context.h"
 #include "intel_mipmap_tree.h"
@@ -14,11 +15,13 @@
  */
 static void
 intel_update_max_level(struct intel_context *intel,
-		       struct intel_texture_object *intelObj)
+		       struct intel_texture_object *intelObj,
+		       struct gl_sampler_object *sampler)
 {
    struct gl_texture_object *tObj = &intelObj->base;
 
-   if (tObj->Sampler.MinFilter == GL_NEAREST || tObj->Sampler.MinFilter == GL_LINEAR) {
+   if (sampler->MinFilter == GL_NEAREST ||
+       sampler->MinFilter == GL_LINEAR) {
       intelObj->_MaxLevel = tObj->BaseLevel;
    } else {
       intelObj->_MaxLevel = tObj->_MaxLevel;
@@ -70,8 +73,10 @@ copy_image_data_to_tree(struct intel_context *intel,
 GLuint
 intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
 {
+   struct gl_context *ctx = &intel->ctx;
    struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
+   struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
    int comp_byte = 0;
    int cpp;
    GLuint face, i;
@@ -84,7 +89,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
 
    /* What levels must the tree include at a minimum?
     */
-   intel_update_max_level(intel, intelObj);
+   intel_update_max_level(intel, intelObj, sampler);
    firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
 
    /* Fallback case:
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index ed495c3..a839010 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -28,6 +28,14 @@
 
 struct dd_function_table;
 
+static INLINE struct gl_sampler_object *
+_mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
+{
+   if (ctx->Texture.Unit[unit].Sampler)
+      return ctx->Texture.Unit[unit].Sampler;
+   else
+      return &ctx->Texture.Unit[unit]._Current->Sampler;
+}
 
 extern void
 _mesa_reference_sampler_object(struct gl_context *ctx,
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 808aa73..56da010 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -33,6 +33,8 @@
  
 
 #include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
 
 #include "st_context.h"
 #include "st_cb_texture.h"
@@ -154,7 +156,7 @@ update_samplers(struct st_context *st)
 
          teximg = texobj->Image[0][texobj->BaseLevel];
 
-         msamp = st_get_mesa_sampler(st->ctx, texUnit);
+         msamp = _mesa_get_samplerobj(st->ctx, texUnit);
 
          sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
          sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 19ad2e8..9d437ad 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -33,6 +33,8 @@
  
 
 #include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
 #include "program/prog_instruction.h"
 
 #include "st_context.h"
@@ -209,7 +211,7 @@ update_textures(struct st_context *st)
          else
             texUnit = vprog->Base.SamplerUnits[su];
 
-         samp = st_get_mesa_sampler(st->ctx, texUnit);
+         samp = _mesa_get_samplerobj(st->ctx, texUnit);
 
          texObj = st->ctx->Texture.Unit[texUnit]._Current;
 
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 903e30d..d50c3c9 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -163,21 +163,6 @@ st_get_texture_sampler_view(struct st_texture_object *stObj,
 }
 
 
-/**
- * Get pointer to the active sampler object for the given texture unit.
- * This will either be a user-defined sampler object or the texture
- * object's own sampler state.
- */
-static INLINE struct gl_sampler_object *
-st_get_mesa_sampler(const struct gl_context *ctx, GLuint unit)
-{
-   if (ctx->Texture.Unit[unit].Sampler)
-      return ctx->Texture.Unit[unit].Sampler;
-   else
-      return &ctx->Texture.Unit[unit]._Current->Sampler;
-}
-
-
 extern struct pipe_resource *
 st_texture_create(struct st_context *st,
                   enum pipe_texture_target target,




More information about the mesa-commit mailing list