From a46bcf0a771575ce68e0a0585a84ca6029b96b4e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Thu, 5 Oct 2017 02:38:35 +0200 Subject: gallium/u_blitter: let drivers set the vertex elements state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit radeonsi won't set it. Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/r300/r300_context.h | 1 + src/gallium/drivers/r300/r300_render.c | 7 +++++-- src/gallium/drivers/r600/r600_pipe_common.c | 3 +++ src/gallium/drivers/r600/r600_pipe_common.h | 1 + src/gallium/drivers/radeonsi/si_state.h | 1 + src/gallium/drivers/radeonsi/si_state_draw.c | 4 ++++ 6 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers') 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; -- cgit v1.2.3