On 08.01.2016 18:09, Ian Romanick wrote:
On 01/07/2016 04:57 PM, Nicolai Hähnle wrote:
From: Nicolai Hähnle <nicolai.haeh...@amd.com>

We will want to disable minmax index caching for buffers that are used in this
way.

I think this is too heavy handed.  It seems like what you want is to
disable caching of draws in the mapped range while it is mapped.  If an
app has a 16mb buffer, maps the last 8mb, unmaps it, then draws, it
would be a shame to lose the cache forever.  To avoid having to do all
the range checking in the draw and cache-invalidate code, you could just
clear the USAGE_PERSISTENT_WRITE_MAP bit in the unmap.  Right?

I like that idea. An alternative would be to just check the access flags in the cache itself, i.e. an additional check like:

if (bufferObj->Mappings[MAP_USER].AccessFlags &
    (GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT) ==
    (GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT))
   // don't use the cache

It's a few additional instructions in vbo_use_minmax_cache and a few instructions less in _mesa_map_buffer_range. That's probably a good trade-off, right?

Otherwise, perhaps the variable UsageHistory should be renamed if it contains non-sticky flags...

Cheers,
Nicolai


---
  src/mesa/main/bufferobj.c | 6 +++++-
  src/mesa/main/mtypes.h    | 1 +
  2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8fd9a06..ef2b495 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -2474,9 +2474,13 @@ _mesa_map_buffer_range(struct gl_context *ctx,
        assert(bufObj->Mappings[MAP_USER].AccessFlags == access);
     }

-   if (access & GL_MAP_WRITE_BIT)
+   if (access & GL_MAP_WRITE_BIT) {
        bufObj->Written = GL_TRUE;

+      if (access & GL_MAP_PERSISTENT_BIT)
+         bufObj->UsageHistory |= USAGE_PERSISTENT_WRITE_MAP;
+   }
+
  #ifdef VBO_DEBUG
     if (strstr(func, "Range") == NULL) { /* If not MapRange */
        printf("glMapBuffer(%u, sz %ld, access 0x%x)\n",
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9e4b2c8..4d625da 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1255,6 +1255,7 @@ typedef enum {
     USAGE_SHADER_STORAGE_BUFFER = 0x8,
     USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10,
     USAGE_PIXEL_PACK_BUFFER = 0x20,
+   USAGE_PERSISTENT_WRITE_MAP = 0x40,
  } gl_buffer_usage;




_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to