Attached is a patch that allows the depth of the Radeon depth buffer to
be set to either 16 or 24 bpp (24 bpp actually takes twice the space of
16 bpp, since the format is not packed; the extra byte is used for an
accellerated stencil buffer).  As it is, the driver chooses 16 when the
display depth is 16 and 24 when the display depth is 24.  This might
help some people like me with 16 MB Radeons until there is a better
memory manager.  I went from 960 kB for textures with a 24 bit display
and 24 bpp depth buffer to 3.5 MB with same display but 16 bit depth
buffer.

Add:

Option "DepthBits" "24"

or

Option "DepthBits" "16"

to the Device section.

--Jonathan Thambidurai
? programs/Xserver/hw/xfree86/drivers/ati/radeon.diffs
? programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/.radeon_cp.o.flags
? programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/.radeon_drv.o.flags
? programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/.radeon_irq.o.flags
? programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/.radeon_mem.o.flags
? programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/.radeon_state.o.flags
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon.h
===================================================================
RCS file: /cvs/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h,v
retrieving revision 1.45
diff -u -r1.45 radeon.h
--- programs/Xserver/hw/xfree86/drivers/ati/radeon.h    4 Nov 2003 01:16:53 -0000      
 1.45
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon.h    18 Jan 2004 08:00:03 -0000
@@ -582,6 +582,7 @@
     Bool               NoVirtual;
     Bool               No2048Limit;
 
+    int                 depthBpp;
 } RADEONInfoRec, *RADEONInfoPtr;
 
 
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c
===================================================================
RCS file: /cvs/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c,v
retrieving revision 1.59
diff -u -r1.59 radeon_dri.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        10 Jan 2004 19:03:27 
-0000      1.59
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        18 Jan 2004 08:00:03 
-0000
@@ -165,7 +165,7 @@
                    pConfigs[i].doubleBuffer   = FALSE;
                pConfigs[i].stereo             = FALSE;
                pConfigs[i].bufferSize         = 16;
-               pConfigs[i].depthSize          = 16;
+               pConfigs[i].depthSize          = info->depthBpp;
                if (stencil)
                    pConfigs[i].stencilSize    = 8;
                else
@@ -249,10 +249,10 @@
                pConfigs[i].stereo             = FALSE;
                pConfigs[i].bufferSize         = 32;
                if (stencil) {
-                   pConfigs[i].depthSize      = 24;
+                   pConfigs[i].depthSize      = info->depthBpp;
                    pConfigs[i].stencilSize    = 8;
                } else {
-                   pConfigs[i].depthSize      = 24;
+                   pConfigs[i].depthSize      = info->depthBpp;
                    pConfigs[i].stencilSize    = 0;
                }
                pConfigs[i].auxBuffers         = 0;
@@ -488,7 +488,7 @@
     if (ya < yb) ydir = -1, ystart = h-1, yend = 0;
     else         ydir =  1, ystart = 0,   yend = h-1;
 
