[Mesa-dev] [PATCH] st/mesa: Reduce array updates due to current changes.
From: Mathias Fröhlich Hi Brian, Following a small optimization in the gallium state tracker to avoid flagging ST_NEW_VERTEX_ARRAYS a bit more often: please review! best Mathias 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. Signed-off-by: Mathias Fröhlich --- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_context.h | 9 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0a0bd8ba1ca..45451531df9 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -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. */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index ed69e3d4873..324a7f24178 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -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)) -- 2.20.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: Reduce array updates due to current changes.
Reviewed-by: Marek Olšák Marek On Sun, Feb 24, 2019 at 1:46 AM wrote: > From: Mathias Fröhlich > > Hi Brian, > > Following a small optimization in the gallium state tracker to > avoid flagging ST_NEW_VERTEX_ARRAYS a bit more often: > > please review! > > best > > Mathias > > > > > 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. > > Signed-off-by: Mathias Fröhlich > --- > src/mesa/state_tracker/st_context.c | 2 +- > src/mesa/state_tracker/st_context.h | 9 + > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/state_tracker/st_context.c > b/src/mesa/state_tracker/st_context.c > index 0a0bd8ba1ca..45451531df9 100644 > --- a/src/mesa/state_tracker/st_context.c > +++ b/src/mesa/state_tracker/st_context.c > @@ -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. */ > diff --git a/src/mesa/state_tracker/st_context.h > b/src/mesa/state_tracker/st_context.h > index ed69e3d4873..324a7f24178 100644 > --- a/src/mesa/state_tracker/st_context.h > +++ b/src/mesa/state_tracker/st_context.h > @@ -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)) > > -- > 2.20.1 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: Reduce array updates due to current changes.
LGTM too. Reviewed-by: Brian Paul On Sun, Feb 24, 2019 at 1:46 AM wrote: > From: Mathias Fröhlich > > Hi Brian, > > Following a small optimization in the gallium state tracker to > avoid flagging ST_NEW_VERTEX_ARRAYS a bit more often: > > please review! > > best > > Mathias > > > > > 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. > > Signed-off-by: Mathias Fröhlich > --- > src/mesa/state_tracker/st_context.c | 2 +- > src/mesa/state_tracker/st_context.h | 9 + > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/state_tracker/st_context.c > b/src/mesa/state_tracker/st_context.c > index 0a0bd8ba1ca..45451531df9 100644 > --- a/src/mesa/state_tracker/st_context.c > +++ b/src/mesa/state_tracker/st_context.c > @@ -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. */ > diff --git a/src/mesa/state_tracker/st_context.h > b/src/mesa/state_tracker/st_context.h > index ed69e3d4873..324a7f24178 100644 > --- a/src/mesa/state_tracker/st_context.h > +++ b/src/mesa/state_tracker/st_context.h > @@ -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)) > > -- > 2.20.1 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] st/mesa: Reduce array updates due to current changes.
Hi, Thanks, Brian and Marek for the review! best Mathias On Monday, 25 February 2019 22:44:37 CET Marek Olšák wrote: > Reviewed-by: Marek Olšák > > Marek > > On Sun, Feb 24, 2019 at 1:46 AM wrote: > > > From: Mathias Fröhlich > > > > Hi Brian, > > > > Following a small optimization in the gallium state tracker to > > avoid flagging ST_NEW_VERTEX_ARRAYS a bit more often: > > > > please review! > > > > best > > > > Mathias > > > > > > > > > > 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. > > > > Signed-off-by: Mathias Fröhlich > > --- > > src/mesa/state_tracker/st_context.c | 2 +- > > src/mesa/state_tracker/st_context.h | 9 + > > 2 files changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/src/mesa/state_tracker/st_context.c > > b/src/mesa/state_tracker/st_context.c > > index 0a0bd8ba1ca..45451531df9 100644 > > --- a/src/mesa/state_tracker/st_context.c > > +++ b/src/mesa/state_tracker/st_context.c > > @@ -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. */ > > diff --git a/src/mesa/state_tracker/st_context.h > > b/src/mesa/state_tracker/st_context.h > > index ed69e3d4873..324a7f24178 100644 > > --- a/src/mesa/state_tracker/st_context.h > > +++ b/src/mesa/state_tracker/st_context.h > > @@ -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)) > > > > -- > > 2.20.1 > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev