[Mesa-dev] [PATCH 06/10] gallium/blitter: use the common uploader

Marek Olšák maraeo at gmail.com
Fri Jan 27 11:02:09 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/util/u_blitter.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 45dc033..447d8d2 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -54,22 +54,20 @@
 #define GET_CLEAR_BLEND_STATE_IDX(clear_buffers) \
    ((clear_buffers) / PIPE_CLEAR_COLOR0)
 
 #define NUM_RESOLVE_FRAG_SHADERS 5 /* MSAA 2x, 4x, 8x, 16x, 32x */
 #define GET_MSAA_RESOLVE_FS_IDX(nr_samples) (util_logbase2(nr_samples)-1)
 
 struct blitter_context_priv
 {
    struct blitter_context base;
 
-   struct u_upload_mgr *upload;
-
    float vertices[4][2][4];   /**< {pos, color} or {pos, texcoord} */
 
    /* Templates for various state objects. */
 
    /* Constant state objects. */
    /* Vertex shaders. */
    void *vs; /**< Vertex shader which passes {pos, generic} to the output.*/
    void *vs_pos_only[4]; /**< Vertex shader which passes pos to the output.*/
    void *vs_layered; /**< Vertex shader which sets LAYER = INSTANCEID. */
 
@@ -309,23 +307,20 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    }
 
    ctx->has_layered =
       pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) &&
       pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT);
 
    /* set invariant vertex coordinates */
    for (i = 0; i < 4; i++)
       ctx->vertices[i][0][3] = 1; /*v.w*/
 
-   ctx->upload = u_upload_create(pipe, 65536, PIPE_BIND_VERTEX_BUFFER,
-                                 PIPE_USAGE_STREAM);
-
    return &ctx->base;
 }
 
 static void bind_vs_pos_only(struct blitter_context_priv *ctx,
                              unsigned num_so_channels)
 {
    struct pipe_context *pipe = ctx->base.pipe;
    int index = num_so_channels ? num_so_channels - 1 : 0;
 
    if (!ctx->vs_pos_only[index]) {
@@ -484,21 +479,20 @@ void util_blitter_destroy(struct blitter_context *blitter)
       ctx->delete_fs_state(pipe, ctx->fs_empty);
    if (ctx->fs_write_one_cbuf)
       ctx->delete_fs_state(pipe, ctx->fs_write_one_cbuf);
    if (ctx->fs_write_all_cbufs)
       ctx->delete_fs_state(pipe, ctx->fs_write_all_cbufs);
 
    pipe->delete_sampler_state(pipe, ctx->sampler_state_rect_linear);
    pipe->delete_sampler_state(pipe, ctx->sampler_state_rect);
    pipe->delete_sampler_state(pipe, ctx->sampler_state_linear);
    pipe->delete_sampler_state(pipe, ctx->sampler_state);
-   u_upload_destroy(ctx->upload);
    FREE(ctx);
 }
 
 void util_blitter_set_texture_multisample(struct blitter_context *blitter,
                                           boolean supported)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
 
    ctx->has_texture_multisample = supported;
 }
@@ -1207,25 +1201,25 @@ static void blitter_draw(struct blitter_context_priv *ctx,
                          int x1, int y1, int x2, int y2, float depth,
                          unsigned num_instances)
 {
    struct pipe_context *pipe = ctx->base.pipe;
    struct pipe_vertex_buffer vb = {0};
 
    blitter_set_rectangle(ctx, x1, y1, x2, y2, depth);
 
    vb.stride = 8 * sizeof(float);
 
-   u_upload_data(ctx->upload, 0, sizeof(ctx->vertices), 4, ctx->vertices,
+   u_upload_data(pipe->stream_uploader, 0, sizeof(ctx->vertices), 4, ctx->vertices,
                  &vb.buffer_offset, &vb.buffer);
    if (!vb.buffer)
       return;
-   u_upload_unmap(ctx->upload);
+   u_upload_unmap(pipe->stream_uploader);
 
    pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb);
    util_draw_arrays_instanced(pipe, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
                               0, num_instances);
    pipe_resource_reference(&vb.buffer, NULL);
 }
 
 void util_blitter_draw_rectangle(struct blitter_context *blitter,
                                  int x1, int y1, int x2, int y2, float depth,
                                  enum blitter_attrib_type type,
@@ -2257,21 +2251,21 @@ void util_blitter_clear_buffer(struct blitter_context *blitter,
       assert(!"Streamout unsupported in util_blitter_clear_buffer()");
       return;
    }
 
    /* Some alignment is required. */
    if (offset % 4 != 0 || size % 4 != 0) {
       assert(!"Bad alignment in util_blitter_clear_buffer()");
       return;
    }
 
-   u_upload_data(ctx->upload, 0, num_channels*4, 4, clear_value,
+   u_upload_data(pipe->stream_uploader, 0, num_channels*4, 4, clear_value,
                  &vb.buffer_offset, &vb.buffer);
    if (!vb.buffer)
       goto out;
 
    vb.stride = 0;
 
    util_blitter_set_running_flag(blitter);
    blitter_check_saved_vertex_states(ctx);
    blitter_disable_render_cond(ctx);
 
-- 
2.7.4



More information about the mesa-dev mailing list