[Mesa-dev,4/4] i965: Orphan storage in MapBufferRange if invalidating all valid data.

Submitted by Kenneth Graunke on June 13, 2017, 12:33 a.m.

Details

Message ID 20170613003332.14106-4-kenneth@whitecape.org
State New
Headers show
Series "Series without cover letter" ( rev: 2 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Kenneth Graunke June 13, 2017, 12:33 a.m.
We can promote INVALIDATE_RANGE_BIT to INVALIDATE_BUFFER_BIT if the
range contains the only valid data in the buffer.  This allows us to
orphan the storage, instead of doing stall avoidance blits.
---
 src/mesa/drivers/dri/i965/intel_buffer_objects.c | 7 +++++++
 1 file changed, 7 insertions(+)

I don't have any performance data for this.

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
index 09c18db1afe..c305539e1b5 100644
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
@@ -371,6 +371,13 @@  brw_map_buffer_range(struct gl_context *ctx,
       return NULL;
    }
 
+   if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
+       (length == obj->Size ||
+        (intel_obj->valid_data_start >= offset &&
+         intel_obj->valid_data_end <= offset + length))) {
+      access |= GL_MAP_INVALIDATE_BUFFER_BIT;
+   }
+
    /* If the access is synchronized (like a normal buffer mapping), then get
     * things flushed out so the later mapping syncs appropriately through GEM.
     * If the user doesn't care about existing buffer contents and mapping would

Comments

Quoting Kenneth Graunke (2017-06-13 01:33:32)
> We can promote INVALIDATE_RANGE_BIT to INVALIDATE_BUFFER_BIT if the
> range contains the only valid data in the buffer.  This allows us to
> orphan the storage, instead of doing stall avoidance blits.
> ---
>  src/mesa/drivers/dri/i965/intel_buffer_objects.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> I don't have any performance data for this.
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> index 09c18db1afe..c305539e1b5 100644
> --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> @@ -371,6 +371,13 @@ brw_map_buffer_range(struct gl_context *ctx,
>        return NULL;
>     }
>  
> +   if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
> +       (length == obj->Size ||
> +        (intel_obj->valid_data_start >= offset &&
> +         intel_obj->valid_data_end <= offset + length))) {
> +      access |= GL_MAP_INVALIDATE_BUFFER_BIT;

Lgtm, but repetition here could be moved to a helper.
-Chris
Do you have any data on how much this helps?  Regardless, the series is

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>

On Mon, Jun 12, 2017 at 5:33 PM, Kenneth Graunke <kenneth@whitecape.org>
wrote:

> We can promote INVALIDATE_RANGE_BIT to INVALIDATE_BUFFER_BIT if the
> range contains the only valid data in the buffer.  This allows us to
> orphan the storage, instead of doing stall avoidance blits.
> ---
>  src/mesa/drivers/dri/i965/intel_buffer_objects.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> I don't have any performance data for this.
>
> diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> index 09c18db1afe..c305539e1b5 100644
> --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> @@ -371,6 +371,13 @@ brw_map_buffer_range(struct gl_context *ctx,
>        return NULL;
>     }
>
> +   if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
> +       (length == obj->Size ||
> +        (intel_obj->valid_data_start >= offset &&
> +         intel_obj->valid_data_end <= offset + length))) {
> +      access |= GL_MAP_INVALIDATE_BUFFER_BIT;
> +   }
> +
>     /* If the access is synchronized (like a normal buffer mapping), then
> get
>      * things flushed out so the later mapping syncs appropriately through
> GEM.
>      * If the user doesn't care about existing buffer contents and mapping
> would
> --
> 2.13.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
On Thursday, July 13, 2017 3:04:59 PM PDT Jason Ekstrand wrote:
> Do you have any data on how much this helps?  Regardless, the series is
> 
> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>

Thanks!  It turns out that, no, I don't have any data on this patch.

I'd originally found it helpful, but I had been testing a broken version
which assumed that GL_MAP_WRITE_BIT implied the mapped region would be
overwritten...but it doesn't, unless you have GL_MAP_INVALIDATE_RANGE_BIT.

With that fixed, I'm not seeing this condition ever trigger in any of the
workloads I looked at.

It still seems like the right thing to do, but maybe I should hold off for
now.  (I should also implement InvalidateBufferSubData...)

Patches 1-3 are still definitely useful.