[Mesa-dev] [PATCH v2 7/7] i965: Reemit vertex state between indirect multi draws

Anuj Phogat anuj.phogat at gmail.com
Tue Dec 22 14:59:00 PST 2015


On Wed, Dec 16, 2015 at 3:47 PM, Kristian Høgsberg <krh at bitplanet.net> wrote:
> From: Kristian Høgsberg Kristensen <krh at bitplanet.net>
>
> If we're doing an indirect draw, prims[i].basevertex is always 0 and the
> real base vertex value is in the indirect parameter buffer. We try to
> avoid flagging BRW_NEW_VERTICES if prims[i].basevertex doesn't change,
> which then breaks down for indirect draws. Thus, if a program uses base
> vertex or base instance, and the draw call is indirect, always flag
> BRW_NEW_VERTICES.  A new piglit test,
> spec/ARB_shader_draw_parameters/drawid-indirect-vertexid tests this.
> ---
>  src/mesa/drivers/dri/i965/brw_draw.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
> index b0a162a..8737c64 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
> @@ -491,9 +491,29 @@ brw_try_draw_prims(struct gl_context *ctx,
>           }
>        }
>
> -      brw->draw.params.gl_basevertex =
> +      /* Determine if we need to flag BRW_NEW_VERTICES for updating the
> +       * gl_BaseVertexARB or gl_BaseInstanceARB values. For indirect draw, we
> +       * always flag if the shader uses one of the values. For direct draws,
> +       * we only flag if the values change.
> +       */
> +      const int new_basevertex =
>           prims[i].indexed ? prims[i].basevertex : prims[i].start;
> -      brw->draw.params.gl_baseinstance = prims[i].base_instance;
> +      const int new_baseinstance = prims[i].base_instance;
> +      if (i > 0) {
> +         const bool uses_draw_parameters =
> +            brw->vs.prog_data->uses_basevertex ||
> +            brw->vs.prog_data->uses_baseinstance;
> +
> +         if ((uses_draw_parameters && prims[i].is_indirect) ||
> +             (brw->vs.prog_data->uses_basevertex &&
> +              brw->draw.params.gl_basevertex != new_basevertex) ||
> +             (brw->vs.prog_data->uses_baseinstance &&
> +              brw->draw.params.gl_baseinstance != new_baseinstance))
> +            brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
> +      }
> +
> +      brw->draw.params.gl_basevertex = new_basevertex;
> +      brw->draw.params.gl_baseinstance = new_baseinstance;
>        drm_intel_bo_unreference(brw->draw.draw_params_bo);
>
>        if (prims[i].is_indirect) {
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list