Re: [Mesa-dev] [PATCH 1/2] gallium/pp: use user constant buffers
On 05/04/18 06:11, Marek Olšák wrote: From: Marek OlšákThis fixes a radeonsi crash. The constant buffer didn't follow the PIPE_CAP_CONSTBUF0_FLAGS rule. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105026 --- src/gallium/auxiliary/cso_cache/cso_context.c | 17 src/gallium/auxiliary/cso_cache/cso_context.h | 3 +++ src/gallium/auxiliary/postprocess/pp_mlaa.c| 37 -- src/gallium/auxiliary/postprocess/pp_private.h | 1 - 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 3fa57f16ff4..3a3a63a3327 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1540,20 +1540,37 @@ cso_set_constant_buffer_resource(struct cso_context *cso, cb.buffer = buffer; cb.buffer_offset = 0; cb.buffer_size = buffer->width0; cb.user_buffer = NULL; cso_set_constant_buffer(cso, shader_stage, index, ); } else { cso_set_constant_buffer(cso, shader_stage, index, NULL); } } +void +cso_set_constant_user_buffer(struct cso_context *cso, + enum pipe_shader_type shader_stage, + unsigned index, void *ptr, unsigned size) +{ + if (ptr) { + struct pipe_constant_buffer cb; + cb.buffer = NULL; + cb.buffer_offset = 0; + cb.buffer_size = size; + cb.user_buffer = ptr; + cso_set_constant_buffer(cso, shader_stage, index, ); + } else { + cso_set_constant_buffer(cso, shader_stage, index, NULL); + } +} + void cso_save_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage) { util_copy_constant_buffer(>aux_constbuf_saved[shader_stage], >aux_constbuf_current[shader_stage]); } void cso_restore_constant_buffer_slot0(struct cso_context *cso, diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index b1bc0813442..3a4e808f0c0 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -207,20 +207,23 @@ cso_set_shader_images(struct cso_context *cso, /* constant buffers */ void cso_set_constant_buffer(struct cso_context *cso, enum pipe_shader_type shader_stage, unsigned index, struct pipe_constant_buffer *cb); void cso_set_constant_buffer_resource(struct cso_context *cso, enum pipe_shader_type shader_stage, unsigned index, struct pipe_resource *buffer); +void cso_set_constant_user_buffer(struct cso_context *cso, + enum pipe_shader_type shader_stage, + unsigned index, void *ptr, unsigned size); void cso_save_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage); void cso_restore_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage); /* drawing */ void cso_draw_vbo(struct cso_context *cso, diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c index 0edd01f3f5d..610cedbd1b3 100644 --- a/src/gallium/auxiliary/postprocess/pp_mlaa.c +++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c @@ -50,76 +50,64 @@ #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_string.h" #include "pipe/p_screen.h" #define IMM_SPACE 80 static float constants[] = { 1, 1, 0, 0 }; static unsigned int dimensions[2] = { 0, 0 }; -/** Upload the constants. */ -static void -up_consts(struct pp_queue_t *ppq) -{ - struct pipe_context *pipe = ppq->p->pipe; - - pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE, -0, sizeof(constants), constants); -} - /** Run function of the MLAA filter. */ static void pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, struct pipe_resource *out, unsigned int n, bool iscolor) { struct pp_program *p = ppq->p; struct pipe_depth_stencil_alpha_state mstencil; struct pipe_sampler_view v_tmp, *arr[3]; unsigned int w = 0; unsigned int h = 0; const struct pipe_stencil_ref ref = { {1} }; /* Insufficient initialization checks. */ assert(p); assert(ppq); - assert(ppq->constbuf); assert(ppq->areamaptex); assert(ppq->inner_tmp); assert(ppq->shaders[n]); w = p->framebuffer.width; h = p->framebuffer.height; memset(, 0, sizeof(mstencil));
Re: [Mesa-dev] [PATCH 1/2] gallium/pp: use user constant buffers
On Wed, Apr 4, 2018 at 5:41 PM, Ilia Mirkinwrote: > While I don't see anything obviously wrong in this patch, I also don't > see any issues in the old code. What API misuse is this dealing with? > The constant buffer didn't follow the PIPE_CAP_CONSTBUF0_FLAGS rule. Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] gallium/pp: use user constant buffers
While I don't see anything obviously wrong in this patch, I also don't see any issues in the old code. What API misuse is this dealing with? On Wed, Apr 4, 2018 at 4:11 PM, Marek Olšákwrote: > From: Marek Olšák > > This fixes a radeonsi crash. > --- > src/gallium/auxiliary/cso_cache/cso_context.c | 17 > src/gallium/auxiliary/cso_cache/cso_context.h | 3 +++ > src/gallium/auxiliary/postprocess/pp_mlaa.c| 37 > -- > src/gallium/auxiliary/postprocess/pp_private.h | 1 - > 4 files changed, 25 insertions(+), 33 deletions(-) > > diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c > b/src/gallium/auxiliary/cso_cache/cso_context.c > index 3fa57f16ff4..3a3a63a3327 100644 > --- a/src/gallium/auxiliary/cso_cache/cso_context.c > +++ b/src/gallium/auxiliary/cso_cache/cso_context.c > @@ -1540,20 +1540,37 @@ cso_set_constant_buffer_resource(struct cso_context > *cso, >cb.buffer = buffer; >cb.buffer_offset = 0; >cb.buffer_size = buffer->width0; >cb.user_buffer = NULL; >cso_set_constant_buffer(cso, shader_stage, index, ); > } else { >cso_set_constant_buffer(cso, shader_stage, index, NULL); > } > } > > +void > +cso_set_constant_user_buffer(struct cso_context *cso, > + enum pipe_shader_type shader_stage, > + unsigned index, void *ptr, unsigned size) > +{ > + if (ptr) { > + struct pipe_constant_buffer cb; > + cb.buffer = NULL; > + cb.buffer_offset = 0; > + cb.buffer_size = size; > + cb.user_buffer = ptr; > + cso_set_constant_buffer(cso, shader_stage, index, ); > + } else { > + cso_set_constant_buffer(cso, shader_stage, index, NULL); > + } > +} > + > void > cso_save_constant_buffer_slot0(struct cso_context *cso, > enum pipe_shader_type shader_stage) > { > util_copy_constant_buffer(>aux_constbuf_saved[shader_stage], > >aux_constbuf_current[shader_stage]); > } > > void > cso_restore_constant_buffer_slot0(struct cso_context *cso, > diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h > b/src/gallium/auxiliary/cso_cache/cso_context.h > index b1bc0813442..3a4e808f0c0 100644 > --- a/src/gallium/auxiliary/cso_cache/cso_context.h > +++ b/src/gallium/auxiliary/cso_cache/cso_context.h > @@ -207,20 +207,23 @@ cso_set_shader_images(struct cso_context *cso, > > /* constant buffers */ > > void cso_set_constant_buffer(struct cso_context *cso, > enum pipe_shader_type shader_stage, > unsigned index, struct pipe_constant_buffer > *cb); > void cso_set_constant_buffer_resource(struct cso_context *cso, >enum pipe_shader_type shader_stage, >unsigned index, >struct pipe_resource *buffer); > +void cso_set_constant_user_buffer(struct cso_context *cso, > + enum pipe_shader_type shader_stage, > + unsigned index, void *ptr, unsigned size); > void cso_save_constant_buffer_slot0(struct cso_context *cso, > enum pipe_shader_type shader_stage); > void cso_restore_constant_buffer_slot0(struct cso_context *cso, > enum pipe_shader_type shader_stage); > > > /* drawing */ > > void > cso_draw_vbo(struct cso_context *cso, > diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c > b/src/gallium/auxiliary/postprocess/pp_mlaa.c > index 0edd01f3f5d..610cedbd1b3 100644 > --- a/src/gallium/auxiliary/postprocess/pp_mlaa.c > +++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c > @@ -50,76 +50,64 @@ > #include "util/u_inlines.h" > #include "util/u_memory.h" > #include "util/u_string.h" > #include "pipe/p_screen.h" > > #define IMM_SPACE 80 > > static float constants[] = { 1, 1, 0, 0 }; > static unsigned int dimensions[2] = { 0, 0 }; > > -/** Upload the constants. */ > -static void > -up_consts(struct pp_queue_t *ppq) > -{ > - struct pipe_context *pipe = ppq->p->pipe; > - > - pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE, > -0, sizeof(constants), constants); > -} > - > /** Run function of the MLAA filter. */ > static void > pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, > struct pipe_resource *out, unsigned int n, bool iscolor) > { > > struct pp_program *p = ppq->p; > > struct pipe_depth_stencil_alpha_state mstencil; > struct pipe_sampler_view v_tmp, *arr[3]; > > unsigned int w = 0; > unsigned int h = 0; > > const struct pipe_stencil_ref ref = { {1} }; > > /* Insufficient initialization checks. */ > assert(p); > assert(ppq); > - assert(ppq->constbuf); > assert(ppq->areamaptex); >
[Mesa-dev] [PATCH 1/2] gallium/pp: use user constant buffers
From: Marek OlšákThis fixes a radeonsi crash. --- src/gallium/auxiliary/cso_cache/cso_context.c | 17 src/gallium/auxiliary/cso_cache/cso_context.h | 3 +++ src/gallium/auxiliary/postprocess/pp_mlaa.c| 37 -- src/gallium/auxiliary/postprocess/pp_private.h | 1 - 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 3fa57f16ff4..3a3a63a3327 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1540,20 +1540,37 @@ cso_set_constant_buffer_resource(struct cso_context *cso, cb.buffer = buffer; cb.buffer_offset = 0; cb.buffer_size = buffer->width0; cb.user_buffer = NULL; cso_set_constant_buffer(cso, shader_stage, index, ); } else { cso_set_constant_buffer(cso, shader_stage, index, NULL); } } +void +cso_set_constant_user_buffer(struct cso_context *cso, + enum pipe_shader_type shader_stage, + unsigned index, void *ptr, unsigned size) +{ + if (ptr) { + struct pipe_constant_buffer cb; + cb.buffer = NULL; + cb.buffer_offset = 0; + cb.buffer_size = size; + cb.user_buffer = ptr; + cso_set_constant_buffer(cso, shader_stage, index, ); + } else { + cso_set_constant_buffer(cso, shader_stage, index, NULL); + } +} + void cso_save_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage) { util_copy_constant_buffer(>aux_constbuf_saved[shader_stage], >aux_constbuf_current[shader_stage]); } void cso_restore_constant_buffer_slot0(struct cso_context *cso, diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index b1bc0813442..3a4e808f0c0 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -207,20 +207,23 @@ cso_set_shader_images(struct cso_context *cso, /* constant buffers */ void cso_set_constant_buffer(struct cso_context *cso, enum pipe_shader_type shader_stage, unsigned index, struct pipe_constant_buffer *cb); void cso_set_constant_buffer_resource(struct cso_context *cso, enum pipe_shader_type shader_stage, unsigned index, struct pipe_resource *buffer); +void cso_set_constant_user_buffer(struct cso_context *cso, + enum pipe_shader_type shader_stage, + unsigned index, void *ptr, unsigned size); void cso_save_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage); void cso_restore_constant_buffer_slot0(struct cso_context *cso, enum pipe_shader_type shader_stage); /* drawing */ void cso_draw_vbo(struct cso_context *cso, diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c index 0edd01f3f5d..610cedbd1b3 100644 --- a/src/gallium/auxiliary/postprocess/pp_mlaa.c +++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c @@ -50,76 +50,64 @@ #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_string.h" #include "pipe/p_screen.h" #define IMM_SPACE 80 static float constants[] = { 1, 1, 0, 0 }; static unsigned int dimensions[2] = { 0, 0 }; -/** Upload the constants. */ -static void -up_consts(struct pp_queue_t *ppq) -{ - struct pipe_context *pipe = ppq->p->pipe; - - pipe->buffer_subdata(pipe, ppq->constbuf, PIPE_TRANSFER_WRITE, -0, sizeof(constants), constants); -} - /** Run function of the MLAA filter. */ static void pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, struct pipe_resource *out, unsigned int n, bool iscolor) { struct pp_program *p = ppq->p; struct pipe_depth_stencil_alpha_state mstencil; struct pipe_sampler_view v_tmp, *arr[3]; unsigned int w = 0; unsigned int h = 0; const struct pipe_stencil_ref ref = { {1} }; /* Insufficient initialization checks. */ assert(p); assert(ppq); - assert(ppq->constbuf); assert(ppq->areamaptex); assert(ppq->inner_tmp); assert(ppq->shaders[n]); w = p->framebuffer.width; h = p->framebuffer.height; memset(, 0, sizeof(mstencil)); cso_set_stencil_ref(p->cso, ); /* Init the pixel size constant */ if (dimensions[0] != p->framebuffer.width || dimensions[1] != p->framebuffer.height) { constants[0] = 1.0f / p->framebuffer.width; constants[1] = 1.0f / p->framebuffer.height; -