[Mesa-dev] [PATCH 3/4] radeonsi: implement uploading zero-stride vertex attribs

Nicolai Hähnle nhaehnle at gmail.com
Mon Feb 13 15:42:16 UTC 2017


On 11.02.2017 17:30, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> This is the only kind of user buffer we can get with the GL core profile.

Patches 1-3:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

> ---
>  src/gallium/drivers/radeonsi/si_state.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
> index 107bc06..df7092e 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -27,20 +27,21 @@
>  #include "si_pipe.h"
>  #include "sid.h"
>  #include "radeon/r600_cs.h"
>  #include "radeon/r600_query.h"
>
>  #include "util/u_dual_blend.h"
>  #include "util/u_format.h"
>  #include "util/u_format_s3tc.h"
>  #include "util/u_memory.h"
>  #include "util/u_resource.h"
> +#include "util/u_upload_mgr.h"
>
>  /* Initialize an external atom (owned by ../radeon). */
>  static void
>  si_init_external_atom(struct si_context *sctx, struct r600_atom *atom,
>  		      struct r600_atom **list_elem)
>  {
>  	atom->id = list_elem - sctx->atoms.array;
>  	*list_elem = atom;
>  }
>
> @@ -3507,28 +3508,42 @@ static void si_set_vertex_buffers(struct pipe_context *ctx,
>  	struct si_context *sctx = (struct si_context *)ctx;
>  	struct pipe_vertex_buffer *dst = sctx->vertex_buffer + start_slot;
>  	int i;
>
>  	assert(start_slot + count <= ARRAY_SIZE(sctx->vertex_buffer));
>
>  	if (buffers) {
>  		for (i = 0; i < count; i++) {
>  			const struct pipe_vertex_buffer *src = buffers + i;
>  			struct pipe_vertex_buffer *dsti = dst + i;
> -			struct pipe_resource *buf = src->buffer;
> -
> -			pipe_resource_reference(&dsti->buffer, buf);
> -			dsti->buffer_offset = src->buffer_offset;
> -			dsti->stride = src->stride;
> -			r600_context_add_resource_size(ctx, buf);
> -			if (buf)
> -				r600_resource(buf)->bind_history |= PIPE_BIND_VERTEX_BUFFER;
> +
> +			if (unlikely(src->user_buffer)) {
> +				/* Zero-stride attribs only. */
> +				assert(src->stride == 0);
> +
> +				/* Assume the attrib has 4 dwords like the vbo
> +				 * module. This is also a good upper bound. */
> +				u_upload_data(sctx->b.uploader, 0, 16, 16,
> +					      src->user_buffer,
> +					      &dsti->buffer_offset,
> +					      &dsti->buffer);
> +				dsti->stride = 0;
> +			} else {
> +				struct pipe_resource *buf = src->buffer;
> +
> +				pipe_resource_reference(&dsti->buffer, buf);
> +				dsti->buffer_offset = src->buffer_offset;
> +				dsti->stride = src->stride;
> +				r600_context_add_resource_size(ctx, buf);
> +				if (buf)
> +					r600_resource(buf)->bind_history |= PIPE_BIND_VERTEX_BUFFER;
> +			}
>  		}
>  	} else {
>  		for (i = 0; i < count; i++) {
>  			pipe_resource_reference(&dst[i].buffer, NULL);
>  		}
>  	}
>  	sctx->vertex_buffers_dirty = true;
>  }
>
>  static void si_set_index_buffer(struct pipe_context *ctx,
>



More information about the mesa-dev mailing list