gallium: add take_ownership param into set_vertex_buffers to eliminate atomics
authorMarek Olšák <marek.olsak@amd.com>
Sat, 26 Dec 2020 22:29:45 +0000 (17:29 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 Jan 2021 23:53:35 +0000 (23:53 +0000)
commit27dcb466293f2ab3f80a141fd0b8c14617a8e37f
treebfa6ac1a675fa85d225bb83a4e9f093ffed110b5
parentb688ea31fcf7e20436c0a44f57eaca6f6c6418f3
gallium: add take_ownership param into set_vertex_buffers to eliminate atomics

There are a few places (mainly u_threaded_context) that do:
   set_vertex_buffers(...);
   for (i = 0; i < count; i++)
      pipe_resource_reference(&buffers[i].resource.buffer, NULL);

set_vertex_buffers increments the reference counts while the loop
decrements them.

This commit eliminates those reference count changes by adding a parameter
into set_vertex_buffers that tells the callee to accept all buffers
without incrementing the reference counts.

AMD Zen benefits from this because it has slow atomics if they come from
different CCXs.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
64 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/driver_ddebug/dd_context.c
src/gallium/auxiliary/driver_noop/noop_state.c
src/gallium/auxiliary/driver_rbug/rbug_context.c
src/gallium/auxiliary/driver_trace/tr_context.c
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/postprocess/pp_run.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_draw_quad.c
src/gallium/auxiliary/util/u_helpers.c
src/gallium/auxiliary/util/u_helpers.h
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/auxiliary/util/u_vbuf.c
src/gallium/auxiliary/vl/vl_bicubic_filter.c
src/gallium/auxiliary/vl/vl_compositor_gfx.c
src/gallium/auxiliary/vl/vl_deint_filter.c
src/gallium/auxiliary/vl/vl_matrix_filter.c
src/gallium/auxiliary/vl/vl_median_filter.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/drivers/d3d12/d3d12_context.cpp
src/gallium/drivers/etnaviv/etnaviv_state.c
src/gallium/drivers/freedreno/freedreno_blitter.c
src/gallium/drivers/freedreno/freedreno_state.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/iris/iris_state.c
src/gallium/drivers/lima/lima_state.c
src/gallium/drivers/llvmpipe/lp_state_vertex.c
src/gallium/drivers/nouveau/nv30/nv30_state.c
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r600/r600_pipe_common.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/softpipe/sp_state_vertex.c
src/gallium/drivers/svga/svga_pipe_vertex.c
src/gallium/drivers/swr/swr_state.cpp
src/gallium/drivers/tegra/tegra_context.c
src/gallium/drivers/v3d/v3dx_state.c
src/gallium/drivers/vc4/vc4_state.c
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/zink/zink_context.c
src/gallium/frontends/lavapipe/lvp_execute.c
src/gallium/frontends/nine/nine_state.c
src/gallium/include/pipe/p_context.h
src/gallium/tests/graw/fs-fragcoord.c
src/gallium/tests/graw/fs-frontface.c
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/fs-write-z.c
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/occlusion-query.c
src/gallium/tests/graw/quad-sample.c
src/gallium/tests/graw/quad-tex.c
src/gallium/tests/graw/shader-leak.c
src/gallium/tests/graw/tex-srgb.c
src/gallium/tests/graw/tex-swizzle.c
src/gallium/tests/graw/tri-gs.c
src/gallium/tests/graw/tri-instanced.c
src/gallium/tests/graw/tri-large.c
src/gallium/tests/graw/tri.c
src/gallium/tests/graw/vs-test.c