r300g,util: remove pipe_surface from the util_blitter_fill interface and clean up
authorMarek Olšák <maraeo@gmail.com>
Tue, 25 May 2010 19:28:19 +0000 (21:28 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 25 May 2010 21:32:25 +0000 (23:32 +0200)
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_blit.h
src/gallium/drivers/r300/r300_context.c

index c2d1af372c7b6240c38eee7f98c160f7bc499f6f..7c08ebc5767f1b7a7c200363d12257b2f90b4118 100644 (file)
@@ -715,10 +715,8 @@ static void util_blitter_do_copy(struct blitter_context *blitter,
 
    blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, dst->width, dst->height, 0);
    blitter_draw_quad(ctx);
-
 }
 
-
 void util_blitter_copy(struct blitter_context *blitter,
                        struct pipe_surface *dst,
                        unsigned dstx, unsigned dsty,
@@ -775,38 +773,41 @@ void util_blitter_copy(struct blitter_context *blitter,
    blitter_restore_CSOs(ctx);
 }
 
-void util_blitter_fill(struct blitter_context *blitter,
-                       struct pipe_surface *dst,
-                       unsigned dstx, unsigned dsty,
-                       unsigned width, unsigned height,
-                       unsigned value)
+/* Fill a region of a surface with a constant value. */
+void util_blitter_fill_region(struct blitter_context *blitter,
+                              struct pipe_resource *dst,
+                              struct pipe_subresource subdst,
+                              unsigned dstx, unsigned dsty, unsigned dstz,
+                              unsigned width, unsigned height,
+                              unsigned value)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_screen *screen = pipe->screen;
+   struct pipe_surface *dstsurf;
    struct pipe_framebuffer_state fb_state;
    float rgba[4];
    ubyte ub_rgba[4] = {0};
    union util_color color;
    int i;
 
-   assert(dst->texture);
-   if (!dst->texture)
+   assert(dst);
+   if (!dst)
       return;
 
    /* check if we can render to the surface */
    if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
-       !screen->is_format_supported(screen, dst->format, dst->texture->target,
-                                    dst->texture->nr_samples,
+       !screen->is_format_supported(screen, dst->format, dst->target,
+                                    dst->nr_samples,
                                     PIPE_BIND_RENDER_TARGET, 0)) {
-      struct pipe_subresource subdst;
-      subdst.face = dst->face;
-      subdst.level = dst->level;
-      util_resource_fill_region(pipe, dst->texture, subdst, dstx, dsty,
-                                dst->zslice, width, height, value);
+      util_resource_fill_region(pipe, dst, subdst, dstx, dsty, dstz,
+                                width, height, value);
       return;
    }
 
+   dstsurf = screen->get_tex_surface(screen, dst, subdst.face, subdst.level,
+                                     dstz, PIPE_BIND_RENDER_TARGET);
+
    /* unpack the color */
    color.ui = value;
    util_unpack_color_ub(dst->format, &color,
@@ -827,15 +828,17 @@ void util_blitter_fill(struct blitter_context *blitter,
    pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
 
    /* set a framebuffer state */
-   fb_state.width = dst->width;
-   fb_state.height = dst->height;
+   fb_state.width = dstsurf->width;
+   fb_state.height = dstsurf->height;
    fb_state.nr_cbufs = 1;
-   fb_state.cbufs[0] = dst;
+   fb_state.cbufs[0] = dstsurf;
    fb_state.zsbuf = 0;
    pipe->set_framebuffer_state(pipe, &fb_state);
 
    blitter_set_clear_color(ctx, rgba);
-   blitter_set_rectangle(ctx, 0, 0, width, height, dst->width, dst->height, 0);
+   blitter_set_rectangle(ctx, 0, 0, width, height, dstsurf->width, dstsurf->height, 0);
    blitter_draw_quad(ctx);
    blitter_restore_CSOs(ctx);
+
+   pipe_surface_reference(&dstsurf, NULL);
 }
index ab96ba2e738e4c6f0b7b2cc118a123a04e70da3d..fe4c3d483e260ce15e1272ac591cf21e529d4874 100644 (file)
@@ -130,11 +130,12 @@ void util_blitter_copy(struct blitter_context *blitter,
  * already required to be saved:
  * - framebuffer state
  */
-void util_blitter_fill(struct blitter_context *blitter,
-                       struct pipe_surface *dst,
-                       unsigned dstx, unsigned dsty,
-                       unsigned width, unsigned height,
-                       unsigned value);
+void util_blitter_fill_region(struct blitter_context *blitter,
+                              struct pipe_resource *dst,
+                              struct pipe_subresource subdst,
+                              unsigned dstx, unsigned dsty, unsigned dstz,
+                              unsigned width, unsigned height,
+                              unsigned value);
 
 
 /* The functions below should be used to save currently bound constant state
index 2bf9317803e793ef379d8a36f60ff76e1c3e76d8..5489d880b18f57283226bc18c4346e305d623100 100644 (file)
@@ -205,34 +205,18 @@ void r300_surface_copy(struct pipe_context* pipe,
 }
 
 /* Fill a region of a surface with a constant value. */
-void r300_surface_fill(struct pipe_context* pipe,
-                       struct pipe_resource* dst,
-                       struct pipe_subresource subdst,
-                       unsigned dstx, unsigned dsty, unsigned dstz,
-                       unsigned width, unsigned height,
-                       unsigned value)
+void r300_resource_fill_region(struct pipe_context *pipe,
+                               struct pipe_resource *dst,
+                               struct pipe_subresource subdst,
+                               unsigned dstx, unsigned dsty, unsigned dstz,
+                               unsigned width, unsigned height,
+                               unsigned value)
 {
-    struct pipe_screen *screen = pipe->screen;
-    struct r300_context* r300 = r300_context(pipe);
-    struct pipe_surface *dstsurf;
-    unsigned bind;
-
-    if (util_format_is_depth_or_stencil(dst->format))
-       bind = PIPE_BIND_DEPTH_STENCIL;
-    else
-       bind = PIPE_BIND_RENDER_TARGET;
-
-    dstsurf = screen->get_tex_surface(screen, dst,
-                                      subdst.face,
-                                      subdst.level,
-                                      dstz,
-                                      bind);
+    struct r300_context *r300 = r300_context(pipe);
 
     r300_blitter_save_states(r300);
     util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state);
 
-    util_blitter_fill(r300->blitter,
-                      dstsurf, dstx, dsty, width, height, value);
-
-    pipe_surface_reference(&dstsurf, NULL);
+    util_blitter_fill_region(r300->blitter, dst, subdst,
+                             dstx, dsty, dstz, width, height, value);
 }
index c97872662aa9404f5c8f8eb4ac291919d13bafa6..6dfb4534282627580316b31d85dcd1ba200dca8b 100644 (file)
@@ -42,11 +42,11 @@ void r300_surface_copy(struct pipe_context* pipe,
                        unsigned srcx, unsigned srcy, unsigned srcz,
                        unsigned width, unsigned height);
 
-void r300_surface_fill(struct pipe_context* pipe,
-                       struct pipe_resource* dst,
-                       struct pipe_subresource subdst,
-                       unsigned dstx, unsigned dsty, unsigned dstz,
-                       unsigned width, unsigned height,
-                       unsigned value);
+void r300_resource_fill_region(struct pipe_context* pipe,
+                               struct pipe_resource* dst,
+                               struct pipe_subresource subdst,
+                               unsigned dstx, unsigned dsty, unsigned dstz,
+                               unsigned width, unsigned height,
+                               unsigned value);
 
 #endif /* R300_BLIT_H */
index f771e10c64ee6c5fb27400f7a70c26df074ccd54..406b812f6aeb7ab42d3c8de41aa7a3634f9c06ed 100644 (file)
@@ -187,7 +187,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300->context.clear = r300_clear;
     r300->context.resource_copy_region = r300_surface_copy;
-    r300->context.resource_fill_region = r300_surface_fill;
+    r300->context.resource_fill_region = r300_resource_fill_region;
 
     if (r300screen->caps.has_tcl) {
         r300->context.draw_arrays = r300_draw_arrays;