-    switch (pScrn->bitsPerPixel) {
+    switch (info->depthBpp) {
     case 16:
        for (x = xstart; x != xend; x += xdir) {
            for (y = ystart; y != yend; y += ydir) {
@@ -498,7 +498,7 @@
        }
        break;
 
-    case 32:
+    case 24:
        for (x = xstart; x != xend; x += xdir) {
            for (y = ystart; y != yend; y += ydir) {
                READ_DEPTH32(d, xa+x, ya+y);
@@ -1037,15 +1037,15 @@
     drmInfo.usec_timeout        = info->CPusecTimeout;
 
     drmInfo.fb_bpp              = info->CurrentLayout.pixel_code;
-    drmInfo.depth_bpp           = info->CurrentLayout.pixel_code;
+    drmInfo.depth_bpp           = (info->depthBpp == 24) ? 32 : 16;
 
     drmInfo.front_offset        = info->frontOffset;
     drmInfo.front_pitch         = info->frontPitch * cpp;
     drmInfo.back_offset         = info->backOffset;
     drmInfo.back_pitch          = info->backPitch * cpp;
     drmInfo.depth_offset        = info->depthOffset;
-    drmInfo.depth_pitch         = info->depthPitch * cpp;
-
+    drmInfo.depth_pitch         = (info->depthBpp == 24) ? 
+      info->depthPitch * 4 : info->depthPitch * 2;
     drmInfo.fb_offset           = info->fbHandle;
     drmInfo.mmio_offset         = info->registerHandle;
     drmInfo.ring_offset         = info->ringHandle;
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c
===================================================================
RCS file: /cvs/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v
retrieving revision 1.84
diff -u -r1.84 radeon_driver.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     11 Jan 2004 19:59:48 
-0000      1.84
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     18 Jan 2004 08:00:05 
-0000
@@ -154,7 +154,8 @@
     OPTION_CRT2ISSCRN0,
     OPTION_DISP_PRIORITY,
     OPTION_PANEL_SIZE,
-    OPTION_NO2048LIMIT
+    OPTION_NO2048LIMIT,
+    OPTION_DEPTHBITS
 } RADEONOpts;
 
 const OptionInfoRec RADEONOptions[] = {
@@ -193,6 +194,7 @@
     { OPTION_DISP_PRIORITY,  "DisplayPriority",  OPTV_ANYSTR,  {0}, FALSE },
     { OPTION_PANEL_SIZE,     "PanelSize",        OPTV_ANYSTR,  {0}, FALSE },
     { OPTION_NO2048LIMIT,    "No2048Limit",      OPTV_BOOLEAN, {0}, FALSE },
+    { OPTION_DEPTHBITS,      "DepthBits",        OPTV_INTEGER, {0}, FALSE },
     { -1,                    NULL,               OPTV_NONE,    {0}, FALSE }
 };
 
@@ -4356,6 +4358,31 @@
                          pScrn->defaultVisual)) return FALSE;
     miSetPixmapDepths ();
 
+    {
+      int depthBits = 0;
+
+      if (info->CurrentLayout.pixel_bytes == 2)
+       info->depthBpp = 16;
+      else if (info->CurrentLayout.pixel_bytes == 4)
+       info->depthBpp = 24;
+
+      if (xf86GetOptValInteger(info->Options,
+                            OPTION_DEPTHBITS, &depthBits))
+       {
+         if (depthBits == 16 || depthBits == 24) 
+         {
+           xf86DrvMsg (pScrn->scrnIndex, X_CONFIG,
+                       "Will use %d bit depth buffer\n", depthBits);
+           info->depthBpp = depthBits;
+         }
+       else
+         {
+           xf86DrvMsg (pScrn->scrnIndex, X_WARNING,
+                       "Invalid specifed depth bpp (must be 16 or 24)\n");
+         }
+       }
+    }
+
 #ifdef XF86DRI
                                /* Setup DRI after visuals have been
                                   established, but before fbScreenInit is
@@ -4482,6 +4509,18 @@
        int        l;
        int        scanlines;
 
+
+
+       /* account for DepthBits option */
+       if (info->CurrentLayout.pixel_bytes == 2 && info->depthBpp == 24)
+         depthSize = ((((pScrn->virtualY+15) & ~15) * width_bytes*2
+                       + RADEON_BUFFER_ALIGN)
+                      & ~RADEON_BUFFER_ALIGN);
+       else if (info->CurrentLayout.pixel_bytes == 4 && info->depthBpp == 16)
+         depthSize = ((((pScrn->virtualY+15) & ~15) * width_bytes/2
+                       + RADEON_BUFFER_ALIGN)
+                      & ~RADEON_BUFFER_ALIGN);
+
        info->frontOffset = 0;
        info->frontPitch = pScrn->displayWidth;
 

Reply via email to