gallium/u_blitter: make clearing independent of the colorbuffer format
authorMarek Olšák <maraeo@gmail.com>
Wed, 29 May 2013 13:51:20 +0000 (15:51 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 13 Jun 2013 01:54:13 +0000 (03:54 +0200)
There isn't any difference between 32_FLOAT and 32_*INT in vertex fetching.
Both of them don't do any format conversion.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/radeonsi/r600_blit.c

index 4ce2bfb6a8e2d826658c264e0fe0b56ee775bbf5..e9ac170f79616a382e270c5ddc4e995a3946ddc6 100644 (file)
@@ -98,8 +98,6 @@ struct blitter_context_priv
 
    /* Vertex elements states. */
    void *velem_state;
-   void *velem_uint_state;
-   void *velem_sint_state;
    void *velem_state_readbuf[4]; /**< X, XY, XYZ, XYZW */
 
    /* Sampler state. */
@@ -119,7 +117,6 @@ struct blitter_context_priv
    unsigned dst_height;
 
    boolean has_geometry_shader;
-   boolean vertex_has_integers;
    boolean has_stream_out;
    boolean has_stencil_export;
    boolean has_texture_multisample;
@@ -171,9 +168,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    ctx->has_geometry_shader =
       pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_GEOMETRY,
                                      PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0;
-   ctx->vertex_has_integers =
-      pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_VERTEX,
-                                     PIPE_SHADER_CAP_INTEGERS);
    ctx->has_stream_out =
       pipe->screen->get_param(pipe->screen,
                               PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0;
@@ -265,26 +259,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    }
    ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
 
