summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau/nvc0
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2020-12-26 12:01:10 -0500
committerMarge Bot <eric+marge@anholt.net>2021-01-27 23:53:34 +0000
commita51d4b10f1a056a7e8ff592c034575139d19211c (patch)
tree685ffdbb701887397d595b320d33ad0aa454e627 /src/gallium/drivers/nouveau/nvc0
parent0aa63c31ca807e8aaa01a75d918830ac87fc070c (diff)
gallium: add take_ownership param into set_constant_buffer to eliminate atomics
We often do this: pipe->set_constant_buffer(pipe, shader, slot, &cb); pipe_resource_reference(&cb->buffer, NULL); That results in atomic increment in set_constant_buffer followed by atomic decrement after set_constant_buffer. This new interface eliminates those atomics. For the case above, this should be used instead: pipe->set_constant_buffer(pipe, shader, slot, true, &cb); cb->buffer = NULL; // if cb is not a local variable, else do nothing AMD Zen benefits from this. The perf improvement is ~3% for Viewperf13/Catia. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0')
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_state.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
index c44c87bd370..a3a9fd1454f 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
@@ -774,6 +774,7 @@ nvc0_cp_state_bind(struct pipe_context *pipe, void *hwcso)
static void
nvc0_set_constant_buffer(struct pipe_context *pipe,
enum pipe_shader_type shader, uint index,
+ bool take_ownership,
const struct pipe_constant_buffer *cb)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
@@ -802,7 +803,13 @@ nvc0_set_constant_buffer(struct pipe_context *pipe,
if (nvc0->constbuf[s][i].u.buf)
nv04_resource(nvc0->constbuf[s][i].u.buf)->cb_bindings[s] &= ~(1 << i);
- pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, res);
+
+ if (take_ownership) {
+ pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL);
+ nvc0->constbuf[s][i].u.buf = res;
+ } else {
+ pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, res);
+ }
nvc0->constbuf[s][i].user = (cb && cb->user_buffer) ? true : false;
if (nvc0->constbuf[s][i].user) {