merge r128 DRI driver from DRI trunk
authorAlan Hourihane <alanh@tungstengraphics.com>
Fri, 5 Dec 2003 11:51:39 +0000 (11:51 +0000)
committerAlan Hourihane <alanh@tungstengraphics.com>
Fri, 5 Dec 2003 11:51:39 +0000 (11:51 +0000)
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_context.h
src/mesa/drivers/dri/r128/r128_tex.c

index e1b003a3587729821c98df8511b6f9a54a1b6496..1c7e868ad1fd33ac216875f1cd6501f3a8304aef 100644 (file)
@@ -66,19 +66,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 const char __driConfigOptions[] =
 DRI_CONF_BEGIN
+    DRI_CONF_SECTION_PERFORMANCE
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_QUALITY
+        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+    DRI_CONF_SECTION_END
 #if ENABLE_PERF_BOXES
     DRI_CONF_SECTION_DEBUG
         DRI_CONF_PERFORMANCE_BOXES(false)
     DRI_CONF_SECTION_END
 #endif
-    DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
-    DRI_CONF_SECTION_END
 DRI_CONF_END;
 #if ENABLE_PERF_BOXES
-const GLuint __driNConfigOptions = 2;
+const GLuint __driNConfigOptions = 3;
 #else
-const GLuint __driNConfigOptions = 1;
+const GLuint __driNConfigOptions = 2;
 #endif
 
 #ifndef R128_DEBUG
@@ -176,6 +179,11 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
       driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
                                        & rmesa->c_textureSwaps );
    }
+   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
+                                          "texture_depth");
+   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+      rmesa->texture_depth = ( r128scrn->cpp == 4 ) ?
+        DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
 
 
    rmesa->RenderIndex = -1;            /* Impossible value */
index 453ccb6f537fbe82f05d728970efca84785d1d1e..3a908d7a1b30bef43df30d1fad6b0792453deb44 100644 (file)
@@ -160,6 +160,8 @@ struct r128_context {
    driTextureObject      swapped;
 
    r128TexObjPtr CurrentTexObj[2];
+
+   int texture_depth;
  
    /* Fallback rasterization functions 
     */
index 2793a793a0e7fd516b3010fc7b64c0b44dbde75b..51c55141d805e7c6f41a4340d89209b52f3c8cbc 100644 (file)
@@ -51,6 +51,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "imports.h"
 #include "colormac.h"
 
+#include "xmlpool.h"
+
 #define TEX_0  1
 #define TEX_1  2
 
@@ -174,80 +176,93 @@ r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                          GLenum format, GLenum type )
 {
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
+   const GLboolean do32bpt =
+       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+   const GLboolean force16bpt =
+       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
    (void) format;
    (void) type;
 
    switch ( internalFormat ) {
+   /* non-sized formats with alpha */
+   case GL_INTENSITY:
+   case GL_COMPRESSED_INTENSITY:
    case GL_ALPHA:
-   case GL_ALPHA4:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
    case GL_COMPRESSED_ALPHA:
    case 2:
    case GL_LUMINANCE_ALPHA:
+   case GL_COMPRESSED_LUMINANCE_ALPHA:
+   case 4:
+   case GL_RGBA:
+   case GL_COMPRESSED_RGBA:
+      if (do32bpt)
+         return &_mesa_texformat_argb8888;
+      else
+         return &_mesa_texformat_argb4444;
+
+   /* 16-bit formats with alpha */
+   case GL_INTENSITY4:
+   case GL_ALPHA4:
    case GL_LUMINANCE4_ALPHA4:
+   case GL_RGBA2:
+   case GL_RGBA4:
+      return &_mesa_texformat_argb4444;
+
+   /* 32-bit formats with alpha */
+   case GL_INTENSITY8:
+   case GL_INTENSITY12:
+   case GL_INTENSITY16:
+   case GL_ALPHA8:
+   case GL_ALPHA12:
+   case GL_ALPHA16:
    case GL_LUMINANCE6_ALPHA2:
    case GL_LUMINANCE8_ALPHA8:
    case GL_LUMINANCE12_ALPHA4:
    case GL_LUMINANCE12_ALPHA12:
    case GL_LUMINANCE16_ALPHA16:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-   case GL_RGBA2:
    case GL_RGB5_A1:
    case GL_RGBA8:
    case GL_RGB10_A2:
    case GL_RGBA12:
    case GL_RGBA16:
-      if (rmesa->r128Screen->cpp == 4)
+      if (!force16bpt)
          return &_mesa_texformat_argb8888;
       else
          return &_mesa_texformat_argb4444;
-   case GL_RGBA4:
-         return &_mesa_texformat_argb4444;
 
+   /* non-sized formats without alpha */
+   case 1:
+   case GL_LUMINANCE:
+   case GL_COMPRESSED_LUMINANCE:
    case 3:
    case GL_RGB:
    case GL_COMPRESSED_RGB:
-   case GL_R3_G3_B2:
-   case GL_RGB4:
-   case GL_RGB5:
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      if (rmesa->r128Screen->cpp == 4)
+      if (do32bpt)
          return &_mesa_texformat_argb8888;
       else
          return &_mesa_texformat_rgb565;
 
-   case 1:
-   case GL_LUMINANCE:
+   /* 16-bit formats without alpha */
    case GL_LUMINANCE4:
+   case GL_R3_G3_B2:
+   case GL_RGB4:
+   case GL_RGB5:
+      return &_mesa_texformat_rgb565;
+
+   /* 32-bit formats without alpha */
    case GL_LUMINANCE8:
    case GL_LUMINANCE12:
    case GL_LUMINANCE16:
-   case GL_COMPRESSED_LUMINANCE:
-      if (rmesa->r128Screen->cpp == 4)
-         return &_mesa_texformat_argb8888; /* inefficient but accurate */
+   case GL_RGB8:
+   case GL_RGB10:
+   case GL_RGB12:
+   case GL_RGB16:
+      if (!force16bpt)
+         return &_mesa_texformat_argb8888;
       else
          return &_mesa_texformat_rgb565;
 
-   case GL_INTENSITY4:
-      return &_mesa_texformat_argb4444;
-   case GL_INTENSITY:
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_COMPRESSED_INTENSITY:
-      if (rmesa->r128Screen->cpp == 4)
-         return &_mesa_texformat_argb8888; /* inefficient but accurate */
-      else
-         return &_mesa_texformat_argb4444;
-
+   /* color-indexed formats */
    case GL_COLOR_INDEX:
    case GL_COLOR_INDEX1_EXT:
    case GL_COLOR_INDEX2_EXT: