From: Timur Kristóf Date: Mon, 4 Mar 2019 12:54:10 +0000 (+0100) Subject: freedreno: Plumb pipe_screen through to irX_tgsi_to_nir. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e582e761b7f49d1c0b100289b62442e6295cefef;p=mesa.git freedreno: Plumb pipe_screen through to irX_tgsi_to_nir. 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 Tested-by: Rob Clark Reviewed-by: Rob Clark --- diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.c b/src/gallium/drivers/freedreno/a2xx/fd2_program.c index 84b54cf56b7..cba87f01afc 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.c @@ -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)) diff --git a/src/gallium/drivers/freedreno/a2xx/ir2.h b/src/gallium/drivers/freedreno/a2xx/ir2.h index f381fdfff16..706dc943a73 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2.h +++ b/src/gallium/drivers/freedreno/a2xx/ir2.h @@ -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); diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c index 5d92f86befc..ee27b8835a2 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c +++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c @@ -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); } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index 29371049ba0..7df1f77a3ca 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -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 * diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_program.c b/src/gallium/drivers/freedreno/a4xx/fd4_program.c index 970f918faae..2d230faff19 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_program.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_program.c @@ -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 * diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_compute.c b/src/gallium/drivers/freedreno/a5xx/fd5_compute.c index 1e084fd4c3b..97034d7a703 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_compute.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_compute.c @@ -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; } diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_program.c b/src/gallium/drivers/freedreno/a5xx/fd5_program.c index 650db0df463..3dba15fc56a 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_program.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_program.c @@ -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 * diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c index a3f7d537cf7..1219d7ad9b3 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c @@ -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; } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_program.c b/src/gallium/drivers/freedreno/a6xx/fd6_program.c index 13c5778e427..13c080e1ddc 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_program.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_program.c @@ -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 * diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 364e62b308c..872bcb28469 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -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); diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 1fe61273d32..726bd14ac6d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -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)); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.h b/src/gallium/drivers/freedreno/ir3/ir3_gallium.h index 5fb74596781..74f03e651ff 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.h @@ -28,20 +28,24 @@ #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;