st/mesa: use buffer usage history to set dirty flags for revalidation
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 4 Jun 2016 17:26:46 +0000 (13:26 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 8 Jun 2016 02:27:04 +0000 (22:27 -0400)
We were previously unconditionally doing this for arrays and ubo's, and
ignoring texture/storage/atomic buffers. Instead use the usage history
to determine which atoms need to be revalidated.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/mesa/state_tracker/st_cb_bufferobjects.c

index 8bbc2f0af4b201aae538a0e4cc47a25fc9fc14c6..1a8aea3c198fd8d142bedafe515134a7f75b1c7c 100644 (file)
@@ -332,8 +332,19 @@ st_bufferobj_data(struct gl_context *ctx,
       }
    }
 
-   /* BufferData may change an array or uniform buffer, need to update it */
-   st->dirty.st |= ST_NEW_VERTEX_ARRAYS | ST_NEW_UNIFORM_BUFFER;
+   /* The current buffer may be bound, so we have to revalidate all atoms that
+    * might be using it.
+    */
+   /* TODO: Add arrays to usage history */
+   st->dirty.st |= ST_NEW_VERTEX_ARRAYS;
+   if (st_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER)
+      st->dirty.st |= ST_NEW_UNIFORM_BUFFER;
+   if (st_obj->Base.UsageHistory & USAGE_SHADER_STORAGE_BUFFER)
+      st->dirty.st |= ST_NEW_STORAGE_BUFFER;
+   if (st_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER)
+      st->dirty.st |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
+   if (st_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER)
+      st->dirty.st |= ST_NEW_ATOMIC_BUFFER;
 
    return GL_TRUE;
 }