On 09/21/2011 05:56 PM, Brian Paul wrote:
From: Brian Paul<bri...@vmware.com>

It's only used by swrast.

The useful thing of client-storage is that we could use it for asynchronous texture uploads. With PBOs, there's not a lot of point.

For the series,

Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>

---
  src/mesa/main/mtypes.h        |    1 -
  src/mesa/main/teximage.c      |    7 -------
  src/mesa/swrast/s_context.h   |    3 ++-
  src/mesa/swrast/s_texfilter.c |   27 ++++++++++++++++++---------
  src/mesa/swrast/s_texture.c   |    8 ++++++++
  src/mesa/swrast/s_triangle.c  |    5 ++++-
  6 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 42831d7..a3f0deb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1258,7 +1258,6 @@ struct gl_texture_image
     GLfloat HeightScale;               /**<  used for mipmap LOD computation */
     GLfloat DepthScale;                /**<  used for mipmap LOD computation */
     GLboolean IsClientData;    /**<  Data owned by client? */
-   GLboolean _IsPowerOfTwo;    /**<  Are all dimensions powers of two? */

     struct gl_texture_object *TexObject;  /**<  Pointer back to parent object 
*/
     GLuint Level;                /**<  Which mipmap level am I? */
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fa00183..50e7b4c 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1159,13 +1159,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, 
GLenum target,

     img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);

-   if ((width == 1 || _mesa_is_pow_two(img->Width2))&&
-       (height == 1 || _mesa_is_pow_two(img->Height2))&&
-       (depth == 1 || _mesa_is_pow_two(img->Depth2)))
-      img->_IsPowerOfTwo = GL_TRUE;
-   else
-      img->_IsPowerOfTwo = GL_FALSE;
-
     /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
     img->RowStride = width;
     /* Allocate the ImageOffsets array and initialize to typical values.
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 8357483..363115a 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -139,10 +139,11 @@ struct swrast_texture_image
  {
     struct gl_texture_image Base;

+   GLboolean _IsPowerOfTwo;  /**<  Are all dimensions powers of two? */
+
  #if 0
     /** used for mipmap LOD computation */
     GLfloat WidthScale, HeightScale, DepthScale;
-   GLboolean _IsPowerOfTwo;  /**<  Are all dimensions powers of two? */

     GLubyte *Data;    /**<  The actual texture data in malloc'd memory */

diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index a7a190a..262ad74 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -159,11 +159,12 @@ linear_texel_locations(GLenum wrapMode,
                         GLint size, GLfloat s,
                         GLint *i0, GLint *i1, GLfloat *weight)
  {
+   const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
     GLfloat u;
     switch (wrapMode) {
     case GL_REPEAT:
        u = s * size - 0.5F;
-      if (img->_IsPowerOfTwo) {
+      if (swImg->_IsPowerOfTwo) {
           *i0 = IFLOOR(u)&  (size - 1);
           *i1 = (*i0 + 1)&  (size - 1);
        }
@@ -285,6 +286,7 @@ nearest_texel_location(GLenum wrapMode,
                         const struct gl_texture_image *img,
                         GLint size, GLfloat s)
  {
+   const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
     GLint i;

     switch (wrapMode) {
@@ -292,7 +294,7 @@ nearest_texel_location(GLenum wrapMode,
        /* s limited to [0,1) */
        /* i limited to [0,size-1] */
        i = IFLOOR(s * size);
-      if (img->_IsPowerOfTwo)
+      if (swImg->_IsPowerOfTwo)
           i&= (size - 1);
        else
           i = REMAINDER(i, size);
@@ -1173,7 +1175,7 @@ sample_2d_linear_repeat(struct gl_context *ctx,
     ASSERT(tObj->Sampler.WrapS == GL_REPEAT);
     ASSERT(tObj->Sampler.WrapT == GL_REPEAT);
     ASSERT(img->Border == 0);
-   ASSERT(img->_IsPowerOfTwo);
+   ASSERT(swImg->_IsPowerOfTwo);

     linear_repeat_texel_location(width,  texcoord[0],&i0,&i1,&wi);
     linear_repeat_texel_location(height, texcoord[1],&j0,&j1,&wj);
@@ -1320,10 +1322,11 @@ sample_linear_2d(struct gl_context *ctx,
  {
     GLuint i;
     struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+   const struct swrast_texture_image *swImg = 
swrast_texture_image_const(image);
     (void) lambda;
     if (tObj->Sampler.WrapS == GL_REPEAT&&
         tObj->Sampler.WrapT == GL_REPEAT&&
-       image->_IsPowerOfTwo&&
+       swImg->_IsPowerOfTwo&&
         image->Border == 0) {
        for (i = 0; i<  n; i++) {
           sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]);
@@ -1352,6 +1355,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
                    const GLfloat lambda[], GLfloat rgba[][4])
  {
     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+   const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
     const GLfloat width = (GLfloat) img->Width;
     const GLfloat height = (GLfloat) img->Height;
     const GLint colMask = img->Width - 1;
@@ -1364,7 +1368,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
     ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
     ASSERT(img->Border==0);
     ASSERT(img->TexFormat == MESA_FORMAT_RGB888);
-   ASSERT(img->_IsPowerOfTwo);
+   ASSERT(swImg->_IsPowerOfTwo);

     for (k=0; k<n; k++) {
        GLint i = IFLOOR(texcoords[k][0] * width)&  colMask;
@@ -1394,6 +1398,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
                     const GLfloat lambda[], GLfloat rgba[][4])
  {
     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+   const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
     const GLfloat width = (GLfloat) img->Width;
     const GLfloat height = (GLfloat) img->Height;
     const GLint colMask = img->Width - 1;
@@ -1406,7 +1411,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
     ASSERT(tObj->Sampler.WrapT==GL_REPEAT);
     ASSERT(img->Border==0);
     ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888);
-   ASSERT(img->_IsPowerOfTwo);
+   ASSERT(swImg->_IsPowerOfTwo);

     for (i = 0; i<  n; i++) {
        const GLint col = IFLOOR(texcoords[i][0] * width)&  colMask;
@@ -1429,13 +1434,14 @@ sample_lambda_2d(struct gl_context *ctx,
                   const GLfloat lambda[], GLfloat rgba[][4])
  {
     const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+   const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
     GLuint minStart, minEnd;  /* texels with minification */
     GLuint magStart, magEnd;  /* texels with magnification */

     const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT)
        &&  (tObj->Sampler.WrapT == GL_REPEAT)
        &&  (tImg->Border == 0&&  (tImg->Width == tImg->RowStride))
-&&  tImg->_IsPowerOfTwo;
+&&  swImg->_IsPowerOfTwo;

     ASSERT(lambda != NULL);
     compute_min_mag_ranges(tObj, n, lambda,
@@ -3634,17 +3640,20 @@ _swrast_choose_texture_sample_func( struct gl_context 
*ctx,
           else {
              /* check for a few optimized cases */
              const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+            const struct swrast_texture_image *swImg =
+               swrast_texture_image_const(img);
+
              ASSERT(t->Sampler.MinFilter == GL_NEAREST);
              if (t->Sampler.WrapS == GL_REPEAT&&
                  t->Sampler.WrapT == GL_REPEAT&&
-                img->_IsPowerOfTwo&&
+                swImg->_IsPowerOfTwo&&
                  img->Border == 0&&
                  img->TexFormat == MESA_FORMAT_RGB888) {
                 return&opt_sample_rgb_2d;
              }
              else if (t->Sampler.WrapS == GL_REPEAT&&
                       t->Sampler.WrapT == GL_REPEAT&&
-                     img->_IsPowerOfTwo&&
+                     swImg->_IsPowerOfTwo&&
                       img->Border == 0&&
                       img->TexFormat == MESA_FORMAT_RGBA8888) {
                 return&opt_sample_rgba_2d;
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 7e3fc28..14ee0eb 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -67,6 +67,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
                                     gl_format format, GLsizei width,
                                     GLsizei height, GLsizei depth)
  {
+   struct swrast_texture_image *swImg = swrast_texture_image(texImage);
     GLuint bytes = _mesa_format_image_size(format, width, height, depth);

     /* This _should_ be true (revisit if these ever fail) */
@@ -77,6 +78,13 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
     assert(!texImage->Data);
     texImage->Data = _mesa_align_malloc(bytes, 512);

+   if ((width == 1 || _mesa_is_pow_two(texImage->Width2))&&
+       (height == 1 || _mesa_is_pow_two(texImage->Height2))&&
+       (depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
+      swImg->_IsPowerOfTwo = GL_TRUE;
+   else
+      swImg->_IsPowerOfTwo = GL_FALSE;
+
     return texImage->Data != NULL;
  }

diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 8a9671a..77bd2a3 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1038,11 +1038,14 @@ _swrast_choose_triangle( struct gl_context *ctx )
           /* Ugh, we do a _lot_ of tests to pick the best textured tri func */
           const struct gl_texture_object *texObj2D;
           const struct gl_texture_image *texImg;
+         const struct swrast_texture_image *swImg;
           GLenum minFilter, magFilter, envMode;
           gl_format format;
           texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];

           texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
+         swImg = swrast_texture_image_const(texImg);
+
           format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
           minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE;
           magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE;
@@ -1057,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
               &&  texObj2D->Sampler.WrapS == GL_REPEAT
               &&  texObj2D->Sampler.WrapT == GL_REPEAT
               &&  texObj2D->_Swizzle == SWIZZLE_NOOP
-&&  texImg->_IsPowerOfTwo
+&&  swImg->_IsPowerOfTwo
               &&  texImg->Border == 0
               &&  texImg->Width == texImg->RowStride
               &&  (format == MESA_FORMAT_RGB888 || format == 
MESA_FORMAT_RGBA8888)

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to