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>
This commit is contained in:
Marek Olšák
2020-12-26 12:01:10 -05:00
committed by Marge Bot
parent 0aa63c31ca
commit a51d4b10f1
59 changed files with 240 additions and 141 deletions

View File

@@ -48,6 +48,8 @@ buffers, surfaces) are bound to the driver.
type. index is used to indicate which buffer to set (some APIs may allow
multiple ones to be set, and binding a specific one later, though drivers
are mostly restricted to the first one right now).
If take_ownership is true, the buffer reference is passed to the driver, so
that the driver doesn't have to increment the reference count.
* ``set_inlinable_constants`` sets inlinable constants for constant buffer 0.