On Tue, May 30, 2017 at 10:36 PM, Samuel Pitoiset <samuel.pitoi...@gmail.com> wrote: > For each texture/image handles, we need to allocate a new > buffer for the bindless descriptor. But when the number of > buffers added to the current CS becomes high, the overhead > in the winsys (and in the kernel) is important. > > To reduce this bottleneck, the idea is to suballocate the > bindless descriptors using a slab similar to the one used > in the winsys. > > Currently, a buffer can hold 1024 bindless descriptors but > this limit is arbitrary and could be changed in the future > for some reasons. Once a slab is allocated the "base" buffer > is added to a per-context list. > > v2: - rename si_resident_descriptor to si_bindless_descriptor > - make can_reclaim_slab() returns false, always > - use util_dynarray_* > > Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> > --- > src/gallium/drivers/radeonsi/si_descriptors.c | 84 > +++++++++++++++++++++++++++ > src/gallium/drivers/radeonsi/si_pipe.c | 12 ++++ > src/gallium/drivers/radeonsi/si_pipe.h | 15 +++++ > src/gallium/drivers/radeonsi/si_state.h | 8 +++ > 4 files changed, 119 insertions(+) > > diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c > b/src/gallium/drivers/radeonsi/si_descriptors.c > index 3e78dd205b..b2e2e4b760 100644 > --- a/src/gallium/drivers/radeonsi/si_descriptors.c > +++ b/src/gallium/drivers/radeonsi/si_descriptors.c > @@ -2046,6 +2046,90 @@ void si_emit_compute_shader_userdata(struct si_context > *sctx) > sctx->shader_pointers_dirty &= ~compute_mask; > } > > +/* BINDLESS */ > + > +struct si_bindless_descriptor_slab > +{ > + struct pb_slab base; > + struct r600_resource *buffer; > + struct si_bindless_descriptor *entries; > +}; > + > +bool si_bindless_descriptor_can_reclaim_slab(void *priv, > + struct pb_slab_entry *entry) > +{ > + /* Do not allow to reclaim any bindless descriptors for now because > the > + * GPU might be using them. This should be improved later on. > + */ > + return false; > +} > + > +struct pb_slab *si_bindless_descriptor_slab_alloc(void *priv, unsigned heap, > + unsigned entry_size, > + unsigned group_index) > +{ > + struct si_context *sctx = priv; > + struct si_screen *sscreen = sctx->screen; > + struct si_bindless_descriptor_slab *slab; > + > + slab = CALLOC_STRUCT(si_bindless_descriptor_slab); > + if (!slab) > + return NULL; > + > + /* Create a buffer in VRAM for 1024 bindless descriptors. */ > + slab->buffer = (struct r600_resource *) > + pipe_buffer_create(&sscreen->b.b, 0, > + PIPE_USAGE_IMMUTABLE, 64 * 1024);
PIPE_USAGE_DEFAULT would be better here. (even though it's the same) Marek _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev