[Mesa-dev] [PATCH] r600g: Fix flat/smooth shade state toggle
Marek Olšák
maraeo at gmail.com
Wed Aug 20 11:16:50 PDT 2014
Generally, only states which need a full shader compilation must be in
the shader key. Flatshade is not one of them, because it only causes
register updates, so this is not a proper solution. Or I am missing
something?
Marek
On Wed, Aug 20, 2014 at 5:34 PM, Glenn Kennard <glenn.kennard at gmail.com> wrote:
> If only the flat/smooth shade state changed between
> two calls the prior code would miss updating the
> hardware state.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81967
> Signed-off-by: Glenn Kennard <glenn.kennard at gmail.com>
> ---
> Tested on radeon 6670, no piglit regressions
>
> src/gallium/drivers/r600/evergreen_state.c | 2 --
> src/gallium/drivers/r600/r600_shader.h | 2 +-
> src/gallium/drivers/r600/r600_state.c | 2 --
> src/gallium/drivers/r600/r600_state_common.c | 6 +++---
> 4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
> index 841ad0c..b490145 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -2927,8 +2927,6 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
> shader->ps_depth_export = z_export | stencil_export;
>
> shader->sprite_coord_enable = sprite_coord_enable;
> - if (rctx->rasterizer)
> - shader->flatshade = rctx->rasterizer->flatshade;
> }
>
> void evergreen_update_es_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h
> index d6db8f0..8b32966 100644
> --- a/src/gallium/drivers/r600/r600_shader.h
> +++ b/src/gallium/drivers/r600/r600_shader.h
> @@ -89,6 +89,7 @@ struct r600_shader_key {
> unsigned alpha_to_one:1;
> unsigned nr_cbufs:4;
> unsigned vs_as_es:1;
> + unsigned flatshade:1;
> };
>
> struct r600_shader_array {
> @@ -106,7 +107,6 @@ struct r600_pipe_shader {
> struct r600_command_buffer command_buffer; /* register writes */
> struct r600_resource *bo;
> unsigned sprite_coord_enable;
> - unsigned flatshade;
> unsigned pa_cl_vs_out_cntl;
> unsigned nr_ps_color_outputs;
> struct r600_shader_key key;
> diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
> index 607b199..3f5cb2b 100644
> --- a/src/gallium/drivers/r600/r600_state.c
> +++ b/src/gallium/drivers/r600/r600_state.c
> @@ -2532,8 +2532,6 @@ void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *sha
> shader->ps_depth_export = z_export | stencil_export;
>
> shader->sprite_coord_enable = sprite_coord_enable;
> - if (rctx->rasterizer)
> - shader->flatshade = rctx->rasterizer->flatshade;
> }
>
> void r600_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)
> diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
> index 7594d0e..d8243d1 100644
> --- a/src/gallium/drivers/r600/r600_state_common.c
> +++ b/src/gallium/drivers/r600/r600_state_common.c
> @@ -699,6 +699,8 @@ static INLINE struct r600_shader_key r600_shader_selector_key(struct pipe_contex
> /* Dual-source blending only makes sense with nr_cbufs == 1. */
> if (key.nr_cbufs == 1 && rctx->dual_src_blend)
> key.nr_cbufs = 2;
> + if (rctx->rasterizer->flatshade)
> + key.flatshade = 1;
> } else if (sel->type == PIPE_SHADER_VERTEX) {
> key.vs_as_es = (rctx->gs_shader != NULL);
> }
> @@ -1250,9 +1252,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
> }
>
> if (unlikely(!ps_dirty && rctx->ps_shader && rctx->rasterizer &&
> - ((rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable) ||
> - (rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade)))) {
> -
> + ((rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable)))) {
> if (rctx->b.chip_class >= EVERGREEN)
> evergreen_update_ps_state(ctx, rctx->ps_shader->current);
> else
> --
> 1.9.1
>
> _______________________________________________
> 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