OSDN Git Service

freedreno: Plumb pipe_screen through to irX_tgsi_to_nir.
authorTimur Kristóf <timur.kristof@gmail.com>
Mon, 4 Mar 2019 12:54:10 +0000 (13:54 +0100)
committerEric Anholt <eric@anholt.net>
Tue, 5 Mar 2019 19:13:27 +0000 (19:13 +0000)
This patch makes it possible for freedreno to pass a pipe_screen
to tgsi_to_nir. This will be needed when tgsi_to_nir supports reading
pipe capabilities.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Tested-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
12 files changed:
src/gallium/drivers/freedreno/a2xx/fd2_program.c
src/gallium/drivers/freedreno/a2xx/ir2.h
src/gallium/drivers/freedreno/a2xx/ir2_nir.c
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/a4xx/fd4_program.c
src/gallium/drivers/freedreno/a5xx/fd5_compute.c
src/gallium/drivers/freedreno/a5xx/fd5_program.c
src/gallium/drivers/freedreno/a6xx/fd6_compute.c
src/gallium/drivers/freedreno/a6xx/fd6_program.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/freedreno/ir3/ir3_gallium.c
src/gallium/drivers/freedreno/ir3/ir3_gallium.h

index 84b54cf..cba87f0 100644 (file)
@@ -102,7 +102,7 @@ fd2_fp_state_create(struct pipe_context *pctx,
                           (nir_lower_io_options)0);
        } else {
                assert(cso->type == PIPE_SHADER_IR_TGSI);
-               so->nir = ir2_tgsi_to_nir(cso->tokens);
+               so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
        }
 
        if (ir2_optimize_nir(so->nir, true))
@@ -142,7 +142,7 @@ fd2_vp_state_create(struct pipe_context *pctx,
                           (nir_lower_io_options)0);
        } else {
                assert(cso->type == PIPE_SHADER_IR_TGSI);
-               so->nir = ir2_tgsi_to_nir(cso->tokens);
+               so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
        }
 
        if (ir2_optimize_nir(so->nir, true))
index f381fdf..706dc94 100644 (file)
@@ -28,6 +28,7 @@
 #define IR2_H_
 
 #include "compiler/nir/nir.h"
+#include "pipe/p_context.h"
 
 struct ir2_fetch_info {
        /* dword offset of the fetch instruction */
@@ -85,7 +86,8 @@ struct tgsi_token;
 void ir2_compile(struct fd2_shader_stateobj *so, unsigned variant,
                struct fd2_shader_stateobj *fp);
 
-struct nir_shader *ir2_tgsi_to_nir(const struct tgsi_token *tokens);
+struct nir_shader *ir2_tgsi_to_nir(const struct tgsi_token *tokens,
+                                  struct pipe_screen *screen);
 
 const nir_shader_compiler_options *ir2_get_compiler_options(void);
 
index 5d92f86..ee27b88 100644 (file)
@@ -43,8 +43,11 @@ static const nir_shader_compiler_options options = {
 };
 
 struct nir_shader *
-ir2_tgsi_to_nir(const struct tgsi_token *tokens)
+ir2_tgsi_to_nir(const struct tgsi_token *tokens,
+               struct pipe_screen *screen)
 {
+       /* TODO: pass screen to tgsi_to_nir when it needs that. */
+       (void) screen;
        return tgsi_to_nir(tokens, &options);
 }
 
index 2937104..7df1f77 100644 (file)
@@ -44,7 +44,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
 {
        struct fd_context *ctx = fd_context(pctx);
        struct ir3_compiler *compiler = ctx->screen->compiler;
-       return ir3_shader_create(compiler, cso, type, &ctx->debug);
+       return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
 }
 
 static void *
index 970f918..2d230fa 100644 (file)
@@ -43,7 +43,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
 {
        struct fd_context *ctx = fd_context(pctx);
        struct ir3_compiler *compiler = ctx->screen->compiler;
-       return ir3_shader_create(compiler, cso, type, &ctx->debug);
+       return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
 }
 
 static void *
index 1e084fd..97034d7 100644 (file)
@@ -56,7 +56,7 @@ fd5_create_compute_state(struct pipe_context *pctx,
 
        struct ir3_compiler *compiler = ctx->screen->compiler;
        struct fd5_compute_stateobj *so = CALLOC_STRUCT(fd5_compute_stateobj);
-       so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug);
+       so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen);
        return so;
 }
 
index 650db0d..3dba15f 100644 (file)
@@ -46,7 +46,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
 {
        struct fd_context *ctx = fd_context(pctx);
        struct ir3_compiler *compiler = ctx->screen->compiler;
-       return ir3_shader_create(compiler, cso, type, &ctx->debug);
+       return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
 }
 
 static void *
