[Mesa-dev] [PATCH 1/2] st/mesa: add support for viewport index semantic

Ian Romanick idr at freedesktop.org
Tue Jan 21 15:19:59 PST 2014


On 01/20/2014 10:09 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This adds GS output and FS input support, even though FS input
> support isn't supported until GLSL 4.30 from what I can see.

Or GL_ARB_fragment_layer_viewport.  There's a bit of, IMO, a goof here.
 The FS input will have exactly the value written to the GS, even if
that value is invalid.  An implementation may only support 16 viewports,
but if the GS writes 0xDEADBEEF, the FS will read 0xDEADBEEF.

At least some hardware also passes this value around using fewer bits in
special payload registers.  This is how i965 works, for example.  It
means that we have to output the value twice if the FS reads it. :(  I'm
not sure if any other hardware works this way.

> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/mesa/state_tracker/st_program.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
> index 2d6d430..cdb6662 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -572,6 +572,11 @@ st_translate_fragment_program(struct st_context *st,
>              input_semantic_index[slot] = 0;
>              interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
>              break;
> +         case VARYING_SLOT_VIEWPORT:
> +            input_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
> +            input_semantic_index[slot] = 0;
> +            interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
> +            break;
>           case VARYING_SLOT_CLIP_DIST0:
>              input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
>              input_semantic_index[slot] = 0;
> @@ -1028,6 +1033,10 @@ st_translate_geometry_program(struct st_context *st,
>              gs_output_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
>              gs_output_semantic_index[slot] = 0;
>              break;
> +         case VARYING_SLOT_VIEWPORT:
> +            gs_output_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
> +            gs_output_semantic_index[slot] = 0;
> +            break;
>           case VARYING_SLOT_TEX0:
>           case VARYING_SLOT_TEX1:
>           case VARYING_SLOT_TEX2:
> 



More information about the mesa-dev mailing list