Mesa (master): freedreno/ir3: move the libdrm dependency out of shared code
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 15 16:10:41 UTC 2020
Module: Mesa
Branch: master
Commit: 1a33faea8c514599e5b770a56e741103a9401d49
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a33faea8c514599e5b770a56e741103a9401d49
Author: Rob Clark <robdclark at chromium.org>
Date: Fri Jun 5 12:56:04 2020 -0700
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 <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5476>
---
src/freedreno/ir3/ir3_shader.c | 24 ++++------------
src/freedreno/ir3/ir3_shader.h | 3 ++
src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 37 +++++++++++++++++++++++++
3 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c
index 652129108bf..ddb2c997baf 100644
--- a/src/freedreno/ir3/ir3_shader.c
+++ b/src/freedreno/ir3/ir3_shader.c
@@ -46,10 +46,10 @@ delete_variant(struct ir3_shader_variant *v)
{
if (v->ir)
ir3_destroy(v->ir);
- if (v->bo)
- fd_bo_del(v->bo);
+ assert(!v->bo);
if (v->binning)
delete_variant(v->binning);
+ free(v->bin);
free(v);
}
@@ -160,32 +160,18 @@ static void
assemble_variant(struct ir3_shader_variant *v)
{
struct ir3_compiler *compiler = v->shader->compiler;
- struct shader_info *info = &v->shader->nir->info;
uint32_t gpu_id = compiler->gpu_id;
- uint32_t sz, *bin;
- bin = ir3_shader_assemble(v, gpu_id);
- 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), bin, sz);
+ v->bin = ir3_shader_assemble(v, gpu_id);
if (shader_debug_enabled(v->shader->type)) {
fprintf(stdout, "Native code for unnamed %s shader %s:\n",
ir3_shader_stage(v), v->shader->nir->info.name);
if (v->shader->type == MESA_SHADER_FRAGMENT)
fprintf(stdout, "SIMD0\n");
- ir3_shader_disasm(v, bin, stdout);
+ ir3_shader_disasm(v, v->bin, stdout);
}
- free(bin);
-
/* no need to keep the ir around beyond this point: */
ir3_destroy(v->ir);
v->ir = NULL;
@@ -220,7 +206,7 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key *key,
}
assemble_variant(v);
- if (!v->bo) {
+ if (!v->bin) {
debug_error("assemble failed!");
goto fail;
}
diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h
index 809af42d6cb..9fc175595ba 100644
--- a/src/freedreno/ir3/ir3_shader.h
+++ b/src/freedreno/ir3/ir3_shader.h
@@ -429,6 +429,9 @@ struct ir3_shader_variant {
struct ir3_info info;
struct ir3 *ir;
+ /* The actual binary shader instructions, size given by info.sizedwords: */
+ uint32_t *bin;
+
/* Levels of nesting of flow control:
*/
unsigned branchstack;
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);
}
More information about the mesa-commit
mailing list