sync some more of the r200 driver from the DRI trunk
authorAlan Hourihane <alanh@tungstengraphics.com>
Sun, 7 Dec 2003 23:47:56 +0000 (23:47 +0000)
committerAlan Hourihane <alanh@tungstengraphics.com>
Sun, 7 Dec 2003 23:47:56 +0000 (23:47 +0000)
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r200/r200_context.h
src/mesa/drivers/dri/r200/r200_ioctl.c
src/mesa/drivers/dri/r200/r200_lock.c
src/mesa/drivers/dri/r200/r200_pixel.c
src/mesa/drivers/dri/r200/r200_screen.c
src/mesa/drivers/dri/r200/r200_screen.h
src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/r200/r200_state_init.c

index b0a3ca8c35691aa8ea54189bba7c25f7f98fd196..c08c411e22dc93de250f32f0525528599fd628a2 100644 (file)
@@ -68,11 +68,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 int R200_DEBUG = (0);
 #endif
 
+
 /* R200 configuration
  */
 #include "xmlpool.h"
 
-
 const char __driConfigOptions[] =
 DRI_CONF_BEGIN
     DRI_CONF_SECTION_PERFORMANCE
@@ -246,7 +246,7 @@ static const struct dri_debug_control debug_control[] =
 
 
 static int
-get_ust_nop( uint64_t * ust )
+get_ust_nop( int64_t * ust )
 {
    *ust = 1;
    return 0;
@@ -264,7 +264,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    r200ContextPtr rmesa;
    GLcontext *ctx, *shareCtx;
    int i;
-   int tcl_mode, fthrottle_mode, preferred_bpt;
+   int tcl_mode, fthrottle_mode;
 
    assert(glVisual);
    assert(driContextPriv);
@@ -299,6 +299,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    /* Parse configuration files */
    driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
                        screen->driScreen->myNum, "r200");
+
    rmesa->r200Screen = screen;
    rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
                                       screen->sarea_priv_offset);
index ebb1b8c215f88f1344cd36ea3339a5dcd54216d0..0b2ce111f26efe24a48068d0e6709924e2769b59 100644 (file)
@@ -96,6 +96,7 @@ typedef void (*r200_point_func)( r200ContextPtr,
 struct r200_colorbuffer_state {
    GLuint clear;
    GLint drawOffset, drawPitch;
+   int roundEnable;
 };
 
 
index af7c3a0e629fc60d318e4e248933411ee2d1b15a..fbfdd6374dd91cf284bcaefd92abb3d6d88ad1a1 100644 (file)
@@ -319,7 +319,7 @@ static CARD32 r200GetLastFrame(r200ContextPtr rmesa)
    CARD32 frame;
 
    gp.param = RADEON_PARAM_LAST_FRAME;
-   gp.value = &frame;
+   gp.value = (int *)&frame;
    ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
                              &gp, sizeof(gp) );
    if ( ret ) {
@@ -403,7 +403,7 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv )
    r200ContextPtr rmesa;
    GLint nbox, i, ret;
    GLboolean   missed_target;
-   uint64_t     ust;
+   int64_t     ust;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -534,7 +534,8 @@ void r200PageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    R200_STATECHANGE( rmesa, ctx );
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset;
+   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+                                          + rmesa->r200Screen->fbLocation;
    rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH]  = rmesa->state.color.drawPitch;
 }
 
@@ -615,7 +616,7 @@ static void r200Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
       int clear;
 
       gp.param = RADEON_PARAM_LAST_CLEAR;
-      gp.value = &clear;
+      gp.value = (int *)&clear;
       ret = drmCommandWriteRead( rmesa->dri.fd,
                      DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
 
index 9d6cff50ae4e0c639d1c429bf2941431d95d3b69..3c3356eecb8c487e354d3fa80b4005f77bb8ca08 100644 (file)
@@ -64,7 +64,8 @@ r200UpdatePageFlipping( r200ContextPtr rmesa )
    }
 
    R200_STATECHANGE( rmesa, ctx );
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset;
+   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+                                          + rmesa->r200Screen->fbLocation;
    rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH]  = rmesa->state.color.drawPitch;
 }
 
