From: Marek Olšák Date: Tue, 7 Jan 2020 23:10:38 +0000 (-0500) Subject: radeonsi: add si_context::num_vertex_elements X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c278c73f135e3b6c89253ffe34ad18147097e9d0;p=mesa.git radeonsi: add si_context::num_vertex_elements Reviewed-by: Pierre-Eric Pelloux-Prayer --- diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 76695baa4c3..642a22ccfa6 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -1070,7 +1070,7 @@ static void si_get_buffer_from_descriptors(struct si_buffer_resources *buffers, static void si_vertex_buffers_begin_new_cs(struct si_context *sctx) { - int count = sctx->vertex_elements ? sctx->vertex_elements->count : 0; + int count = sctx->num_vertex_elements; int i; for (i = 0; i < count; i++) { @@ -1095,18 +1095,13 @@ static void si_vertex_buffers_begin_new_cs(struct si_context *sctx) bool si_upload_vertex_buffer_descriptors(struct si_context *sctx) { - struct si_vertex_elements *velems = sctx->vertex_elements; - unsigned i, count; + unsigned i, count = sctx->num_vertex_elements; uint32_t *ptr; - if (!sctx->vertex_buffers_dirty || !velems) - return true; - - count = velems->count; - - if (!count) + if (!sctx->vertex_buffers_dirty || !count) return true; + struct si_vertex_elements *velems = sctx->vertex_elements; unsigned alloc_size = velems->vb_desc_list_alloc_size; unsigned first_vb_use_mask = velems->first_vb_use_mask; @@ -1667,8 +1662,7 @@ void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf) { struct si_resource *buffer = si_resource(buf); unsigned i, shader; - unsigned num_elems = sctx->vertex_elements ? - sctx->vertex_elements->count : 0; + unsigned num_elems = sctx->num_vertex_elements; /* We changed the buffer, now we need to bind it where the old one * was bound. This consists of 2 things: diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index f78ab7aa2ba..14768f02384 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1000,6 +1000,7 @@ struct si_context { /* shader information */ struct si_vertex_elements *vertex_elements; + unsigned num_vertex_elements; unsigned sprite_coord_enable; unsigned cs_max_waves_per_sh; bool flatshade; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 6b3a3a3be6b..2c1638930f3 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -5074,6 +5074,7 @@ static void si_bind_vertex_elements(struct pipe_context *ctx, void *state) struct si_vertex_elements *v = (struct si_vertex_elements*)state; sctx->vertex_elements = v; + sctx->num_vertex_elements = v ? v->count : 0; sctx->vertex_buffers_dirty = true; if (v &&