[Mesa-dev] [PATCH 09/12] st/mesa: use new _mesa_base_tex_image() helper

Brian Paul brianp at vmware.com
Fri Jan 2 16:54:59 PST 2015


This involved adding a new st_texture_image_const() helper also.
---
 src/mesa/state_tracker/st_atom_sampler.c | 3 ++-
 src/mesa/state_tracker/st_atom_texture.c | 3 ++-
 src/mesa/state_tracker/st_cb_drawtex.c   | 3 ++-
 src/mesa/state_tracker/st_cb_texture.c   | 4 ++--
 src/mesa/state_tracker/st_texture.h      | 6 ++++++
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 17b536b..f8d7cd7 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -36,6 +36,7 @@
 #include "main/mtypes.h"
 #include "main/glformats.h"
 #include "main/samplerobj.h"
+#include "main/teximage.h"
 #include "main/texobj.h"
 
 #include "st_context.h"
@@ -141,7 +142,7 @@ convert_sampler(struct st_context *st,
       texobj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
    }
 
-   teximg = texobj->Image[0][texobj->BaseLevel];
+   teximg = _mesa_base_tex_image_const(texobj);
    texBaseFormat = teximg ? teximg->_BaseFormat : GL_RGBA;
 
    msamp = _mesa_get_samplerobj(ctx, texUnit);
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 19072ae..c95e36a 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -35,6 +35,7 @@
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/samplerobj.h"
+#include "main/teximage.h"
 #include "main/texobj.h"
 #include "program/prog_instruction.h"
 
@@ -176,7 +177,7 @@ static unsigned
 get_texture_format_swizzle(const struct st_texture_object *stObj)
 {
    const struct gl_texture_image *texImage =
-      stObj->base.Image[0][stObj->base.BaseLevel];
+      _mesa_base_tex_image_const(&stObj->base);
    unsigned tex_swizzle;
 
    if (texImage) {
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c
index d057ff6..1420b96 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -15,6 +15,7 @@
 #include "main/imports.h"
 #include "main/image.h"
 #include "main/macros.h"
+#include "main/teximage.h"
 #include "program/program.h"
 #include "program/prog_print.h"
 
@@ -196,7 +197,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
          if (ctx->Texture.Unit[i]._Current &&
              ctx->Texture.Unit[i]._Current->Target == GL_TEXTURE_2D) {
             struct gl_texture_object *obj = ctx->Texture.Unit[i]._Current;
-            struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
+            const struct gl_texture_image *img = _mesa_base_tex_image(obj);
             const GLfloat wt = (GLfloat) img->Width;
             const GLfloat ht = (GLfloat) img->Height;
             const GLfloat s0 = obj->CropRect[0] / wt;
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index a8dbb78..c2bf1ef 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1546,7 +1546,7 @@ st_finalize_texture(struct gl_context *ctx,
    struct st_texture_object *stObj = st_texture_object(tObj);
    const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
    GLuint face;
-   struct st_texture_image *firstImage;
+   const struct st_texture_image *firstImage;
    enum pipe_format firstImageFormat;
    GLuint ptWidth, ptHeight, ptDepth, ptLayers, ptNumSamples;
 
@@ -1587,7 +1587,7 @@ st_finalize_texture(struct gl_context *ctx,
 
    }
 
-   firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
+   firstImage = st_texture_image_const(_mesa_base_tex_image(&stObj->base));
    assert(firstImage);
 
    /* If both firstImage and stObj point to a texture which can contain
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index d66afcb..2f54029 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -123,6 +123,12 @@ st_texture_image(struct gl_texture_image *img)
    return (struct st_texture_image *) img;
 }
 
+static INLINE const struct st_texture_image *
+st_texture_image_const(const struct gl_texture_image *img)
+{
+   return (const struct st_texture_image *) img;
+}
+
 static INLINE struct st_texture_object *
 st_texture_object(struct gl_texture_object *obj)
 {
-- 
1.9.1



More information about the mesa-dev mailing list