[Mesa-dev] [RFC] freedreno: add tgsi lowering pass

Matt Turner mattst88 at gmail.com
Wed Jan 15 21:41:36 PST 2014


On Wed, Jan 15, 2014 at 5:40 AM, Rob Clark <robdclark at gmail.com> wrote:
> From: Rob Clark <robclark at freedesktop.org>
>
> So, as I found myself needing to lower a few more TGSI instructions,
> and noticing yet again that I would have to do the same lowering as
> various other gallium drivers already do,  I decided that maybe it
> makes sense to do this instead generically in a way that could maybe
> help other drivers too.
>
> This currently lowers the following instructions:
>
>    DST, XPD, SCS, LRP, FRC, POW, LIT, EXP, LOG

I think we already have GLSL IR level lowering passes for lrp, pow,
exp, and log. Can't you use those?

> translating these into equivalent simpler TGSI instructions.  There
> are probably more that could be lowered.  These are just common
> instructions, and/or ones I ran across in some piglit tests, which
> I needed to lower.  I might add the various DP permutations as well,
> which would let me get rid of even more lower-directly-to-native
> code in fd3_compiler.
>
> I was sort of wondering about sticking this in aux/util or aux/tgsi,
> and somehow making it configurable which instructions to lower, since
> it seems that it could be useful to other drivers?
>
> ---
>  src/gallium/drivers/freedreno/Makefile.sources     |    1 +
>  src/gallium/drivers/freedreno/a3xx/fd3_program.c   |    7 +-
>  src/gallium/drivers/freedreno/freedreno_lowering.c | 1037 ++++++++++++++++++++
>  src/gallium/drivers/freedreno/freedreno_lowering.h |   36 +
>  4 files changed, 1079 insertions(+), 2 deletions(-)
>  create mode 100644 src/gallium/drivers/freedreno/freedreno_lowering.c
>  create mode 100644 src/gallium/drivers/freedreno/freedreno_lowering.h
>
> diff --git a/src/gallium/drivers/freedreno/Makefile.sources b/src/gallium/drivers/freedreno/Makefile.sources
> index 092b09f..3dcec9d 100644
> --- a/src/gallium/drivers/freedreno/Makefile.sources
> +++ b/src/gallium/drivers/freedreno/Makefile.sources
> @@ -1,5 +1,6 @@
>  C_SOURCES := \
>         freedreno_util.c \
> +       freedreno_lowering.c \
>         freedreno_query.c \
>         freedreno_fence.c \
>         freedreno_resource.c \
> diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c
> index 0886c49..ad76b66 100644
> --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c
> +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c
> @@ -34,6 +34,8 @@
>  #include "tgsi/tgsi_dump.h"
>  #include "tgsi/tgsi_parse.h"
>
> +#include "freedreno_lowering.h"
> +
>  #include "fd3_program.h"
>  #include "fd3_compiler.h"
>  #include "fd3_emit.h"
> @@ -87,6 +89,7 @@ create_shader(struct pipe_context *pctx, const struct pipe_shader_state *cso,
>                 enum shader_t type)
>  {
>         struct fd3_shader_stateobj *so = CALLOC_STRUCT(fd3_shader_stateobj);
> +       const struct tgsi_token *tokens = fd_transform_lowering(cso->tokens);
>         int ret;
>
>         if (!so)
> @@ -96,13 +99,13 @@ create_shader(struct pipe_context *pctx, const struct pipe_shader_state *cso,
>
>         if (fd_mesa_debug & FD_DBG_DISASM) {
>                 DBG("dump tgsi: type=%d", so->type);
> -               tgsi_dump(cso->tokens, 0);
> +               tgsi_dump(tokens, 0);
>         }
>
>         if ((type == SHADER_FRAGMENT) && (fd_mesa_debug & FD_DBG_FRAGHALF))
>                 so->half_precision = true;
>
> -       ret = fd3_compile_shader(so, cso->tokens);
> +       ret = fd3_compile_shader(so, tokens);
>         if (ret) {
>                 debug_error("compile failed!");
>                 goto fail;
> diff --git a/src/gallium/drivers/freedreno/freedreno_lowering.c b/src/gallium/drivers/freedreno/freedreno_lowering.c
> new file mode 100644
> index 0000000..354969f
> --- /dev/null
> +++ b/src/gallium/drivers/freedreno/freedreno_lowering.c
> @@ -0,0 +1,1037 @@
> +/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
> +

Doesn't seem like what you want. I'd hope you didn't need a modeline at all.


More information about the mesa-dev mailing list