index a3f7d53..1219d7a 100644 (file)
@@ -56,7 +56,7 @@ fd6_create_compute_state(struct pipe_context *pctx,
 
        struct ir3_compiler *compiler = ctx->screen->compiler;
        struct fd6_compute_stateobj *so = CALLOC_STRUCT(fd6_compute_stateobj);
-       so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug);
+       so->shader = ir3_shader_create_compute(compiler, cso, &ctx->debug, pctx->screen);
        return so;
 }
 
index 13c5778..13c080e 100644 (file)
@@ -45,7 +45,7 @@ create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state
 {
        struct fd_context *ctx = fd_context(pctx);
        struct ir3_compiler *compiler = ctx->screen->compiler;
-       return ir3_shader_create(compiler, cso, type, &ctx->debug);
+       return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen);
 }
 
 static void *
index 364e62b..872bcb2 100644 (file)
@@ -49,6 +49,8 @@
 #include "compiler/nir_types.h"
 #include "compiler/spirv/nir_spirv.h"
 
+#include "pipe/p_context.h"
+
 static void dump_info(struct ir3_shader_variant *so, const char *str)
 {
        uint32_t *bin;
@@ -462,7 +464,7 @@ int main(int argc, char **argv)
                if (ir3_shader_debug & IR3_DBG_OPTMSGS)
                        tgsi_dump(toks, 0);
 
-               nir = ir3_tgsi_to_nir(compiler, toks);
+               nir = ir3_tgsi_to_nir(compiler, toks, NULL);
                NIR_PASS_V(nir, nir_lower_global_vars_to_local);
        } else if (from_spirv) {
                nir = load_spirv(filenames[0], entry, stage);
index 1fe6127..726bd14 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "pipe/p_state.h"
+#include "pipe/p_screen.h"
 #include "util/u_string.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
@@ -120,7 +121,8 @@ copy_stream_out(struct ir3_stream_output_info *i,
 struct ir3_shader *
 ir3_shader_create(struct ir3_compiler *compiler,
                const struct pipe_shader_state *cso, gl_shader_stage type,
-               struct pipe_debug_callback *debug)
+               struct pipe_debug_callback *debug,
+               struct pipe_screen *screen)
 {
        nir_shader *nir;
        if (cso->type == PIPE_SHADER_IR_NIR) {
@@ -131,7 +133,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
                if (ir3_shader_debug & IR3_DBG_DISASM) {
                        tgsi_dump(cso->tokens, 0);
                }
-               nir = ir3_tgsi_to_nir(compiler, cso->tokens);
+               nir = ir3_tgsi_to_nir(compiler, cso->tokens, screen);
        }
 
        struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
@@ -156,7 +158,8 @@ ir3_shader_create(struct ir3_compiler *compiler,
 struct ir3_shader *
 ir3_shader_create_compute(struct ir3_compiler *compiler,
                const struct pipe_compute_state *cso,
-               struct pipe_debug_callback *debug)
+               struct pipe_debug_callback *debug,
+               struct pipe_screen *screen)
 {
        nir_shader *nir;
        if (cso->ir_type == PIPE_SHADER_IR_NIR) {
@@ -167,7 +170,7 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
                if (ir3_shader_debug & IR3_DBG_DISASM) {
                        tgsi_dump(cso->prog, 0);
                }
-               nir = ir3_tgsi_to_nir(compiler, cso->prog);
+               nir = ir3_tgsi_to_nir(compiler, cso->prog, screen);
        }
 
        struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
@@ -176,8 +179,12 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
 }
 
 struct nir_shader *
-ir3_tgsi_to_nir(struct ir3_compiler *compiler, const struct tgsi_token *tokens)
+ir3_tgsi_to_nir(struct ir3_compiler *compiler,
+               const struct tgsi_token *tokens,
+               struct pipe_screen *screen)
 {
+       /* TODO: pass screen to tgsi_to_nir when it needs that. */
+       (void) screen;
        return tgsi_to_nir(tokens, ir3_get_compiler_options(compiler));
 }
 
index 5fb7459..74f03e6 100644 (file)
 #define IR3_GALLIUM_H_
 
 #include "pipe/p_state.h"
+#include "pipe/p_screen.h"
 #include "ir3/ir3_shader.h"
 
 struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler,
                const struct pipe_shader_state *cso, gl_shader_stage type,
-               struct pipe_debug_callback *debug);
+               struct pipe_debug_callback *debug,
+               struct pipe_screen *screen);
 struct ir3_shader *
 ir3_shader_create_compute(struct ir3_compiler *compiler,
                const struct pipe_compute_state *cso,
-               struct pipe_debug_callback *debug);
+               struct pipe_debug_callback *debug,
+               struct pipe_screen *screen);
 struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader,
                struct ir3_shader_key key, bool binning_pass,
                struct pipe_debug_callback *debug);
 struct nir_shader * ir3_tgsi_to_nir(struct ir3_compiler *compiler,
-               const struct tgsi_token *tokens);
+               const struct tgsi_token *tokens,
+               struct pipe_screen *screen);
 
 struct fd_ringbuffer;
 struct fd_context;