[Mesa-dev] [PATCH 09/14] mesa_to_tgsi: remove remnants of flow control and subroutine support

Ilia Mirkin imirkin at alum.mit.edu
Mon Oct 17 14:01:13 UTC 2016


Patches 1-9 are Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

On Mon, Oct 17, 2016 at 9:39 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/mesa/state_tracker/st_mesa_to_tgsi.c | 93 +-------------------------------
>  1 file changed, 1 insertion(+), 92 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
> index c8ed26c..4c26d92 100644
> --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
> +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
> @@ -44,116 +44,42 @@
>  #include "util/u_debug.h"
>  #include "util/u_math.h"
>  #include "util/u_memory.h"
>  #include "st_glsl_to_tgsi.h" /* for _mesa_sysval_to_semantic */
>
>
>  #define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) |    \
>                             (1 << PROGRAM_CONSTANT) |     \
>                             (1 << PROGRAM_UNIFORM))
>
> -
> -struct label {
> -   unsigned branch_target;
> -   unsigned token;
> -};
> -
> -
>  /**
>   * Intermediate state used during shader translation.
>   */
>  struct st_translate {
>     struct ureg_program *ureg;
>
>     struct ureg_dst temps[MAX_PROGRAM_TEMPS];
>     struct ureg_src *constants;
>     struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
>     struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
>     struct ureg_dst address[1];
>     struct ureg_src samplers[PIPE_MAX_SAMPLERS];
>     struct ureg_src systemValues[SYSTEM_VALUE_MAX];
>
>     const GLuint *inputMapping;
>     const GLuint *outputMapping;
>
> -   /* For every instruction that contains a label (eg CALL), keep
> -    * details so that we can go back afterwards and emit the correct
> -    * tgsi instruction number for each label.
> -    */
> -   struct label *labels;
> -   unsigned labels_size;
> -   unsigned labels_count;
> -
> -   /* Keep a record of the tgsi instruction number that each mesa
> -    * instruction starts at, will be used to fix up labels after
> -    * translation.
> -    */
> -   unsigned *insn;
> -   unsigned insn_size;
> -   unsigned insn_count;
> -
>     unsigned procType;  /**< PIPE_SHADER_VERTEX/FRAGMENT */
> -
> -   boolean error;
>  };
>
>
>  /**
> - * Make note of a branch to a label in the TGSI code.
> - * After we've emitted all instructions, we'll go over the list
> - * of labels built here and patch the TGSI code with the actual
> - * location of each label.
> - */
> -static unsigned *get_label( struct st_translate *t,
> -                            unsigned branch_target )
> -{
> -   unsigned i;
> -
> -   if (t->labels_count + 1 >= t->labels_size) {
> -      t->labels_size = 1 << (util_logbase2(t->labels_size) + 1);
> -      t->labels = realloc(t->labels, t->labels_size * sizeof t->labels[0]);
> -      if (t->labels == NULL) {
> -         static unsigned dummy;
> -         t->error = TRUE;
> -         return &dummy;
> -      }
> -   }
> -
> -   i = t->labels_count++;
> -   t->labels[i].branch_target = branch_target;
> -   return &t->labels[i].token;
> -}
> -
> -
> -/**
> - * Called prior to emitting the TGSI code for each Mesa instruction.
> - * Allocate additional space for instructions if needed.
> - * Update the insn[] array so the next Mesa instruction points to
> - * the next TGSI instruction.
> - */
> -static void set_insn_start( struct st_translate *t,
> -                            unsigned start )
> -{
> -   if (t->insn_count + 1 >= t->insn_size) {
> -      t->insn_size = 1 << (util_logbase2(t->insn_size) + 1);
> -      t->insn = realloc(t->insn, t->insn_size * sizeof t->insn[0]);
> -      if (t->insn == NULL) {
> -         t->error = TRUE;
> -         return;
> -      }
> -   }
> -
> -   t->insn[t->insn_count++] = start;
> -}
> -
> -
> -/**
>   * Map a Mesa dst register to a TGSI ureg_dst register.
>   */
>  static struct ureg_dst
>  dst_register( struct st_translate *t,
>                gl_register_file file,
>                GLuint index )
>  {
>     switch( file ) {
>     case PROGRAM_UNDEFINED:
>        return ureg_dst_undef();
> @@ -1088,34 +1014,17 @@ st_translate_mesa_program(
>                                  TGSI_RETURN_TYPE_FLOAT,
>                                  TGSI_RETURN_TYPE_FLOAT,
>                                  TGSI_RETURN_TYPE_FLOAT,
>                                  TGSI_RETURN_TYPE_FLOAT);
>
>        }
>     }
>
>     /* Emit each instruction in turn:
>      */
> -   for (i = 0; i < program->NumInstructions; i++) {
> -      set_insn_start( t, ureg_get_instruction_number( ureg ));
> +   for (i = 0; i < program->NumInstructions; i++)
>        compile_instruction(ctx, t, &program->Instructions[i]);
> -   }
> -
> -   /* Fix up all emitted labels:
> -    */
> -   for (i = 0; i < t->labels_count; i++) {
> -      ureg_fixup_label( ureg,
> -                        t->labels[i].token,
> -                        t->insn[t->labels[i].branch_target] );
> -   }
>
>  out:
> -   free(t->insn);
> -   free(t->labels);
>     free(t->constants);
> -
> -   if (t->error) {
> -      debug_printf("%s: translate error flag set\n", __func__);
> -   }
> -
>     return ret;
>  }
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list