st/xorg: start adding support for surface fills
authorZack Rusin <zackr@vmware.com>
Wed, 9 Sep 2009 09:34:56 +0000 (05:34 -0400)
committerZack Rusin <zackr@vmware.com>
Thu, 10 Sep 2009 21:21:06 +0000 (17:21 -0400)
src/gallium/state_trackers/xorg/xorg_composite.c
src/gallium/state_trackers/xorg/xorg_composite.h
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xorg_exa.h
src/gallium/state_trackers/xorg/xorg_exa_tgsi.c

index c708ac317029443f1faf269d15ca6eece1121a23..1f8fbd16103ce7c4e1515ffc0f0408464da5a101 100644 (file)
@@ -41,8 +41,8 @@ static const struct xorg_composite_blend xorg_blends[] = {
 };
 
 static INLINE void
-pixel_to_float4(PictFormatPtr format,
-                CARD32 pixel, float *color)
+render_pixel_to_float4(PictFormatPtr format,
+                       CARD32 pixel, float *color)
 {
    CARD32          r, g, b, a;
 
@@ -291,16 +291,15 @@ boolean xorg_composite_accelerated(int op,
 }
 
 static void
-bind_framebuffer_state(struct exa_context *exa, PicturePtr pDstPicture,
-                       struct exa_pixmap_priv *pDst)
+bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
 {
    unsigned i;
    struct pipe_framebuffer_state state;
    struct pipe_surface *surface = exa_gpu_surface(exa, pDst);
    memset(&state, 0, sizeof(struct pipe_framebuffer_state));
 
-   state.width  = pDstPicture->pDrawable->width;
-   state.height = pDstPicture->pDrawable->height;
+   state.width  = pDst->tex->width[0];
+   state.height = pDst->tex->height[0];
 
    state.nr_cbufs = 1;
    state.cbufs[0] = surface;
@@ -338,10 +337,10 @@ set_viewport(struct exa_context *exa, int width, int height,
 }
 
 static void
-bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture)
+bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
 {
-   int width = pDstPicture->pDrawable->width;
-   int height = pDstPicture->pDrawable->height;
+   int width = pDst->tex->width[0];
+   int height = pDst->tex->height[0];
 
    set_viewport(exa, width, height, Y0_TOP);
 }
@@ -395,9 +394,9 @@ bind_shaders(struct exa_context *exa, int op,
          if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
             fs_traits |= FS_SOLID_FILL;
             vs_traits |= VS_SOLID_FILL;
-            pixel_to_float4(pSrcPicture->pFormat,
-                            pSrcPicture->pSourcePict->solidFill.color,
-                            exa->solid_color);
+            render_pixel_to_float4(pSrcPicture->pFormat,
+                                   pSrcPicture->pSourcePict->solidFill.color,
+                                   exa->solid_color);
          } else {
             debug_assert("!gradients not supported");
          }
@@ -530,8 +529,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
                                   struct exa_pixmap_priv *pMask,
                                   struct exa_pixmap_priv *pDst)
 {
-   bind_framebuffer_state(exa, pDstPicture, pDst);
-   bind_viewport_state(exa, pDstPicture);
+   bind_framebuffer_state(exa, pDst);
+   bind_viewport_state(exa, pDst);
    bind_blend_state(exa, op, pSrcPicture, pMaskPicture);
    bind_rasterizer_state(exa);
    bind_shaders(exa, op, pSrcPicture, pMaskPicture);
@@ -582,3 +581,17 @@ void xorg_composite(struct exa_context *exa,
    }
 }
 
+boolean xorg_solid_bind_state(struct exa_context *exa,
+                              struct exa_pixmap_priv *pixmap,
+                              Pixel fg)
+{
+   
+   return TRUE;
+}
+
+void xorg_solid(struct exa_context *exa,
+                struct exa_pixmap_priv *pixmap,
+                int x0, int y0, int x1, int y1)
+{
+}
+
index 17dfcb199ea71468f920814177bbbfceec643b84..236addf1ce485602f452e79a717bb819e1353130 100644 (file)
@@ -22,4 +22,11 @@ void xorg_composite(struct exa_context *exa,
                     int srcX, int srcY, int maskX, int maskY,
                     int dstX, int dstY, int width, int height);
 
