Skip to content
  • Kenneth Graunke's avatar
    iris: Allow slab-allocation of explicitly-coherent buffers · a204bd75
    Kenneth Graunke authored
    When I implemented the suballocator, I skipped it when the caller
    explicitly requested coherent buffers.  However, PIPE_USAGE_STAGING
    ends up implying BO_ALLOC_COHERENT, and staging buffers for transfer
    maps that use copies to avoid stalls are extremely common.
    
    The point of this restriction was to avoid allocating buffers with
    different coherency requirements out of the same slab.  We wouldn't
    want to have some require snooping, and others not want it.
    
    However, this is trivial on most systems.  On discrete, local memory
    is always non-coherent.  System memory is always coherent.  But it's
    always consistent.  Similarly, integrated GPUs with LLC always have
    coherent allocations, so they're fine too.  The only case that is
    troublesome is non-LLC integrated, where we have to manually enable
    snooping, and so there are two possible modes.
    
    So, we can enable the suballocator in all cases on discrete and LLC
    systems.  For non-LLC systems, this patch suballocates for buffers
    where coherency is the default (non-coherent), but falls back to using
    real BOs for the less common snooped case.  Someday, we could use two
    heaps for non-LLC, if we want to start suballocating snooped buffers.
    
    This moves 95% of the buffer allocations in a trace of Dota 2 from
    being allocated in real BOs to being suballocated.  This should not
    only be more memory efficient, but should also save on mmap calls.
    a204bd75