aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2020-06-05 12:56:04 -0700
committerMarge Bot <[email protected]>2020-06-15 15:46:37 +0000
commit1a33faea8c514599e5b770a56e741103a9401d49 (patch)
treeb94bf96aa57c8344e6c56b60ad344cb915718bdf /src/gallium/drivers/freedreno/ir3/ir3_gallium.c
parent43e0062c5b3762ec6a07398d0872b174404ef0ab (diff)
freedreno/ir3: move the libdrm dependency out of shared code
The only reason for this dependency was the fd_bo used for the uploaded shader. But this isn't used by turnip. Now that we've unified the cleanup path from gallium, it isn't hard to pull the fd_bo upload/free parts into ir3_gallium. This cleanup has the added benefit that the shader disk-cache will not have to deal with it. Signed-off-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5476>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3/ir3_gallium.c')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_gallium.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index 6c0aa9f4b80..5544e0e50c7 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -70,6 +70,27 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
v->max_sun, v->loops);
}
+static void
+upload_shader_variant(struct ir3_shader_variant *v)
+{
+ struct shader_info *info = &v->shader->nir->info;
+ struct ir3_compiler *compiler = v->shader->compiler;
+
+ assert(!v->bo);
+
+ unsigned sz = v->info.sizedwords * 4;
+
+ v->bo = fd_bo_new(compiler->dev, sz,
+ DRM_FREEDRENO_GEM_CACHE_WCOMBINE |
+ DRM_FREEDRENO_GEM_TYPE_KMEM,
+ "%s:%s", ir3_shader_stage(v), info->name);
+
+ /* Always include shaders in kernel crash dumps. */
+ fd_bo_mark_for_dump(v->bo);
+
+ memcpy(fd_bo_map(v->bo), v->bin, sz);
+}
+
struct ir3_shader_variant *
ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,
bool binning_pass, struct pipe_debug_callback *debug)
@@ -98,6 +119,8 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,
}
dump_shader_info(v, binning_pass, debug);
+
+ upload_shader_variant(v);
}
return v;
@@ -237,6 +260,20 @@ void
ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
{
struct ir3_shader *so = hwcso;
+
+ /* free the uploaded shaders, since this is handled outside of the
+ * shared ir3 code (ie. not used by turnip):
+ */
+ for (struct ir3_shader_variant *v = so->variants; v; v = v->next) {
+ fd_bo_del(v->bo);
+ v->bo = NULL;
+
+ if (v->binning) {
+ fd_bo_del(v->binning->bo);
+ v->binning->bo = NULL;
+ }
+ }
+
ir3_shader_destroy(so);
}