[Mesa-dev] [PATCH 05/53] r600: use a macro to remove common shader selection code.

Oded Gabbay oded.gabbay at gmail.com
Mon Nov 30 04:20:38 PST 2015


On Mon, Nov 30, 2015 at 8:20 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This function is going to get a lot messier with tessellation
> so I'm going to use some macros to try and clean some bits
> of common code up.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/gallium/drivers/r600/r600_state_common.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
> index b544abb..b6d739d 100644
> --- a/src/gallium/drivers/r600/r600_state_common.c
> +++ b/src/gallium/drivers/r600/r600_state_common.c
> @@ -1288,6 +1288,11 @@ static void r600_update_clip_state(struct r600_context *rctx,
>                                 r600_mark_atom_dirty(rctx, &rctx->clip_misc_state.atom);
>         }
>  }
> +#define SELECT_SHADER_OR_FAIL(x) do {                                  \
> +               r600_shader_select(ctx, rctx->x##_shader, &x##_dirty);  \
> +               if (unlikely(!rctx->x##_shader))                        \

Isn't the above statement missing the "->current" reference ?


> +                       return false;                                   \
> +       } while(0)
>
>  static bool r600_update_derived_state(struct r600_context *rctx)
>  {
> @@ -1310,16 +1315,12 @@ static bool r600_update_derived_state(struct r600_context *rctx)
>                 }
>         }
>
> -       r600_shader_select(ctx, rctx->ps_shader, &ps_dirty);
> -       if (unlikely(!rctx->ps_shader->current))
> -               return false;
> +       SELECT_SHADER_OR_FAIL(ps);
>
>         update_gs_block_state(rctx, rctx->gs_shader != NULL);
>
>         if (rctx->gs_shader) {
> -               r600_shader_select(ctx, rctx->gs_shader, &gs_dirty);
> -               if (unlikely(!rctx->gs_shader->current))
> -                       return false;
> +               SELECT_SHADER_OR_FAIL(gs);
>
>                 if (!rctx->shader_stages.geom_enable) {
>                         rctx->shader_stages.geom_enable = true;
> @@ -1335,9 +1336,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
>                         rctx->b.streamout.enabled_stream_buffers_mask = rctx->gs_shader->current->gs_copy_shader->enabled_stream_buffers_mask;
>                 }
>
> -               r600_shader_select(ctx, rctx->vs_shader, &vs_dirty);
> -               if (unlikely(!rctx->vs_shader->current))
> -                       return false;
> +               SELECT_SHADER_OR_FAIL(vs);
>
>                 /* vs_shader is used as ES */
>                 if (unlikely(vs_dirty || rctx->hw_shader_stages[R600_HW_STAGE_ES].shader != rctx->vs_shader->current)) {
> @@ -1351,9 +1350,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
>                         r600_mark_atom_dirty(rctx, &rctx->shader_stages.atom);
>                 }
>
> -               r600_shader_select(ctx, rctx->vs_shader, &vs_dirty);
> -               if (unlikely(!rctx->vs_shader->current))
> -                       return false;
> +               SELECT_SHADER_OR_FAIL(vs);
>
>                 if (unlikely(vs_dirty || rctx->hw_shader_stages[R600_HW_STAGE_VS].shader != rctx->vs_shader->current)) {
>                         update_shader_atom(ctx, &rctx->hw_shader_stages[R600_HW_STAGE_VS], rctx->vs_shader->current);
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list