Gallium interface and u_upload_mgr changes to eliminate atomics and unbind resources efficiently
This MR depends on and contains !8180 (merged), which is squashed into 1 commit here.
This is a very large improvement in CPU overhead mainly due to the elimination of atomic ops for reference counting. When I saw the results in my CPU profiler, my jaw dropped.
The Gallium interface is changed as follows:
- Many
pipe_context
functions have their parameter types changed fromunsigned
toubyte
. - Changes that make resource unbinding more efficient:
-
set_vertex_buffers
gets new parameterunbind_num_trailing_slots
, which unbinds slots after start + count while binding buffers at the same time. -
set_shader_images
gets new parameterunbind_num_trailing_slots
-
set_sampler_views
gets new parameterunbind_num_trailing_slots
-
- Changes that totally eliminate refcount atomics from st/mesa and u_threaded_context, improving performance significantly on some CPU architectures:
-
set_constant_buffer
gets new parametertake_ownership
, meaning the driver shouldn't increment the reference count of the buffer. This is used to pass a buffer from st/mesa through u_threaded_context into the driver without touching the reference count on the way. -
set_vertex_buffers
gets new parametertake_ownership
, meaning the driver shouldn't increment the reference counts of the buffers. - Added
pipe_draw_info::take_index_buffer_ownership
, meaning the driver should decrement the reference count of the index buffer indraw_vbo
. Only used whenu_threaded_context
is used.
-
Additionally, all refcount atomic ops in u_upload_mgr
are eliminated when returning buffers to callers. There are also other small improvements in this MR.
Edited by Marek Olšák