-   if (ctx->vertex_has_integers) {
-      memset(&velem[0], 0, sizeof(velem[0]) * 2);
-      velem[0].src_offset = 0;
-      velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-      velem[0].vertex_buffer_index = ctx->base.vb_slot;
-      velem[1].src_offset = 4 * sizeof(float);
-      velem[1].src_format = PIPE_FORMAT_R32G32B32A32_SINT;
-      velem[1].vertex_buffer_index = ctx->base.vb_slot;
-      ctx->velem_sint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
-
-      memset(&velem[0], 0, sizeof(velem[0]) * 2);
-      velem[0].src_offset = 0;
-      velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-      velem[0].vertex_buffer_index = ctx->base.vb_slot;
-      velem[1].src_offset = 4 * sizeof(float);
-      velem[1].src_format = PIPE_FORMAT_R32G32B32A32_UINT;
-      velem[1].vertex_buffer_index = ctx->base.vb_slot;
-      ctx->velem_uint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
-   }
-
    if (ctx->has_stream_out) {
       static enum pipe_format formats[4] = {
          PIPE_FORMAT_R32_UINT,
@@ -368,10 +342,6 @@ void util_blitter_destroy(struct blitter_context *blitter)
    if (ctx->vs_pos_only)
       pipe->delete_vs_state(pipe, ctx->vs_pos_only);
    pipe->delete_vertex_elements_state(pipe, ctx->velem_state);
-   if (ctx->vertex_has_integers) {
-      pipe->delete_vertex_elements_state(pipe, ctx->velem_sint_state);
-      pipe->delete_vertex_elements_state(pipe, ctx->velem_uint_state);
-   }
    for (i = 0; i < 4; i++) {
       if (ctx->velem_state_readbuf[i]) {
          pipe->delete_vertex_elements_state(pipe, ctx->velem_state_readbuf[i]);
@@ -982,7 +952,6 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter,
 static void util_blitter_clear_custom(struct blitter_context *blitter,
                                       unsigned width, unsigned height,
                                       unsigned clear_buffers,
-                                      enum pipe_format cbuf_format,
                                       const union pipe_color_union *color,
                                       double depth, unsigned stencil,
                                       void *custom_blend, void *custom_dsa)
@@ -1020,13 +989,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
    sr.ref_value[0] = stencil & 0xff;
    pipe->set_stencil_ref(pipe, &sr);
 
-   if (util_format_is_pure_sint(cbuf_format)) {
-      pipe->bind_vertex_elements_state(pipe, ctx->velem_sint_state);
-   } else if (util_format_is_pure_uint(cbuf_format)) {
-      pipe->bind_vertex_elements_state(pipe, ctx->velem_uint_state);
-   } else {
-      pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
-   }
+   pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
    ctx->bind_fs_state(pipe, ctx->fs_write_all_cbufs);
    pipe->set_sample_mask(pipe, ~0);
 
@@ -1044,12 +1007,11 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
 void util_blitter_clear(struct blitter_context *blitter,
                         unsigned width, unsigned height,
                         unsigned clear_buffers,
-                        enum pipe_format cbuf_format,
                         const union pipe_color_union *color,
                         double depth, unsigned stencil)
 {
    util_blitter_clear_custom(blitter, width, height,
-                             clear_buffers, cbuf_format, color, depth, stencil,
+                             clear_buffers, color, depth, stencil,
                              NULL, NULL);
 }
 
@@ -1058,8 +1020,8 @@ void util_blitter_custom_clear_depth(struct blitter_context *blitter,
                                      double depth, void *custom_dsa)
 {
     static const union pipe_color_union color;
-    util_blitter_clear_custom(blitter, width, height,
-                              0, PIPE_FORMAT_NONE, &color, depth, 0, NULL, custom_dsa);
+    util_blitter_clear_custom(blitter, width, height, 0, &color, depth, 0,
+                              NULL, custom_dsa);
 }
 
 void util_blitter_default_dst_texture(struct pipe_surface *dst_templ,
index c533dbc41b49b5a854bc34e99b1e5d38c69994a1..e52d5acc95ffcef9ebb5276a1f045fef9c214b3f 100644 (file)
@@ -184,7 +184,6 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter,
 void util_blitter_clear(struct blitter_context *blitter,
                         unsigned width, unsigned height,
                         unsigned clear_buffers,
-                        enum pipe_format cbuf_format,
                         const union pipe_color_union *color,
                         double depth, unsigned stencil);
 
index 6cac567848564310357c48b79b1f3b00e9eaf6b4..7802594bbb822334c0522ff39122c8ba767a26ac 100644 (file)
@@ -363,13 +363,12 @@ static void r300_clear(struct pipe_context* pipe,
 
     /* Clear. */
     if (buffers) {
-        enum pipe_format cformat = fb->nr_cbufs ? fb->cbufs[0]->format : PIPE_FORMAT_NONE;
         /* Clear using the blitter. */
         r300_blitter_begin(r300, R300_CLEAR);
         util_blitter_clear(r300->blitter,
                            width,
                            height,
-                           buffers, cformat, color, depth, stencil);
+                           buffers, color, depth, stencil);
         r300_blitter_end(r300);
     } else if (r300->zmask_clear.dirty ||
                r300->hiz_clear.dirty ||
index eded3555b4fbe64e555a540d118a75b1d33449b5..660f4f9aa96f8bd6428eb92aaed7e4f8b8bca68a 100644 (file)
@@ -443,8 +443,7 @@ static void r600_clear(struct pipe_context *ctx, unsigned buffers,
 
        r600_blitter_begin(ctx, R600_CLEAR);
        util_blitter_clear(rctx->blitter, fb->width, fb->height,
-                          buffers, fb->nr_cbufs ? fb->cbufs[0]->format : PIPE_FORMAT_NONE,
-                          color, depth, stencil);
+                          buffers, color, depth, stencil);
        r600_blitter_end(ctx);
 
        /* disable fast clear */
index eee6cd10a9edc5e2b9b2f06a5455c8c1c388b3c2..724d481daad910204971e805b34ecb092818ea2c 100644 (file)
@@ -244,8 +244,7 @@ static void r600_clear(struct pipe_context *ctx, unsigned buffers,
 
        r600_blitter_begin(ctx, R600_CLEAR);
        util_blitter_clear(rctx->blitter, fb->width, fb->height,
-                          buffers, fb->nr_cbufs ? fb->cbufs[0]->format : PIPE_FORMAT_NONE,
-                          color, depth, stencil);
+                          buffers, color, depth, stencil);
        r600_blitter_end(ctx);
 }