[Mesa-dev] [PATCH] tgsi: pass a shader type to the machine create and clean up.

Brian Paul brianp at vmware.com
Tue Apr 26 01:25:30 UTC 2016


On 04/25/2016 06:48 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> There was definitely bugs here mixing up the PIPE_ and TGSI_ defines,
> hopefully they didn't cause any problems, since mostly it was special
> cases for GEOMETRY.
>
> This clarifies at shader machine create what type of shader this
> machine will execute. This is needed also for compute shaders where
> we don't want to allocate inputs/outputs.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>   src/gallium/auxiliary/draw/draw_gs.c      |  2 +-
>   src/gallium/auxiliary/draw/draw_vs.c      |  2 +-
>   src/gallium/auxiliary/tgsi/tgsi_exec.c    | 20 ++++++++++----------
>   src/gallium/auxiliary/tgsi/tgsi_exec.h    |  4 ++--
>   src/gallium/drivers/softpipe/sp_context.c |  2 +-
>   5 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
> index 95ea94f..adba931 100644
> --- a/src/gallium/auxiliary/draw/draw_gs.c
> +++ b/src/gallium/auxiliary/draw/draw_gs.c
> @@ -692,7 +692,7 @@ boolean
>   draw_gs_init( struct draw_context *draw )
>   {
>      if (!draw->llvm) {
> -      draw->gs.tgsi.machine = tgsi_exec_machine_create();
> +      draw->gs.tgsi.machine = tgsi_exec_machine_create(PIPE_SHADER_GEOMETRY);
>         if (!draw->gs.tgsi.machine)
>            return FALSE;
>
> diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
> index 438c9a6..5b42b69 100644
> --- a/src/gallium/auxiliary/draw/draw_vs.c
> +++ b/src/gallium/auxiliary/draw/draw_vs.c
> @@ -154,7 +154,7 @@ draw_vs_init( struct draw_context *draw )
>      draw->dump_vs = debug_get_option_gallium_dump_vs();
>
>      if (!draw->llvm) {
> -      draw->vs.tgsi.machine = tgsi_exec_machine_create();
> +      draw->vs.tgsi.machine = tgsi_exec_machine_create(PIPE_SHADER_VERTEX);
>         if (!draw->vs.tgsi.machine)
>            return FALSE;
>      }
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> index 0e1642e..b068766 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> @@ -895,11 +895,10 @@ tgsi_exec_machine_bind_shader(
>         return;
>      }
>
> -   mach->Processor = parse.FullHeader.Processor.Processor;
>      mach->ImmLimit = 0;
>      mach->NumOutputs = 0;
>
> -   if (mach->Processor == PIPE_SHADER_GEOMETRY &&
> +   if (mach->ShaderType == PIPE_SHADER_GEOMETRY &&
>          !mach->UsedGeometryShader) {
>         struct tgsi_exec_vector *inputs;
>         struct tgsi_exec_vector *outputs;
> @@ -1005,7 +1004,7 @@ tgsi_exec_machine_bind_shader(
>            break;
>
>         case TGSI_TOKEN_TYPE_PROPERTY:
> -         if (mach->Processor == PIPE_SHADER_GEOMETRY) {
> +         if (mach->ShaderType == PIPE_SHADER_GEOMETRY) {
>               if (parse.FullToken.FullProperty.Property.PropertyName == TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES) {
>                  mach->MaxOutputVertices = parse.FullToken.FullProperty.u[0].Data;
>               }
> @@ -1029,7 +1028,7 @@ tgsi_exec_machine_bind_shader(
>
>
>   struct tgsi_exec_machine *
> -tgsi_exec_machine_create( void )
> +tgsi_exec_machine_create(enum pipe_shader_type shader_type)
>   {
>      struct tgsi_exec_machine *mach;
>      uint i;
> @@ -1040,6 +1039,7 @@ tgsi_exec_machine_create( void )
>
>      memset(mach, 0, sizeof(*mach));
>
> +   mach->ShaderType = shader_type;
>      mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR];
>      mach->MaxGeometryShaderOutputs = TGSI_MAX_TOTAL_VERTICES;
>      mach->Predicates = &mach->Temps[TGSI_EXEC_TEMP_P0];
> @@ -1260,7 +1260,7 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach,
>      case TGSI_FILE_INPUT:
>         for (i = 0; i < TGSI_QUAD_SIZE; i++) {
>            /*
> -         if (PIPE_SHADER_GEOMETRY == mach->Processor) {
> +         if (PIPE_SHADER_GEOMETRY == mach->ShaderType) {
>               debug_printf("Fetching Input[%d] (2d=%d, 1d=%d)\n",
>                            index2D->i[i] * TGSI_EXEC_MAX_INPUT_ATTRIBS + index->i[i],
>                            index2D->i[i], index->i[i]);
> @@ -1654,7 +1654,7 @@ store_dest_dstret(struct tgsi_exec_machine *mach,
>         debug_printf("NumOutputs = %d, TEMP_O_C/I = %d, redindex = %d\n",
>                      mach->NumOutputs, mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0],
>                      reg->Register.Index);
> -      if (PIPE_SHADER_GEOMETRY == mach->Processor) {
> +      if (PIPE_SHADER_GEOMETRY == mach->ShaderType) {
>            debug_printf("STORING OUT[%d] mask(%d), = (", offset + index, execmask);
>            for (i = 0; i < TGSI_QUAD_SIZE; i++)
>               if (execmask & (1 << i))
> @@ -1888,7 +1888,7 @@ emit_primitive(struct tgsi_exec_machine *mach)
>   static void
>   conditional_emit_primitive(struct tgsi_exec_machine *mach)
>   {
> -   if (PIPE_SHADER_GEOMETRY == mach->Processor) {
> +   if (PIPE_SHADER_GEOMETRY == mach->ShaderType) {
>         int emitted_verts =
>            mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]];
>         if (emitted_verts) {
> @@ -2699,7 +2699,7 @@ exec_declaration(struct tgsi_exec_machine *mach,
>         return;
>      }
>
> -   if (mach->Processor == PIPE_SHADER_FRAGMENT) {
> +   if (mach->ShaderType == PIPE_SHADER_FRAGMENT) {
>         if (decl->Declaration.File == TGSI_FILE_INPUT) {
>            uint first, last, mask;
>
> @@ -5663,7 +5663,7 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
>      mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
>      mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
>
> -   if( mach->Processor == PIPE_SHADER_GEOMETRY ) {
> +   if( mach->ShaderType == PIPE_SHADER_GEOMETRY ) {

Maybe fix the whitespace while you're here:

if (mach->ShaderType == PIPE_SHADER_GEOMETRY) {


>         mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0] = 0;
>         mach->Primitives[0] = 0;
>         /* GS runs on a single primitive for now */
> @@ -5760,7 +5760,7 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
>
>   #if 0
>      /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */
> -   if (mach->Processor == PIPE_SHADER_FRAGMENT) {
> +   if (mach->ShaderType == PIPE_SHADER_FRAGMENT) {
>         /*
>          * Scale back depth component.
>          */
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> index 897ac7a..b12f7be 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> @@ -371,7 +371,7 @@ struct tgsi_exec_machine
>      unsigned ConstsSize[PIPE_MAX_CONSTANT_BUFFERS];
>
>      const struct tgsi_token       *Tokens;   /**< Declarations, instructions */
> -   unsigned                      Processor; /**< PIPE_SHADER_x */
> +   enum pipe_shader_type         ShaderType; /**< PIPE_SHADER_x */
>
>      /* GEOMETRY processor only. */
>      unsigned                      *Primitives;
> @@ -444,7 +444,7 @@ struct tgsi_exec_machine
>   };
>
>   struct tgsi_exec_machine *
> -tgsi_exec_machine_create( void );
> +tgsi_exec_machine_create(enum pipe_shader_type shader_type);
>
>   void
>   tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach);
> diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
> index 0342fc6..e3ec524 100644
> --- a/src/gallium/drivers/softpipe/sp_context.c
> +++ b/src/gallium/drivers/softpipe/sp_context.c
> @@ -256,7 +256,7 @@ softpipe_create_context(struct pipe_screen *screen,
>         }
>      }
>
> -   softpipe->fs_machine = tgsi_exec_machine_create();
> +   softpipe->fs_machine = tgsi_exec_machine_create(PIPE_SHADER_FRAGMENT);
>
>      /* setup quad rendering stages */
>      softpipe->quad.shade = sp_quad_shade_stage(softpipe);
>

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



More information about the mesa-dev mailing list