[Mesa-dev] Mesa (master): gallium: introduce GLSL based interpolation rules. (v2)

Brian Paul brianp at vmware.com
Tue Jan 10 07:34:57 PST 2012


On 01/10/2012 04:56 AM, Dave Airlie wrote:
> Module: Mesa
> Branch: master
> Commit: 67e3cbf1632e361220234013147331e4618b70cb
> URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=67e3cbf1632e361220234013147331e4618b70cb
>
> Author: Dave Airlie<airlied at redhat.com>
> Date:   Mon Jan  9 15:57:02 2012 +0000
>
> gallium: introduce GLSL based interpolation rules. (v2)
>
> This introduces an unspecified interpolation paramter that is only allowed for
> color semantics, so a specified GLSL interpolation will override the ShadeModel
> specified interpolation, but not vice-versa.
>
> This fixes a lot of the interpolation tests in piglit.
>
> v2: rename from unspecified to color
>
> Signed-off-by: Dave Airlie<airlied at redhat.com>
>
> ---
>
>   src/gallium/auxiliary/tgsi/tgsi_exec.c          |    4 ++++
>   src/gallium/auxiliary/tgsi/tgsi_exec.h          |    2 +-
>   src/gallium/auxiliary/tgsi/tgsi_strings.c       |    3 ++-
>   src/gallium/drivers/softpipe/sp_quad_fs.c       |    1 +
>   src/gallium/drivers/softpipe/sp_state_derived.c |   10 ++++++++--
>   src/gallium/include/pipe/p_shader_tokens.h      |    3 ++-
>   src/mesa/state_tracker/st_program.c             |    2 +-
>   7 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> index 3e2b899..52d4ff4 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> @@ -2371,6 +2371,10 @@ exec_declaration(struct tgsi_exec_machine *mach,
>                  eval = eval_perspective_coef;
>                  break;
>
> +            case TGSI_INTERPOLATE_COLOR:
> +               eval = mach->flatshade_color ? eval_constant_coef : eval_perspective_coef;
> +               break;
> +
>               default:
>                  assert(0);
>                  return;
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> index 223da2c..0817e14 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> @@ -263,7 +263,7 @@ struct tgsi_exec_machine
>      const struct tgsi_interp_coef *InterpCoefs;
>      struct tgsi_exec_vector       QuadPos;
>      float                         Face;    /**<  +1 if front facing, -1 if back facing */
> -
> +   bool                          flatshade_color;
>      /* Conditional execution masks */
>      uint CondMask;  /**<  For IF/ELSE/ENDIF */
>      uint LoopMask;  /**<  For BGNLOOP/ENDLOOP */
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> index aa12493..de9152d 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> @@ -117,7 +117,8 @@ const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT] =
>   {
>      "CONSTANT",
>      "LINEAR",
> -   "PERSPECTIVE"
> +   "PERSPECTIVE",
> +   "COLOR"
>   };
>
>   const char *tgsi_primitive_names[PIPE_PRIM_MAX] =
> diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
> index 7b08cd0..7800ba8 100644
> --- a/src/gallium/drivers/softpipe/sp_quad_fs.c
> +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
> @@ -74,6 +74,7 @@ shade_quad(struct quad_stage *qs, struct quad_header *quad)
>      struct tgsi_exec_machine *machine = softpipe->fs_machine;
>
>      /* run shader */
> +   machine->flatshade_color = softpipe->rasterizer->flatshade ? TRUE : FALSE;
>      return softpipe->fs_variant->run( softpipe->fs_variant, machine, quad );
>   }
>
> diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
> index 5685997..7b2b04e 100644
> --- a/src/gallium/drivers/softpipe/sp_state_derived.c
> +++ b/src/gallium/drivers/softpipe/sp_state_derived.c
> @@ -100,6 +100,9 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
>            case TGSI_INTERPOLATE_PERSPECTIVE:
>               interp = INTERP_PERSPECTIVE;
>               break;
> +         case TGSI_INTERPOLATE_COLOR:
> +            assert(fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR);
> +            break;
>            default:
>               assert(0);
>               interp = INTERP_LINEAR;
> @@ -111,8 +114,11 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
>               break;
>
>            case TGSI_SEMANTIC_COLOR:
> -            if (softpipe->rasterizer->flatshade) {
> -               interp = INTERP_CONSTANT;
> +            if (fsInfo->input_interpolate[i] == TGSI_INTERPOLATE_COLOR) {
> +               if (softpipe->rasterizer->flatshade)
> +                  interp = INTERP_CONSTANT;
> +               else
> +                  interp = INTERP_PERSPECTIVE;
>               }
>               break;
>            }
> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
> index 2fbe1df..cb1e698 100644
> --- a/src/gallium/include/pipe/p_shader_tokens.h
> +++ b/src/gallium/include/pipe/p_shader_tokens.h
> @@ -100,7 +100,8 @@ enum tgsi_file_type {
>   #define TGSI_INTERPOLATE_CONSTANT      0
>   #define TGSI_INTERPOLATE_LINEAR        1
>   #define TGSI_INTERPOLATE_PERSPECTIVE   2
> -#define TGSI_INTERPOLATE_COUNT         3
> +#define TGSI_INTERPOLATE_COLOR         3 /* special color case for smooth/flat */
> +#define TGSI_INTERPOLATE_COUNT         4
>
>   #define TGSI_CYLINDRICAL_WRAP_X (1<<  0)
>   #define TGSI_CYLINDRICAL_WRAP_Y (1<<  1)
> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
> index 8d7469d..8d08b2b 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -441,7 +441,7 @@ st_translate_interp(enum glsl_interp_qualifier glsl_qual, bool is_color)
>      switch (glsl_qual) {
>      case INTERP_QUALIFIER_NONE:
>         if (is_color)
> -         return TGSI_INTERPOLATE_LINEAR;
> +         return TGSI_INTERPOLATE_COLOR;
>         return TGSI_INTERPOLATE_PERSPECTIVE;
>      case INTERP_QUALIFIER_SMOOTH:
>         return TGSI_INTERPOLATE_PERSPECTIVE;
>

In the commit message: "paramter" -> "parameter"

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list