aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorTimur Kristóf <[email protected]>2019-03-05 18:59:47 +0100
committerEric Anholt <[email protected]>2019-03-05 19:13:27 +0000
commit9a834447d652ea50864bb6c32f4ff99ac10d39bf (patch)
treeb60582e7bb504b2e2bad847f6494b418db9e83ea /src/gallium/drivers/freedreno
parente582e761b7f49d1c0b100289b62442e6295cefef (diff)
tgsi_to_nir: Produce optimized NIR for a given pipe_screen.
With this patch, tgsi_to_nir will output NIR that is tailored to the given pipe, by reading its capabilities and adjusting the NIR code to those capabilities similarly to how glsl_to_nir works. It also adds an optimization loop that brings the output NIR in line with what glsl_to_nir outputs. This is necessary for the same reason why glsl_to_nir has its own optimization loop: currently not every driver does these optimizations yet. For uses which cannot pass a pipe_screen we also keep a variant called tgsi_to_nir_noscreen which keeps the old behavior. Signed-Off-By: Timur Kristóf <[email protected]> Tested-by: Andre Heider <[email protected]> Tested-by: Rob Clark <[email protected]> Acked-By: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/a2xx/ir2_nir.c8
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_gallium.c10
2 files changed, 12 insertions, 6 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
index ee27b8835a2..6aaff393167 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
+++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
@@ -46,9 +46,11 @@ struct nir_shader *
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);
+ if (!screen) {
+ return tgsi_to_nir_noscreen(tokens, &options);
+ }
+
+ return tgsi_to_nir(tokens, screen);
}
const nir_shader_compiler_options *
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index 726bd14ac6d..4481c544217 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -183,9 +183,13 @@ 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));
+ if (!screen) {
+ const nir_shader_compiler_options *options =
+ ir3_get_compiler_options(compiler);
+ return tgsi_to_nir_noscreen(tokens, options);
+ }
+
+ return tgsi_to_nir(tokens, screen);
}
/* This has to reach into the fd_context a bit more than the rest of