[Mesa-dev] [PATCH 2/7] gallium: use PIPE_CAP_CONSTBUF0_FLAGS
Axel Davy
axel.davy at normalesup.org
Fri Feb 2 21:44:53 UTC 2018
Hi Marek,
Since the previous patch makes it mandatory to use the flags when required,
I guess this patch should also add the neccessary changes to gallium nine.
Yours,
Axel Davy
On 02/02/2018 21:48, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/auxiliary/util/u_inlines.h | 21 +++++++++++++++++++++
> src/gallium/auxiliary/vl/vl_compositor.c | 2 +-
> src/gallium/drivers/radeonsi/si_pipe.c | 2 +-
> src/gallium/state_trackers/xa/xa_renderer.c | 7 ++++---
> 4 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
> index 4ba6ad7..4bd9b7e 100644
> --- a/src/gallium/auxiliary/util/u_inlines.h
> +++ b/src/gallium/auxiliary/util/u_inlines.h
> @@ -277,20 +277,41 @@ pipe_buffer_create( struct pipe_screen *screen,
> buffer.usage = usage;
> buffer.flags = 0;
> buffer.width0 = size;
> buffer.height0 = 1;
> buffer.depth0 = 1;
> buffer.array_size = 1;
> return screen->resource_create(screen, &buffer);
> }
>
>
> +static inline struct pipe_resource *
> +pipe_buffer_create_const0(struct pipe_screen *screen,
> + unsigned bind,
> + enum pipe_resource_usage usage,
> + unsigned size)
> +{
> + struct pipe_resource buffer;
> + memset(&buffer, 0, sizeof buffer);
> + buffer.target = PIPE_BUFFER;
> + buffer.format = PIPE_FORMAT_R8_UNORM;
> + buffer.bind = bind;
> + buffer.usage = usage;
> + buffer.flags = screen->get_param(screen, PIPE_CAP_CONSTBUF0_FLAGS);
> + buffer.width0 = size;
> + buffer.height0 = 1;
> + buffer.depth0 = 1;
> + buffer.array_size = 1;
> + return screen->resource_create(screen, &buffer);
> +}
> +
> +
> /**
> * Map a range of a resource.
> * \param offset start of region, in bytes
> * \param length size of region, in bytes
> * \param access bitmask of PIPE_TRANSFER_x flags
> * \param transfer returns a transfer object
> */
> static inline void *
> pipe_buffer_map_range(struct pipe_context *pipe,
> struct pipe_resource *buffer,
> diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
> index 67ad7f5..725bfd9 100644
> --- a/src/gallium/auxiliary/vl/vl_compositor.c
> +++ b/src/gallium/auxiliary/vl/vl_compositor.c
> @@ -1430,21 +1430,21 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
> s->pipe = pipe;
>
> s->clear_color.f[0] = s->clear_color.f[1] = 0.0f;
> s->clear_color.f[2] = s->clear_color.f[3] = 0.0f;
>
> /*
> * Create our fragment shader's constant buffer
> * Const buffer contains the color conversion matrix and bias vectors
> */
> /* XXX: Create with IMMUTABLE/STATIC... although it does change every once in a long while... */
> - s->csc_matrix = pipe_buffer_create
> + s->csc_matrix = pipe_buffer_create_const0
> (
> pipe->screen,
> PIPE_BIND_CONSTANT_BUFFER,
> PIPE_USAGE_DEFAULT,
> sizeof(csc_matrix) + 2*sizeof(float)
> );
>
> if (!s->csc_matrix)
> return false;
>
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
> index 26835d6..1a5d598 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -580,21 +580,21 @@ static void si_handle_env_var_force_family(struct si_screen *sscreen)
>
> fprintf(stderr, "radeonsi: Unknown family: %s\n", family);
> exit(1);
> }
>
> static void si_test_vmfault(struct si_screen *sscreen)
> {
> struct pipe_context *ctx = sscreen->aux_context;
> struct si_context *sctx = (struct si_context *)ctx;
> struct pipe_resource *buf =
> - pipe_buffer_create(&sscreen->b, 0, PIPE_USAGE_DEFAULT, 64);
> + pipe_buffer_create_const0(&sscreen->b, 0, PIPE_USAGE_DEFAULT, 64);
>
> if (!buf) {
> puts("Buffer allocation failed.");
> exit(1);
> }
>
> r600_resource(buf)->gpu_address = 0; /* cause a VM fault */
>
> if (sscreen->debug_flags & DBG(TEST_VMFAULT_CP)) {
> si_copy_buffer(sctx, buf, buf, 0, 4, 4, 0);
> diff --git a/src/gallium/state_trackers/xa/xa_renderer.c b/src/gallium/state_trackers/xa/xa_renderer.c
> index bc55f87..27497d3 100644
> --- a/src/gallium/state_trackers/xa/xa_renderer.c
> +++ b/src/gallium/state_trackers/xa/xa_renderer.c
> @@ -386,23 +386,24 @@ renderer_bind_destination(struct xa_context *r,
>
> void
> renderer_set_constants(struct xa_context *r,
> int shader_type, const float *params, int param_bytes)
> {
> struct pipe_resource **cbuf =
> (shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
> &r->fs_const_buffer;
>
> pipe_resource_reference(cbuf, NULL);
> - *cbuf = pipe_buffer_create(r->pipe->screen,
> - PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_DEFAULT,
> - param_bytes);
> + *cbuf = pipe_buffer_create_const0(r->pipe->screen,
> + PIPE_BIND_CONSTANT_BUFFER,
> + PIPE_USAGE_DEFAULT,
> + param_bytes);
>
> if (*cbuf) {
> pipe_buffer_write(r->pipe, *cbuf, 0, param_bytes, params);
> }
> pipe_set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
> }
>
> void
> renderer_copy_prepare(struct xa_context *r,
> struct pipe_surface *dst_surface,
More information about the mesa-dev
mailing list