st/mesa: use new _mesa_base_tex_image() helper
authorBrian Paul <brianp@vmware.com>
Fri, 2 Jan 2015 23:56:12 +0000 (16:56 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 5 Jan 2015 20:50:55 +0000 (13:50 -0700)
This involved adding a new st_texture_image_const() helper also.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_drawtex.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.h

index 17b536bf504425db4c383f8ba45e75c3f84f3250..f8d7cd7f9b3621afd40df0a8e58feb13902962ae 100644 (file)
@@ -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);
index 19072ae2fe896fa12c4e69c813938e4e19a72e78..c95e36abc0fc693167da5783e0fee74dd290c393 100644 (file)
@@ -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) {
index d057ff62aeef00be4eaaaa800042a4d6c45045b9..1420b96e55a47ecc1e2ce2ddb4555a3baac5f5ed 100644 (file)
@@ -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;
index a8dbb78884811abd71eeae9be22c5782b171839b..c2bf1ef0289aff7a3be427d5a90e5e68e21de4c0 100644 (file)
@@ -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
index d66afcb560bc47b6abf0c81c57baea3707cb43d6..2f540295f4647065fa223a9cfdd9c1823098cf81 100644 (file)
@@ -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)
 {