+boolean xorg_solid_bind_state(struct exa_context *exa,
+                              struct exa_pixmap_priv *pixmap,
+                              Pixel fg);
+void xorg_solid(struct exa_context *exa,
+                struct exa_pixmap_priv *pixmap,
+                int x0, int y0, int x1, int y1);
+
 #endif
index 1a183de6db6e4cea54f268dc300551ea9fa8e163..cf4478a03d4f7d223651f822e46af620ea60360d 100644 (file)
@@ -82,6 +82,22 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
     }
 }
 
+
+static INLINE void
+pixel_to_float4(Pixel pixel, float *color)
+{
+   CARD32          r, g, b, a;
+
+   a = (pixel >> 24) & 0xff;
+   r = (pixel >> 16) & 0xff;
+   g = (pixel >>  8) & 0xff;
+   b = (pixel >>  0) & 0xff;
+   color[0] = ((float)r) / 255.;
+   color[1] = ((float)g) / 255.;
+   color[2] = ((float)b) / 255.;
+   color[3] = ((float)a) / 255.;
+}
+
 /*
  * Static exported EXA functions
  */
@@ -250,6 +266,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
     struct exa_context *exa = ms->exa;
 
+    debug_printf("ExaPrepareSolid\n");
     if (pPixmap->drawable.depth < 15)
        return FALSE;
 
@@ -262,12 +279,10 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
     if (alu != GXcopy)
        return FALSE;
 
-    if (!exa->ctx || !exa->ctx->surface_fill)
+    if (!exa->ctx)
        return FALSE;
 
-    priv->color = fg;
-
-    return TRUE;
+    return xorg_solid_bind_state(exa, priv, fg);
 }
 
 static void
@@ -277,12 +292,9 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
     modesettingPtr ms = modesettingPTR(pScrn);
     struct exa_context *exa = ms->exa;
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
-    struct pipe_surface *surf = exa_gpu_surface(exa, priv);
 
-    exa->ctx->surface_fill(exa->ctx, surf, x0, y0, x1 - x0, y1 - y0,
-                          priv->color);
-
-    exa->scrn->tex_surface_destroy(surf);
+    debug_printf("\tExaSolid\n");
+    xorg_solid(exa, priv, x0, y0, x1, y1) ;
 }
 
 static Bool
@@ -295,6 +307,8 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
     struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap);
 
+    debug_printf("ExaPrepareCopy\n");
+
     if (alu != GXcopy)
        return FALSE;
 
@@ -328,6 +342,8 @@ ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap);
     struct pipe_surface *surf = exa_gpu_surface(exa, priv);
 
+    debug_printf("\tExaCopy\n");
+
     exa->ctx->surface_copy(exa->ctx, surf, dstX, dstY, priv->src_surf,
                           srcX, srcY, width, height);
     exa->scrn->tex_surface_destroy(surf);
@@ -342,6 +358,8 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
    modesettingPtr ms = modesettingPTR(pScrn);
    struct exa_context *exa = ms->exa;
 
+    debug_printf("ExaPrepareComposite\n");
+
    return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture,
                                     pDstPicture,
                                     exaGetPixmapDriverPrivate(pSrc),
@@ -358,6 +376,8 @@ ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
    struct exa_context *exa = ms->exa;
    struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst);
 
+    debug_printf("\tExaComposite\n");
+
    xorg_composite(exa, priv, srcX, srcY, maskX, maskY,
                   dstX, dstY, width, height);
 }
index 5b515be1397d85f54dc707eb789468bef7008c19..a62c57bf4a3a0d08a47d7065d082a35ce6157638 100644 (file)
@@ -36,7 +36,7 @@ struct exa_pixmap_priv
 
    struct pipe_texture *tex;
    struct pipe_texture *depth_stencil_tex;
-   unsigned int color;
+   float solid_color[4];
    struct pipe_surface *src_surf; /* for copies */
 
    struct pipe_transfer *map_transfer;
index cfee10c3b30ed79ed9853dbe57b9f64395f56661..14d5605f3920c19a593bc4138a7fc5c0a5f17cf3 100644 (file)
@@ -318,8 +318,8 @@ create_fs(struct pipe_context *pipe,
                                      TGSI_SEMANTIC_POSITION,
                                      0,
                                      TGSI_INTERPOLATE_PERSPECTIVE);
-   }
-   if (is_fill) {
+   } else {
+      debug_assert(is_fill);
       if (is_solid)
          src_input = ureg_DECL_fs_input(ureg,
                                         TGSI_SEMANTIC_COLOR,