u_blitter: add a custom blitter call passing a dsa cso
authorDave Airlie <airlied@redhat.com>
Thu, 23 Sep 2010 04:18:22 +0000 (14:18 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 23 Sep 2010 06:00:16 +0000 (16:00 +1000)
reimplement the flush stage added for r300 to allow a custom DSA stage
to be used in the pipeline, this allows for r600 hw DB->CB flushes.

src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h

index f93ef26ae73c182a7f2918b358be26906a377dfa..c160716e6a76f36b37dd7d974acc6347450c17a7 100644 (file)
@@ -964,16 +964,18 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
    blitter_restore_CSOs(ctx);
 }
 
-/* Clear a region of a depth stencil surface. */
-void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
-                                      struct pipe_surface *dstsurf)
+/* draw a rectangle across a region using a custom dsa stage - for r600g */
+void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
+                                      struct pipe_surface *zsurf,
+                                      struct pipe_surface *cbsurf,
+                                      void *dsa_stage, float depth)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->base.pipe;
    struct pipe_framebuffer_state fb_state;
 
-   assert(dstsurf->texture);
-   if (!dstsurf->texture)
+   assert(zsurf->texture);
+   if (!zsurf->texture)
       return;
 
    /* check the saved state */
@@ -981,8 +983,8 @@ void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
    assert(blitter->saved_fb_state.nr_cbufs != ~0);
 
    /* bind CSOs */
-   pipe->bind_blend_state(pipe, ctx->blend_keep_color);
-   pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_flush_depth_stencil);
+   pipe->bind_blend_state(pipe, ctx->blend_write_color);
+   pipe->bind_depth_stencil_alpha_state(pipe, dsa_stage);
 
    pipe->bind_rasterizer_state(pipe, ctx->rs_state);
    pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0));
@@ -990,15 +992,30 @@ void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
    pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
 
    /* set a framebuffer state */
-   fb_state.width = dstsurf->width;
-   fb_state.height = dstsurf->height;
-   fb_state.nr_cbufs = 0;
-   fb_state.cbufs[0] = 0;
-   fb_state.zsbuf = dstsurf;
+   fb_state.width = zsurf->width;
+   fb_state.height = zsurf->height;
+   fb_state.nr_cbufs = 1;
+   if (cbsurf) {
+          fb_state.cbufs[0] = cbsurf;
+          fb_state.nr_cbufs = 1;
+   } else {
+          fb_state.cbufs[0] = NULL;
+          fb_state.nr_cbufs = 0;
+   }
+   fb_state.zsbuf = zsurf;
    pipe->set_framebuffer_state(pipe, &fb_state);
 
-   blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
-   blitter->draw_rectangle(blitter, 0, 0, dstsurf->width, dstsurf->height, 0,
+   blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
+   blitter->draw_rectangle(blitter, 0, 0, zsurf->width, zsurf->height, depth,
                            UTIL_BLITTER_ATTRIB_NONE, NULL);
    blitter_restore_CSOs(ctx);
 }
+
+/* flush a region of a depth stencil surface for r300g */
+void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
+                                      struct pipe_surface *dstsurf)
+{
+       struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+       util_blitter_custom_depth_stencil(blitter, dstsurf, NULL,
+                                         ctx->dsa_flush_depth_stencil, 0.0f);
+}
index e33d2e283f8072606fb3c61df816b6569e523ee4..f9f96f25c77e28cc1b2455173bb5f2a562b7d50a 100644 (file)
@@ -203,6 +203,12 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
 
 void util_blitter_flush_depth_stencil(struct blitter_context *blitter,
                                       struct pipe_surface *dstsurf);
+
+void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
+                                      struct pipe_surface *zsurf,
+                                      struct pipe_surface *cbsurf,
+                                      void *dsa_stage, float depth);
+
 /* The functions below should be used to save currently bound constant state
  * objects inside a driver. The objects are automatically restored at the end
  * of the util_blitter_{clear, copy_region, fill_region} functions and then