st/mesa: Reduce array updates due to current changes.
authorMathias Fröhlich <mathias.froehlich@web.de>
Sat, 22 Dec 2018 15:49:16 +0000 (16:49 +0100)
committerMathias Fröhlich <mathias.froehlich@web.de>
Tue, 26 Feb 2019 04:42:04 +0000 (05:42 +0100)
Since using bitmasks we can easily check if we have any
current value that is potentially uploaded on array setup.
So check for any potential vertex program input that is not
already a vao enabled array. Only flag array update if there is
a potential overlap.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_context.h

index 0a0bd8ba1ca6d2cc946a1bce798751f1de21d7d8..45451531df927ea8a94b4dabc046d66d5111714f 100644 (file)
@@ -224,7 +224,7 @@ st_invalidate_state(struct gl_context *ctx)
    if (new_state & _NEW_PIXEL)
       st->dirty |= ST_NEW_PIXEL_TRANSFER;
 
-   if (new_state & _NEW_CURRENT_ATTRIB)
+   if (new_state & _NEW_CURRENT_ATTRIB && st_vp_uses_current_values(ctx))
       st->dirty |= ST_NEW_VERTEX_ARRAYS;
 
    /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
index ed69e3d4873806a584ed7d52a149f666b5e52f6c..324a7f241782c7d5f3f98f8d03aed1b63d725645 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef ST_CONTEXT_H
 #define ST_CONTEXT_H
 
+#include "main/arrayobj.h"
 #include "main/mtypes.h"
 #include "state_tracker/st_api.h"
 #include "main/fbobject.h"
@@ -398,6 +399,14 @@ st_user_clip_planes_enabled(struct gl_context *ctx)
           ctx->Transform.ClipPlanesEnabled;
 }
 
+
+static inline bool
+st_vp_uses_current_values(const struct gl_context *ctx)
+{
+   const uint64_t inputs = ctx->VertexProgram._Current->info.inputs_read;
+   return _mesa_draw_current_bits(ctx) & inputs;
+}
+
 /** clear-alloc a struct-sized object, with casting */
 #define ST_CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))