diff options
author | Marek Olšák <[email protected]> | 2017-08-17 02:38:23 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-09-11 02:10:23 +0200 |
commit | 43247c440e65e41ea8a7d48249aef66f508601e3 (patch) | |
tree | a758eb7f1f6f67c29fc2fac984870052cda337b7 /src | |
parent | 7aaf4c73de1ad2526b5cd3ddbeecb687b66f6747 (diff) |
gallium/u_blitter: use draw_rectangle callback for layered clears
They are done with instancing.
Reviewed-by: Nicolai Hähnle <[email protected]>
Tested-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 52 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/r600_pipe_common.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/r600_pipe_common.h | 3 |
6 files changed, 47 insertions, 36 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 235e39b9af4..fff598d61e2 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1268,7 +1268,8 @@ static void blitter_draw(struct blitter_context_priv *ctx, } void util_blitter_draw_rectangle(struct blitter_context *blitter, - int x1, int y1, int x2, int y2, float depth, + int x1, int y1, int x2, int y2, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib) { @@ -1286,7 +1287,7 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter, default:; } - blitter_draw(ctx, x1, y1, x2, y2, depth, 1); + blitter_draw(ctx, x1, y1, x2, y2, depth, num_instances); } static void *get_clear_blend_state(struct blitter_context_priv *ctx, @@ -1383,18 +1384,17 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, pipe->bind_vertex_elements_state(pipe, ctx->velem_state); bind_fs_write_all_cbufs(ctx); + union blitter_attrib attrib; + memcpy(attrib.color, color->ui, sizeof(color->ui)); + if (num_layers > 1 && ctx->has_layered) { blitter_set_common_draw_rect_state(ctx, false, true); - blitter_set_clear_color(ctx, color->f); - blitter_draw(ctx, 0, 0, width, height, depth, num_layers); - } - else { - union blitter_attrib attrib; - - memcpy(attrib.color, color->ui, sizeof(color->ui)); + blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth, + num_layers, UTIL_BLITTER_ATTRIB_COLOR, &attrib); + } else { blitter_set_common_draw_rect_state(ctx, false, false); blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth, - UTIL_BLITTER_ATTRIB_COLOR, &attrib); + 1, UTIL_BLITTER_ATTRIB_COLOR, &attrib); } util_blitter_restore_vertex_states(blitter); @@ -1644,7 +1644,7 @@ static void do_blits(struct blitter_context_priv *ctx, pipe->set_sample_mask(pipe, ~0); ctx->base.draw_rectangle(&ctx->base, dstbox->x, dstbox->y, dstbox->x + dstbox->width, - dstbox->y + dstbox->height, 0, + dstbox->y + dstbox->height, 0, 1, UTIL_BLITTER_ATTRIB_TEXCOORD, &coord); } else { /* Draw the quad with the generic codepath. */ @@ -2103,19 +2103,18 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); + union blitter_attrib attrib; + memcpy(attrib.color, color->ui, sizeof(color->ui)); + num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1; if (num_layers > 1 && ctx->has_layered) { blitter_set_common_draw_rect_state(ctx, false, true); - blitter_set_clear_color(ctx, color->f); - blitter_draw(ctx, dstx, dsty, dstx+width, dsty+height, 0, num_layers); - } - else { - union blitter_attrib attrib; - - memcpy(attrib.color, color->ui, sizeof(color->ui)); + blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0, + num_layers, UTIL_BLITTER_ATTRIB_COLOR, &attrib); + } else { blitter_set_common_draw_rect_state(ctx, false, false); blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0, - UTIL_BLITTER_ATTRIB_COLOR, &attrib); + 1, UTIL_BLITTER_ATTRIB_COLOR, &attrib); } util_blitter_restore_vertex_states(blitter); @@ -2187,12 +2186,13 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1; if (num_layers > 1 && ctx->has_layered) { blitter_set_common_draw_rect_state(ctx, false, true); - blitter_draw(ctx, dstx, dsty, dstx+width, dsty+height, (float) depth, num_layers); - } - else { + blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, + depth, num_layers, + UTIL_BLITTER_ATTRIB_NONE, NULL); + } else { blitter_set_common_draw_rect_state(ctx, false, false); blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, - (float) depth, + depth, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); } @@ -2253,7 +2253,7 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false); 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); + 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); util_blitter_restore_fragment_states(blitter); @@ -2453,7 +2453,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false); blitter_set_dst_dimensions(ctx, src->width0, src->height0); blitter->draw_rectangle(blitter, 0, 0, src->width0, src->height0, - 0, 0, NULL); + 0, 1, 0, NULL); util_blitter_restore_fb_state(blitter); util_blitter_restore_vertex_states(blitter); util_blitter_restore_fragment_states(blitter); @@ -2503,7 +2503,7 @@ void util_blitter_custom_color(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false); blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); blitter->draw_rectangle(blitter, 0, 0, dstsurf->width, dstsurf->height, - 0, 0, NULL); + 0, 1, 0, NULL); util_blitter_restore_vertex_states(blitter); util_blitter_restore_fragment_states(blitter); diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 8cc588c5300..b335de0ef58 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -81,7 +81,7 @@ struct blitter_context */ void (*draw_rectangle)(struct blitter_context *blitter, int x1, int y1, int x2, int y2, - float depth, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib); @@ -154,7 +154,8 @@ void util_blitter_set_texture_multisample(struct blitter_context *blitter, /* The default function to draw a rectangle. This can only be used * inside of the draw_rectangle callback if the driver overrides it. */ void util_blitter_draw_rectangle(struct blitter_context *blitter, - int x1, int y1, int x2, int y2, float depth, + int x1, int y1, int x2, int y2, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index a99d50f76c0..84b8748b4c1 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -744,7 +744,7 @@ void r300_plug_in_stencil_ref_fallback(struct r300_context *r300); void r500_emit_index_bias(struct r300_context *r300, int index_bias); void r300_blitter_draw_rectangle(struct blitter_context *blitter, int x1, int y1, int x2, int y2, - float depth, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index e1fabe45035..1f896da22e9 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1114,7 +1114,7 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300) * somewhat inefficient. Instead we use a rectangular point sprite. */ void r300_blitter_draw_rectangle(struct blitter_context *blitter, int x1, int y1, int x2, int y2, - float depth, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib) { @@ -1131,8 +1131,10 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter, /* XXX workaround for a lockup in MSAA resolve on SWTCL chipsets, this * function most probably doesn't handle type=NONE correctly */ - if (!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) { - util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, type, attrib); + if ((!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) || + num_instances > 1) { + util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, + num_instances, type, attrib); return; } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 1cfab31ea33..f5f15246176 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -211,7 +211,8 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx, } void r600_draw_rectangle(struct blitter_context *blitter, - int x1, int y1, int x2, int y2, float depth, + int x1, int y1, int x2, int y2, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib) { @@ -277,8 +278,14 @@ void r600_draw_rectangle(struct blitter_context *blitter, } /* draw */ - util_draw_vertex_buffer(&rctx->b, NULL, buf, blitter->vb_slot, offset, - R600_PRIM_RECTANGLE_LIST, 3, 2); + struct pipe_vertex_buffer vbuffer = {}; + vbuffer.buffer.resource = buf; + vbuffer.stride = 2 * 4 * sizeof(float); /* vertex size */ + vbuffer.buffer_offset = offset; + + rctx->b.set_vertex_buffers(&rctx->b, blitter->vb_slot, 1, &vbuffer); + util_draw_arrays_instanced(&rctx->b, R600_PRIM_RECTANGLE_LIST, 0, 3, + 0, num_instances); pipe_resource_reference(&buf, NULL); } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 48536723b6c..08220bdfd8d 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -765,7 +765,8 @@ unsigned r600_gfx_write_fence_dwords(struct r600_common_screen *screen); void r600_gfx_wait_fence(struct r600_common_context *ctx, uint64_t va, uint32_t ref, uint32_t mask); void r600_draw_rectangle(struct blitter_context *blitter, - int x1, int y1, int x2, int y2, float depth, + int x1, int y1, int x2, int y2, + float depth, unsigned num_instances, enum blitter_attrib_type type, const union blitter_attrib *attrib); bool r600_common_screen_init(struct r600_common_screen *rscreen, |