summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-04-04 16:04:30 -0400
committerMarek Olšák <[email protected]>2018-04-04 20:01:43 -0400
commit096942be2cb656a8f28b98905e1783adba3aae7f (patch)
tree852f111e8d4b11361839b3f10229af88d520fea9 /src/gallium/auxiliary
parentd9dc26c94e454385e2094727f4163e7ba4e20a7f (diff)
gallium/pp: use user constant buffers
This fixes a radeonsi crash. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105026
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c17
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h3
-rw-r--r--src/gallium/auxiliary/postprocess/pp_mlaa.c37
-rw-r--r--src/gallium/auxiliary/postprocess/pp_private.h1
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
@@ -1548,6 +1548,23 @@ cso_set_constant_buffer_resource(struct cso_context *cso,
}
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, &cb);
+ } 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)
{
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
@@ -214,6 +214,9 @@ 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,
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
@@ -57,16 +57,6 @@
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,
@@ -86,7 +76,6 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
/* Insufficient initialization checks. */
assert(p);
assert(ppq);
- assert(ppq->constbuf);
assert(ppq->areamaptex);
assert(ppq->inner_tmp);
assert(ppq->shaders[n]);
@@ -104,15 +93,14 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
constants[0] = 1.0f / p->framebuffer.width;
constants[1] = 1.0f / p->framebuffer.height;
- up_consts(ppq);
dimensions[0] = p->framebuffer.width;
dimensions[1] = p->framebuffer.height;
}
- cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_VERTEX,
- 0, ppq->constbuf);
- cso_set_constant_buffer_resource(p->cso, PIPE_SHADER_FRAGMENT,
- 0, ppq->constbuf);
+ cso_set_constant_user_buffer(p->cso, PIPE_SHADER_VERTEX,
+ 0, constants, sizeof(constants));
+ cso_set_constant_user_buffer(p->cso, PIPE_SHADER_FRAGMENT,
+ 0, constants, sizeof(constants));
mstencil.stencil[0].enabled = 1;
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
@@ -239,15 +227,6 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
return FALSE;
}
- ppq->constbuf = pipe_buffer_create(ppq->p->screen,
- PIPE_BIND_CONSTANT_BUFFER,
- PIPE_USAGE_DEFAULT,
- sizeof(constants));
- if (ppq->constbuf == NULL) {
- pp_debug("Failed to allocate constant buffer\n");
- goto fail;
- }
-
pp_debug("mlaa: using %u max search steps\n", val);
util_sprintf(tmp_text, "%s"
@@ -352,12 +331,6 @@ pp_jimenezmlaa_color(struct pp_queue_t *ppq, struct pipe_resource *in,
void
pp_jimenezmlaa_free(struct pp_queue_t *ppq, unsigned int n)
{
- if (ppq->areamaptex) {
- pipe_resource_reference(&ppq->areamaptex, NULL);
- }
-
- if (ppq->constbuf) {
- pipe_resource_reference(&ppq->constbuf, NULL);
- }
+ pipe_resource_reference(&ppq->areamaptex, NULL);
}
diff --git a/src/gallium/auxiliary/postprocess/pp_private.h b/src/gallium/auxiliary/postprocess/pp_private.h
index 0d032124115..710909b71e2 100644
--- a/src/gallium/auxiliary/postprocess/pp_private.h
+++ b/src/gallium/auxiliary/postprocess/pp_private.h
@@ -76,7 +76,6 @@ struct pp_queue_t
struct pipe_resource *depth; /* depth of original input */
struct pipe_resource *stencil; /* stencil shared by inner_tmps */
- struct pipe_resource *constbuf; /* MLAA constant buffer */
struct pipe_resource *areamaptex; /* MLAA area map texture */
struct pipe_surface *tmps[2], *inner_tmps[3], *stencils;