diff options
author | Marek Olšák <[email protected]> | 2017-10-05 02:38:35 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-10-07 18:26:35 +0200 |
commit | a46bcf0a771575ce68e0a0585a84ca6029b96b4e (patch) | |
tree | 8a1b68c3666b96fc621b9411fb1eb7095fa753d5 | |
parent | 7f8af4624d5e77b1ff4779a361930cadb3ab38ba (diff) |
gallium/u_blitter: let drivers set the vertex elements state
radeonsi won't set it.
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 54 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe_common.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe_common.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_draw.c | 4 |
8 files changed, 45 insertions, 28 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 9153ae139b2..ec03e5f7d12 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1237,6 +1237,7 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx, } static void blitter_draw(struct blitter_context_priv *ctx, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances) { @@ -1254,12 +1255,14 @@ static void blitter_draw(struct blitter_context_priv *ctx, u_upload_unmap(pipe->stream_uploader); pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb); + pipe->bind_vertex_elements_state(pipe, vertex_elements_cso); util_draw_arrays_instanced(pipe, PIPE_PRIM_TRIANGLE_FAN, 0, 4, 0, num_instances); pipe_resource_reference(&vb.buffer.resource, NULL); } void util_blitter_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, @@ -1286,7 +1289,7 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter, default:; } - blitter_draw(ctx, x1, y1, x2, y2, depth, num_instances); + blitter_draw(ctx, vertex_elements_cso, x1, y1, x2, y2, depth, num_instances); } static void *get_clear_blend_state(struct blitter_context_priv *ctx, @@ -1380,7 +1383,6 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, sr.ref_value[0] = stencil & 0xff; pipe->set_stencil_ref(pipe, &sr); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); bind_fs_write_all_cbufs(ctx); union blitter_attrib attrib; @@ -1392,12 +1394,12 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, if (num_layers > 1 && ctx->has_layered) { blitter_set_common_draw_rect_state(ctx, false, true, pass_generic); - blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth, - num_layers, type, &attrib); + blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0, width, height, + (float) depth, num_layers, type, &attrib); } else { blitter_set_common_draw_rect_state(ctx, false, false, pass_generic); - blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth, - 1, type, &attrib); + blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0, width, height, + (float) depth, 1, type, &attrib); } util_blitter_restore_vertex_states(blitter); @@ -1629,10 +1631,12 @@ blitter_draw_tex(struct blitter_context_priv *ctx, ctx->vertices[i][1][3] = coord.texcoord.w; /* Cubemaps don't use draw_rectangle. */ - blitter_draw(ctx, dst_x1, dst_y1, dst_x2, dst_y2, 0, 1); + blitter_draw(ctx, ctx->velem_state, + dst_x1, dst_y1, dst_x2, dst_y2, 0, 1); } else { - ctx->base.draw_rectangle(&ctx->base, dst_x1, dst_y1, dst_x2, dst_y2, 0, - 1, type, &coord); + ctx->base.draw_rectangle(&ctx->base, ctx->velem_state, + dst_x1, dst_y1, dst_x2, dst_y2, + 0, 1, type, &coord); } } @@ -1938,7 +1942,6 @@ void util_blitter_blit_generic(struct blitter_context *blitter, 0, 1, &sampler_state); } - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); if (scissor) { pipe->set_scissor_states(pipe, 0, 1, scissor); } @@ -2049,7 +2052,6 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter, pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); blitter_set_common_draw_rect_state(ctx, false, false, true); for (src_level = base_level; src_level < last_level; src_level++) { @@ -2125,7 +2127,6 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA][0]); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); bind_fs_write_one_cbuf(ctx); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ fb_state.width = dstsurf->width; @@ -2144,11 +2145,13 @@ void util_blitter_clear_render_target(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, true); - blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0, + blitter->draw_rectangle(blitter, ctx->velem_state, + dstx, dsty, dstx+width, dsty+height, 0, num_layers, UTIL_BLITTER_ATTRIB_COLOR, &attrib); } else { blitter_set_common_draw_rect_state(ctx, false, false, true); - blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0, + blitter->draw_rectangle(blitter, ctx->velem_state, + dstx, dsty, dstx+width, dsty+height, 0, 1, UTIL_BLITTER_ATTRIB_COLOR, &attrib); } @@ -2205,7 +2208,6 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); bind_fs_empty(ctx); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ fb_state.width = dstsurf->width; @@ -2221,13 +2223,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, false); - blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, - depth, num_layers, - UTIL_BLITTER_ATTRIB_NONE, NULL); + blitter->draw_rectangle(blitter, ctx->velem_state, + dstx, dsty, dstx+width, dsty+height, depth, + num_layers, UTIL_BLITTER_ATTRIB_NONE, NULL); } else { blitter_set_common_draw_rect_state(ctx, false, false, false); - blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, - depth, 1, + blitter->draw_rectangle(blitter, ctx->velem_state, + dstx, dsty, dstx+width, dsty+height, depth, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); } @@ -2268,7 +2270,6 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, bind_fs_write_one_cbuf(ctx); else bind_fs_empty(ctx); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ fb_state.width = zsurf->width; @@ -2287,7 +2288,8 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false, false); blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height); - blitter->draw_rectangle(blitter, 0, 0, zsurf->width, zsurf->height, depth, + blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0, + zsurf->width, zsurf->height, depth, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); @@ -2458,7 +2460,6 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, /* bind states */ pipe->bind_blend_state(pipe, custom_blend); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); bind_fs_write_one_cbuf(ctx); pipe->set_sample_mask(pipe, sample_mask); @@ -2487,7 +2488,8 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false, false); blitter_set_dst_dimensions(ctx, src->width0, src->height0); - blitter->draw_rectangle(blitter, 0, 0, src->width0, src->height0, + blitter->draw_rectangle(blitter, ctx->velem_state, + 0, 0, src->width0, src->height0, 0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_fb_state(blitter); util_blitter_restore_vertex_states(blitter); @@ -2523,7 +2525,6 @@ void util_blitter_custom_color(struct blitter_context *blitter, : ctx->blend[PIPE_MASK_RGBA][0]); pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); bind_fs_write_one_cbuf(ctx); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->set_sample_mask(pipe, (1ull << MAX2(1, dstsurf->texture->nr_samples)) - 1); /* set a framebuffer state */ @@ -2537,7 +2538,8 @@ void util_blitter_custom_color(struct blitter_context *blitter, blitter_set_common_draw_rect_state(ctx, false, false, false); blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); - blitter->draw_rectangle(blitter, 0, 0, dstsurf->width, dstsurf->height, + blitter->draw_rectangle(blitter, ctx->velem_state, + 0, 0, dstsurf->width, dstsurf->height, 0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL); util_blitter_restore_vertex_states(blitter); diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 626d46aae47..868f1da5c9c 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -81,6 +81,7 @@ struct blitter_context * a rectangular point sprite. */ void (*draw_rectangle)(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, @@ -155,6 +156,7 @@ 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, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 84b8748b4c1..b2d7f6da30e 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -743,6 +743,7 @@ void r300_plug_in_stencil_ref_fallback(struct r300_context *r300); /* r300_render.c */ void r500_emit_index_bias(struct r300_context *r300, int index_bias); void r300_blitter_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index ddd24523ca6..7808669e253 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1113,6 +1113,7 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300) * would be computed and stored twice, which makes the clear/copy codepaths * somewhat inefficient. Instead we use a rectangular point sprite. */ void r300_blitter_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, @@ -1134,14 +1135,16 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter, if ((!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) || type == UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW || num_instances > 1) { - util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth, - num_instances, type, attrib); + util_blitter_draw_rectangle(blitter, vertex_elements_cso, x1, y1, x2, y2, + depth, num_instances, type, attrib); return; } if (r300->skip_rendering) return; + r300->context.bind_vertex_elements_state(&r300->context, vertex_elements_cso); + if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY) r300->sprite_coord_enable = 1; diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index 4fbcd3a6572..0e8a12a1b64 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -211,6 +211,7 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx, } void r600_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, @@ -223,6 +224,8 @@ void r600_draw_rectangle(struct blitter_context *blitter, unsigned offset = 0; float *vb; + rctx->b.bind_vertex_elements_state(&rctx->b, vertex_elements_cso); + /* Some operations (like color resolve on r6xx) don't work * with the conventional primitive types. * One that works is PT_RECTLIST, which we use here. */ diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h index 719efb9bbab..37dcbd3d316 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.h +++ b/src/gallium/drivers/r600/r600_pipe_common.h @@ -762,6 +762,7 @@ 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, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index eccc87ea8a0..c9745a58cb7 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -408,6 +408,7 @@ void si_init_ia_multi_vgt_param_table(struct si_context *sctx); void si_emit_cache_flush(struct si_context *sctx); void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo); void si_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index adebba645d4..ceb90d287f5 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -1491,6 +1491,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) } void si_draw_rectangle(struct blitter_context *blitter, + void *vertex_elements_cso, int x1, int y1, int x2, int y2, float depth, unsigned num_instances, enum blitter_attrib_type type, @@ -1565,6 +1566,9 @@ void si_draw_rectangle(struct blitter_context *blitter, pipe->set_vertex_buffers(pipe, blitter->vb_slot, 1, &vbuffer); + if (sctx->vertex_elements != vertex_elements_cso) + pipe->bind_vertex_elements_state(pipe, vertex_elements_cso); + struct pipe_draw_info info = {}; info.mode = R600_PRIM_RECTANGLE_LIST; info.count = 3; |