summaryrefslogtreecommitdiff
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@collabora.com>2020-10-17 12:08:17 +0200
committerMarge Bot <eric+marge@anholt.net>2020-10-23 14:48:22 +0000
commit69c864b0b92da981b169cf879f7718e3d2c458c0 (patch)
tree4ae7fb48138d5d02ddce388dcf1d3fd9b3f0129d /src/panfrost/midgard
parentb83c293674c11de4acec14a45f798cb12566a8e0 (diff)
panfrost: Make {midgard,bifrost}_compile_shader_nir() return a program object
Letting the caller zero-initialize the program object is error prone, not to mention that resources attached to the program might not be freed by the caller. Let's simplify that by letting the compiler allocate the panfrost_program object. Those objects should be freed with ralloc_free(). Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/midgard_compile.c10
-rw-r--r--src/panfrost/midgard/midgard_compile.h4
2 files changed, 8 insertions, 6 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 7f67fb35537..acbf296be85 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2942,10 +2942,12 @@ mir_add_writeout_loops(compiler_context *ctx)
}
}
-int
-midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
+panfrost_program *
+midgard_compile_shader_nir(void *mem_ctx, nir_shader *nir,
const struct panfrost_compile_inputs *inputs)
{
+ panfrost_program *program = rzalloc(mem_ctx, panfrost_program);
+
struct util_dynarray *compiled = &program->compiled;
midgard_debug = debug_get_option_midgard_debug();
@@ -3041,7 +3043,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
break; /* TODO: Multi-function shaders */
}
- util_dynarray_init(compiled, NULL);
+ util_dynarray_init(compiled, program);
/* Per-block lowering before opts */
@@ -3187,5 +3189,5 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
ralloc_free(ctx);
- return 0;
+ return program;
}
diff --git a/src/panfrost/midgard/midgard_compile.h b/src/panfrost/midgard/midgard_compile.h
index 93ac3a825db..c50ece351b1 100644
--- a/src/panfrost/midgard/midgard_compile.h
+++ b/src/panfrost/midgard/midgard_compile.h
@@ -28,8 +28,8 @@
#include "util/u_dynarray.h"
#include "panfrost/util/pan_ir.h"
-int
-midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program,
+panfrost_program *
+midgard_compile_shader_nir(void *mem_ctx, nir_shader *nir,
const struct panfrost_compile_inputs *inputs);
/* NIR options are shared between the standalone compiler and the online