[Mesa-dev] [PATCH 1/3] gallium: add TGSI property NEXT_SHADER
Nicolai Hähnle
nhaehnle at gmail.com
Fri Mar 11 16:37:41 UTC 2016
Good idea. Series is
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
On 10.03.2016 12:36, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Radeonsi needs to know which shader stage will execute after a shader
> in order to make the best decision about which shader variant to compile
> first.
>
> This is only set for VS and TES, because we don't need it elsewhere.
>
> VS has 3 variants:
> - next shader is FS
> - next shader is GS
> - next shader is TCS
>
> TES has 2 variants:
> - next shader is FS
> - next shader is GS
>
> Currently, radeonsi always assumes the next shader is FS, which is suboptimal,
> since st/mesa always knows which shader is next if the GLSL program is not
> a "separate shader".
>
> By default, ureg always sets "next shader is FS".
> ---
> src/gallium/auxiliary/tgsi/tgsi_strings.c | 1 +
> src/gallium/auxiliary/tgsi/tgsi_ureg.c | 19 +++++++++++++++++++
> src/gallium/auxiliary/tgsi/tgsi_ureg.h | 2 ++
> src/gallium/docs/source/tgsi.rst | 7 +++++++
> src/gallium/include/pipe/p_shader_tokens.h | 3 ++-
> 5 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> index b15ae69..17c389f 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> @@ -144,6 +144,7 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
> "TES_POINT_MODE",
> "NUM_CLIPDIST_ENABLED",
> "NUM_CULLDIST_ENABLED",
> + "NEXT_SHADER",
> };
>
> const char *tgsi_return_type_names[TGSI_RETURN_TYPE_COUNT] =
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> index e1a7278..b0147fb 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> @@ -101,6 +101,7 @@ struct ureg_program
> {
> unsigned processor;
> bool supports_any_inout_decl_range;
> + int next_shader_processor;
>
> struct {
> unsigned semantic_name;
> @@ -1960,6 +1961,16 @@ const struct tgsi_token *ureg_finalize( struct ureg_program *ureg )
> {
> const struct tgsi_token *tokens;
>
> + switch (ureg->processor) {
> + case TGSI_PROCESSOR_VERTEX:
> + case TGSI_PROCESSOR_TESS_EVAL:
> + ureg_property(ureg, TGSI_PROPERTY_NEXT_SHADER,
> + ureg->next_shader_processor == -1 ?
> + TGSI_PROCESSOR_FRAGMENT :
> + ureg->next_shader_processor);
> + break;
> + }
> +
> emit_header( ureg );
> emit_decls( ureg );
> copy_instructions( ureg );
> @@ -2073,6 +2084,7 @@ ureg_create_with_screen(unsigned processor, struct pipe_screen *screen)
> screen->get_shader_param(screen,
> util_pipe_shader_from_tgsi_processor(processor),
> PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE) != 0;
> + ureg->next_shader_processor = -1;
>
> for (i = 0; i < Elements(ureg->properties); i++)
> ureg->properties[i] = ~0;
> @@ -2102,6 +2114,13 @@ no_ureg:
> }
>
>
> +void
> +ureg_set_next_shader_processor(struct ureg_program *ureg, unsigned processor)
> +{
> + ureg->next_shader_processor = processor;
> +}
> +
> +
> unsigned
> ureg_get_nr_outputs( const struct ureg_program *ureg )
> {
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> index 6a3b5dd..2e63c62 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> @@ -114,6 +114,8 @@ ureg_create_shader( struct ureg_program *,
> struct pipe_context *pipe,
> const struct pipe_stream_output_info *so );
>
> +void
> +ureg_set_next_shader_processor(struct ureg_program *ureg, unsigned processor);
>
> /* Alternately, return the built token stream and hand ownership of
> * that memory to the caller:
> diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
> index 489cbb0..1db88d7 100644
> --- a/src/gallium/docs/source/tgsi.rst
> +++ b/src/gallium/docs/source/tgsi.rst
> @@ -3206,6 +3206,13 @@ NUM_CULLDIST_ENABLED
>
> How many cull distance scalar outputs are enabled.
>
> +NEXT_SHADER
> +"""""""""""
> +
> +Which shader stage will MOST LIKELY follow after this shader when the shader
> +is bound. This is only a hint to the driver and doesn't have to be precise.
> +Only set for VS and TES.
> +
>
> Texture Sampling and Texture Formats
> ------------------------------------
> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
> index 9d4a96a..54b6127 100644
> --- a/src/gallium/include/pipe/p_shader_tokens.h
> +++ b/src/gallium/include/pipe/p_shader_tokens.h
> @@ -277,7 +277,8 @@ union tgsi_immediate_data
> #define TGSI_PROPERTY_TES_POINT_MODE 14
> #define TGSI_PROPERTY_NUM_CLIPDIST_ENABLED 15
> #define TGSI_PROPERTY_NUM_CULLDIST_ENABLED 16
> -#define TGSI_PROPERTY_COUNT 17
> +#define TGSI_PROPERTY_NEXT_SHADER 17
> +#define TGSI_PROPERTY_COUNT 18
>
> struct tgsi_property {
> unsigned Type : 4; /**< TGSI_TOKEN_TYPE_PROPERTY */
>
More information about the mesa-dev
mailing list