r300: Texture size limit cleanups.
authorMichel Dänzer <daenzer@vmware.com>
Wed, 25 Mar 2009 10:13:28 +0000 (11:13 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Wed, 25 Mar 2009 10:19:05 +0000 (11:19 +0100)
Since core Mesa MAX_TEXTURE_LEVELS was bumped, we were incorrectly advertising
a maximum texture size of 4096 on older chips, causing corrupted menu text in
Extreme Tux Racer or Armagetron.

Also make sure our texture image array can actually hold all the mipmap levels
we support...

src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_texmem.c
src/mesa/drivers/dri/r300/r300_texstate.c

index fddd87b85ff0ddf19d25c1697945f3523652f68e..12bee1a8fbbb7688e1d62a70b2dbc4874acb11a7 100644 (file)
@@ -288,10 +288,23 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
        ctx->Const.MaxTextureMaxAnisotropy = 16.0;
        ctx->Const.MaxTextureLodBias = 16.0;
 
-       if (screen->chip_family >= CHIP_FAMILY_RV515) {
+       if (screen->chip_family >= CHIP_FAMILY_RV515)
            ctx->Const.MaxTextureLevels = 13;
-           ctx->Const.MaxTextureRectSize = 4096;
-       }
+       else
+           ctx->Const.MaxTextureLevels = 12;
+
+        driCalculateMaxTextureLevels( r300->texture_heaps,
+                                      r300->nr_heaps,
+                                      & ctx->Const,
+                                      4,
+                                      ctx->Const.MaxTextureLevels - 1,
+                                      MIN2(ctx->Const.MaxTextureLevels,
+                                           MAX_3D_TEXTURE_LEVELS) - 1,
+                                      ctx->Const.MaxTextureLevels - 1,
+                                      ctx->Const.MaxTextureLevels - 1,
+                                      ctx->Const.MaxTextureLevels - 1,
+                                      GL_FALSE,
+                                      2 );
 
        ctx->Const.MinPointSize = 1.0;
        ctx->Const.MinPointSizeAA = 1.0;
index c15e9fa3009c508549912727398ec7670058de73..9c4958699841ef22895d8d961b6b6a9ed9d3cab5 100644 (file)
@@ -170,6 +170,10 @@ struct r300_dma {
 
 typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;
 
+/* Maximum number of mipmap levels supported by any supported GPU
+ */
+#define R300_MAX_TEXTURE_LEVELS 13
+
 /* Texture object in locally shared texture space.
  */
 struct r300_tex_obj {
@@ -178,7 +182,7 @@ struct r300_tex_obj {
        GLuint bufAddr;         /* Offset to start of locally
                                   shared texture block */
 
-       drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
+       drm_radeon_tex_image_t image[6][R300_MAX_TEXTURE_LEVELS];
        /* Six, for the cube faces */
 
        GLboolean image_override;       /* Image overridden by GLX_EXT_tfp */
index b03eefaa7c56afdf20744ebddcd02d97d977fa67..0fe51b0c680e1ec8762d2bccd1dffb070de5b06f 100644 (file)
@@ -306,7 +306,7 @@ static void r300UploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
        ASSERT(face < 6);
 
        /* Ensure we have a valid texture to upload */
-       if ((hwlevel < 0) || (hwlevel >= RADEON_MAX_TEXTURE_LEVELS)) {
+       if ((hwlevel < 0) || (hwlevel >= R300_MAX_TEXTURE_LEVELS)) {
                _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
                return;
        }
index e2329f04ec7ab241d23904cd233472b816a0b863..cadec7f3ecf433212ee948fdca7d5a2456a83750 100644 (file)
@@ -345,7 +345,7 @@ static void r300SetTexImages(r300ContextPtr rmesa,
 
        numLevels = t->base.lastLevel - t->base.firstLevel + 1;
 
-       assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
+       assert(numLevels <= R300_MAX_TEXTURE_LEVELS);
 
        /* Calculate mipmap offsets and dimensions for blitting (uploading)
         * The idea is that we lay out the mipmap levels within a block of