index 29eab6cd2fb3415d576ecd850d96b9034ac2a857..806484404d67c57c75e5f5b3d5b11524c21ddb80 100644 (file)
@@ -215,7 +215,8 @@ r200TryReadPixels( GLcontext *ctx,
    {
       __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
       int nbox = dPriv->numClipRects;
-      int src_offset = rmesa->state.color.drawOffset;
+      int src_offset = rmesa->state.color.drawOffset
+                    + rmesa->r200Screen->fbLocation;
       int src_pitch = rmesa->state.color.drawPitch * rmesa->r200Screen->cpp;
       int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
       int dst_pitch = pitch * rmesa->r200Screen->cpp;
@@ -288,7 +289,7 @@ static void do_draw_pix( GLcontext *ctx,
                         GLint x, GLint y, GLsizei width, GLsizei height,
                         GLint pitch,
                         const void *pixels,
-                        GLuint dest, GLuint planemask)
+                        GLuint planemask)
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
@@ -354,7 +355,7 @@ static void do_draw_pix( GLcontext *ctx,
                    blit_format,
                    src_pitch, src_offset,
                    rmesa->state.color.drawPitch * rmesa->r200Screen->cpp,
-                   rmesa->state.color.drawOffset,
+                   rmesa->state.color.drawOffset + rmesa->r200Screen->fbLocation,
                    bx - x, by - y,
                    bx, by,
                    bw, bh );
@@ -377,7 +378,7 @@ r200TryDrawPixels( GLcontext *ctx,
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLint pitch = unpack->RowLength ? unpack->RowLength : width;
-   GLuint dest, planemask;
+   GLuint planemask;
    GLuint cpp = rmesa->r200Screen->cpp;
    GLint size = width * pitch * cpp;
 
@@ -388,8 +389,6 @@ r200TryDrawPixels( GLcontext *ctx,
    case GL_RGB:
    case GL_RGBA:
    case GL_BGRA:
-      dest = rmesa->state.color.drawOffset;
-
       planemask = r200PackColor(cpp,
                                ctx->Color.ColorMask[RCOMP],
                                ctx->Color.ColorMask[GCOMP],
@@ -428,8 +427,7 @@ r200TryDrawPixels( GLcontext *ctx,
 
    if ( r200IsGartMemory(rmesa, pixels, size) )
    {
-      do_draw_pix( ctx, x, y, width, height, pitch, pixels,
-                  dest, planemask );
+      do_draw_pix( ctx, x, y, width, height, pitch, pixels, planemask );
       return GL_TRUE;
    }
    else if (0)
index 4216046d1989973de11de27b2980dfad357c6dc9..fe246686a0154c9d7520c8904ccde127bb743d51 100644 (file)
@@ -76,6 +76,7 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
 {
    r200ScreenPtr screen;
    RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
+   unsigned char *RADEONMMIO;
 
    if ( ! driCheckDriDdxDrmVersions( sPriv, "R200", 4, 0, 4, 0, 1, 5 ) )
       return NULL;
@@ -193,8 +194,9 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
       return NULL;
    }
 
+   RADEONMMIO = screen->mmio.map;
+
    if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
-      unsigned char *RADEONMMIO = screen->mmio.map;
 
       screen->gartTextures.handle = dri_priv->gartTexHandle;
       screen->gartTextures.size   = dri_priv->gartTexMapSize;
@@ -218,6 +220,18 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
    screen->cpp = dri_priv->bpp / 8;
    screen->AGPMode = dri_priv->AGPMode;
 
+   screen->fbLocation  = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16;
+
+   if ( sPriv->drmMinor >= 10 ) {
+      drmRadeonSetParam sp;
+
+      sp.param = RADEON_SETPARAM_FB_LOCATION;
+      sp.value = screen->fbLocation;
+
+      drmCommandWrite( sPriv->fd, DRM_RADEON_SETPARAM,
+                      &sp, sizeof( sp ) );
+   }
+
    screen->frontOffset = dri_priv->frontOffset;
    screen->frontPitch  = dri_priv->frontPitch;
    screen->backOffset  = dri_priv->backOffset;
@@ -225,7 +239,8 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
    screen->depthOffset = dri_priv->depthOffset;
    screen->depthPitch  = dri_priv->depthPitch;
 
-   screen->texOffset[RADEON_CARD_HEAP] = dri_priv->textureOffset;
+   screen->texOffset[RADEON_CARD_HEAP] = dri_priv->textureOffset
+                                      + screen->fbLocation;
    screen->texSize[RADEON_CARD_HEAP] = dri_priv->textureSize;
    screen->logTexGranularity[RADEON_CARD_HEAP] =
       dri_priv->log2TexGran;
index 3ed4f5502820859521e96c2c140c68151e520a37..6b12227ec5456c7c491229952fd9769775abbfef 100644 (file)
@@ -64,6 +64,7 @@ typedef struct {
    int AGPMode;
    unsigned int irq;                   /* IRQ number (0 means none) */
 
+   unsigned int fbLocation;
    unsigned int frontOffset;
    unsigned int frontPitch;
    unsigned int backOffset;
index 27dc6fd1f2bab7aa12ebdf710d78d7525ead9a0e..2a3df39be03fce9d0ca7dd6d7a3b144c902dc480 100644 (file)
@@ -1623,8 +1623,9 @@ static void r200DrawBuffer( GLcontext *ctx, GLenum mode )
    _swrast_DrawBuffer(ctx, mode);
 
    R200_STATECHANGE( rmesa, ctx );
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = (rmesa->state.color.drawOffset &
-                                           R200_COLOROFFSET_MASK);
+   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+                                              rmesa->r200Screen->fbLocation)
+                                             & R200_COLOROFFSET_MASK);
    rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
 }
 
@@ -1719,8 +1720,10 @@ static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
       R200_STATECHANGE(rmesa, ctx );
       if ( state ) {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_DITHER_ENABLE;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable;
       } else {
         rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_DITHER_ENABLE;
+        rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  rmesa->state.color.roundEnable;
       }
       break;
 
index 4c9a69f79d2bef39f0fed433ec96b0ea375c411e..f7dfcff8b6caeea0f68b265f512e70cf0aab74ed 100644 (file)
@@ -52,6 +52,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_swtcl.h"
 #include "r200_vtxfmt.h"
 
+#include "xmlpool.h"
+
 /* =============================================================
  * State initialization
  */
@@ -363,7 +365,7 @@ void r200InitState( r200ContextPtr rmesa )
                                            R200_DST_BLEND_GL_ZERO );
 
    rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHOFFSET] =
-      rmesa->r200Screen->depthOffset;
+      rmesa->r200Screen->depthOffset + rmesa->r200Screen->fbLocation;
 
    rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] = 
       ((rmesa->r200Screen->depthPitch &
@@ -382,10 +384,28 @@ void r200InitState( r200ContextPtr rmesa )
                                     | R200_TEX_BLEND_0_ENABLE);
 
    rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = color_fmt;
-   rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |=  R200_DITHER_ENABLE;
-
-   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = (rmesa->state.color.drawOffset &
-                                             R200_COLOROFFSET_MASK);
+   switch ( driQueryOptioni( &rmesa->optionCache, "dither_mode" ) ) {
+   case DRI_CONF_DITHER_XERRORDIFFRESET:
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_INIT;
+      break;
+   case DRI_CONF_DITHER_ORDERED:
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_SCALE_DITHER_ENABLE;
+      break;
+   }
+   if ( driQueryOptioni( &rmesa->optionCache, "round_mode" ) ==
+       DRI_CONF_ROUND_ROUND )
+      rmesa->state.color.roundEnable = R200_ROUND_ENABLE;
+   else
+      rmesa->state.color.roundEnable = 0;
+   if ( driQueryOptioni (&rmesa->optionCache, "color_reduction" ) ==
+       DRI_CONF_COLOR_REDUCTION_DITHER )
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_ENABLE;
+   else
+      rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+
+   rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+                                              rmesa->r200Screen->fbLocation)
+                                             & R200_COLOROFFSET_MASK);
 
    rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((rmesa->state.color.drawPitch &
                                              R200_COLORPITCH_MASK) |
@@ -470,7 +490,8 @@ void r200InitState( r200ContextPtr rmesa )
          ((i << R200_TXFORMAT_ST_ROUTE_SHIFT) |  /* <-- note i */
           (2 << R200_TXFORMAT_WIDTH_SHIFT) |
           (2 << R200_TXFORMAT_HEIGHT_SHIFT));
-      rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] = 0;
+      rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] =
+         rmesa->r200Screen->texOffset[RADEON_CARD_HEAP];
       rmesa->hw.tex[i].cmd[TEX_PP_BORDER_COLOR] = 0;
       rmesa->hw.tex[i].cmd[TEX_PP_TXFORMAT_X] =
          (/* R200_TEXCOORD_PROJ | */