Added configuration support to the Savage driver. Three options are
authorFelix Kuehling <fxkuehl@gmx.de>
Wed, 15 Dec 2004 17:45:23 +0000 (17:45 +0000)
committerFelix Kuehling <fxkuehl@gmx.de>
Wed, 15 Dec 2004 17:45:23 +0000 (17:45 +0000)
supported so far.

src/mesa/drivers/dri/savage/savage_init.h
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagecontext.h
src/mesa/drivers/dri/savage/savagestate.c
src/mesa/drivers/dri/savage/savagetex.c

index f632c91f073fffa9c1919a81b30d5aabbbd7e62e..1454b6b36c851399fc94dc41f3a6eec1f063a11e 100644 (file)
@@ -32,6 +32,8 @@
 #include "dri_util.h"
 #include "mtypes.h"
 
+#include "xmlconfig.h"
+
 typedef struct {
    drm_handle_t handle;
    drmSize size;
@@ -76,6 +78,9 @@ typedef struct {
   drmBufMapPtr  bufs;
   int use_copy_buf;
   unsigned int sarea_priv_offset;
+
+   /* Configuration cache with default values for all contexts */
+   driOptionCache optionCache;
 } savageScreenPrivate;
 
 
index c8eb69160f8d632500d7d4f085a2ac14bf07b998..5bbc7c5ba1adf814630ddb80813835d98a26e673 100644 (file)
 
 #include "savagedma.h"
 
+#include "xmlpool.h"
+
+/* Configuration
+ */
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_QUALITY
+        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+        DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+    DRI_CONF_SECTION_END
+    DRI_CONF_SECTION_PERFORMANCE
+        DRI_CONF_MAX_TEXTURE_UNITS(2,1,2)
+    DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 3;
+
 #ifdef USE_NEW_INTERFACE
 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
 #endif /* USE_NEW_INTERFACE */
@@ -202,6 +218,10 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
       return GL_FALSE;
    } 
       
+   /* parse information in __driConfigOptions */
+   driParseOptionInfo (&savageScreen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
+
 #if 0
    savageDDFastPathInit();
    savageDDTrifuncInit();
@@ -217,7 +237,9 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
 {
    savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
 
-   
+   /* free all option information */
+   driDestroyOptionInfo (&savageScreen->optionCache);
+
    Xfree(savageScreen);
    sPriv->private = NULL;
 }
@@ -287,10 +309,24 @@ savageCreateContext( const __GLcontextModes *mesaVis,
    }
    driContextPriv->driverPrivate = imesa;
 
+   /* Parse configuration files */
+   driParseConfigFiles (&imesa->optionCache, &savageScreen->optionCache,
+                        sPriv->myNum, "savage");
+
+   imesa->texture_depth = driQueryOptioni (&imesa->optionCache,
+                                          "texture_depth");
+   if (imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+       imesa->texture_depth = ( savageScreen->cpp == 4 ) ?
+          DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
    if (savageScreen->chipset >= S3_SAVAGE4)
        ctx->Const.MaxTextureUnits = 2;
    else
        ctx->Const.MaxTextureUnits = 1;
+   if (driQueryOptioni(&imesa->optionCache, "texture_units") <
+       ctx->Const.MaxTextureUnits)
+       ctx->Const.MaxTextureUnits =
+          driQueryOptioni(&imesa->optionCache, "texture_units");
    ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
    ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
 
index 5ea40cea4b6a32a413cdf883bc4aa703c20bbe86..501b98adc138be2bdc33634fa12b2af2e7ce6eef 100644 (file)
@@ -44,6 +44,8 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
 #include "savagetex.h"
 #include "savagedma.h"
 
+#include "xmlconfig.h"
+
 /* Reasons to fallback on all primitives.
  */
 #define SAVAGE_FALLBACK_TEXTURE        0x1
@@ -259,6 +261,11 @@ struct savage_context_t {
     volatile GLuint *eventTag1;
     GLuint shadowCounter;
     GLboolean shadowStatus;
+
+    /* Configuration cache
+     */
+    driOptionCache optionCache;
+    int texture_depth;
 };
 
 #define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx))
index 04d8f0870cbe228809f6fd1c79bd17b1c0c9e732..f4f22602d8d5cb388801b122a396d0a030f6b1f0 100644 (file)
@@ -46,6 +46,8 @@
 #include "tnl/tnl.h"
 #include "swrast_setup/swrast_setup.h"
 
+#include "xmlpool.h"
+
 static void savageBlendFunc_s4(GLcontext *);
 static void savageBlendFunc_s3d(GLcontext *);
 
@@ -1619,7 +1621,9 @@ static void savageDDInitState_s4( savageContextPtr imesa )
     imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE;
 
     imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn= GL_TRUE;
-    imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_TRUE;
+    imesa->regs.s4.drawCtrl1.ni.ditherEn = (
+       driQueryOptioni(&imesa->optionCache, "color_reduction") ==
+       DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE;
     imesa->regs.s4.drawCtrl1.ni.cullMode             = BCM_None;
 
     imesa->regs.s4.zBufCtrl.ni.stencilRefVal      = 0x00;
@@ -1684,7 +1688,9 @@ static void savageDDInitState_s3d( savageContextPtr imesa )
     imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
     imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
 
-    imesa->regs.s3d.drawCtrl.ni.ditherEn          = GL_TRUE;
+    imesa->regs.s3d.drawCtrl.ni.ditherEn =  (
+       driQueryOptioni(&imesa->optionCache, "color_reduction") ==
+       DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE;
     imesa->regs.s3d.drawCtrl.ni.cullMode          = BCM_None;
 
     imesa->LcsCullMode = BCM_None;
index edb016f1523772b7a5029412677ff0e1a0c709aa..ade318cdc9f63a9907cd66421dbfba9f360b92d3 100644 (file)
@@ -44,6 +44,8 @@
 
 #include "swrast/swrast.h"
 
+#include "xmlpool.h"
+
 /* Size 1, 2 and 4 images are packed into the last subtile. Each image
  * is repeated to fill a 4x4 pixel area. The figure below shows the
  * layout of those 4x4 pixel areas in the 8x8 subtile.
@@ -325,8 +327,10 @@ savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
                           GLenum format, GLenum type )
 {
    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-   const GLboolean do32bpt = GL_FALSE;
-   const GLboolean force16bpt = GL_FALSE;
+   const GLboolean do32bpt =
+       ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+   const GLboolean force16bpt =
+       ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
    const GLboolean isSavage4 = (imesa->savageScreen->chipset >= S3_SAVAGE4);
    (void) format;
    (void) type;