Module: Mesa
Branch: main
Commit: ceae84479410d36d9dd176404420535c58758122
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ceae84479410d36d9dd176404420535c58758122

Author: Connor Abbott <[email protected]>
Date:   Wed Feb 16 12:58:16 2022 +0100

ir3: Remove ir3_shader_variant::shader

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16147>

---

 src/freedreno/ir3/ir3_assembler.c               |  1 -
 src/freedreno/ir3/ir3_compiler.h                |  1 +
 src/freedreno/ir3/ir3_compiler_nir.c            |  3 ++-
 src/freedreno/ir3/ir3_context.c                 |  5 +++--
 src/freedreno/ir3/ir3_context.h                 |  1 +
 src/freedreno/ir3/ir3_disk_cache.c              | 22 +++++++++++-----------
 src/freedreno/ir3/ir3_shader.c                  | 21 ++++++++++-----------
 src/freedreno/ir3/ir3_shader.h                  |  1 -
 src/gallium/drivers/freedreno/ir3/ir3_cmdline.c |  3 +--
 9 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/freedreno/ir3/ir3_assembler.c 
b/src/freedreno/ir3/ir3_assembler.c
index 0b9c7efd99c..eba2423b460 100644
--- a/src/freedreno/ir3/ir3_assembler.c
+++ b/src/freedreno/ir3/ir3_assembler.c
@@ -39,7 +39,6 @@ ir3_parse_asm(struct ir3_compiler *c, struct ir3_kernel_info 
*info, FILE *in)
 
    struct ir3_shader_variant *v = rzalloc_size(shader, sizeof(*v));
    v->type = MESA_SHADER_COMPUTE;
-   v->shader = shader;
    v->compiler = c;
    v->const_state = rzalloc_size(v, sizeof(*v->const_state));
 
diff --git a/src/freedreno/ir3/ir3_compiler.h b/src/freedreno/ir3/ir3_compiler.h
index e67ed786564..0bc300f92a1 100644
--- a/src/freedreno/ir3/ir3_compiler.h
+++ b/src/freedreno/ir3/ir3_compiler.h
@@ -217,6 +217,7 @@ const nir_shader_compiler_options *
 ir3_get_compiler_options(struct ir3_compiler *compiler);
 
 int ir3_compile_shader_nir(struct ir3_compiler *compiler,
+                           struct ir3_shader *shader,
                            struct ir3_shader_variant *so);
 
 /* gpu pointer size in units of 32bit registers/slots */
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c 
b/src/freedreno/ir3/ir3_compiler_nir.c
index 3319b9f8113..980c83b48ba 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -4592,6 +4592,7 @@ collect_tex_prefetches(struct ir3_context *ctx, struct 
ir3 *ir)
 
 int
 ir3_compile_shader_nir(struct ir3_compiler *compiler,
+                       struct ir3_shader *shader,
                        struct ir3_shader_variant *so)
 {
    struct ir3_context *ctx;
@@ -4601,7 +4602,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
 
    assert(!so->ir);
 
-   ctx = ir3_context_init(compiler, so);
+   ctx = ir3_context_init(compiler, shader, so);
    if (!ctx) {
       DBG("INIT failed!");
       ret = -1;
diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c
index 4fb4c0921f9..8dfb348f898 100644
--- a/src/freedreno/ir3/ir3_context.c
+++ b/src/freedreno/ir3/ir3_context.c
@@ -31,7 +31,8 @@
 #include "ir3_shader.h"
 
 struct ir3_context *
-ir3_context_init(struct ir3_compiler *compiler, struct ir3_shader_variant *so)
+ir3_context_init(struct ir3_compiler *compiler, struct ir3_shader *shader,
+                 struct ir3_shader_variant *so)
 {
    struct ir3_context *ctx = rzalloc(NULL, struct ir3_context);
 
@@ -76,7 +77,7 @@ ir3_context_init(struct ir3_compiler *compiler, struct 
ir3_shader_variant *so)
     * creating duplicate variants..
     */
 
-   ctx->s = nir_shader_clone(ctx, so->shader->nir);
+   ctx->s = nir_shader_clone(ctx, shader->nir);
    ir3_nir_lower_variant(so, ctx->s);
 
    /* this needs to be the last pass run, so do this here instead of
diff --git a/src/freedreno/ir3/ir3_context.h b/src/freedreno/ir3/ir3_context.h
index d2141c07ede..a1983e5252f 100644
--- a/src/freedreno/ir3/ir3_context.h
+++ b/src/freedreno/ir3/ir3_context.h
@@ -199,6 +199,7 @@ extern const struct ir3_context_funcs ir3_a4xx_funcs;
 extern const struct ir3_context_funcs ir3_a6xx_funcs;
 
 struct ir3_context *ir3_context_init(struct ir3_compiler *compiler,
+                                     struct ir3_shader *shader,
                                      struct ir3_shader_variant *so);
 void ir3_context_free(struct ir3_context *ctx);
 
diff --git a/src/freedreno/ir3/ir3_disk_cache.c 
b/src/freedreno/ir3/ir3_disk_cache.c
index a629e51e5e5..332e45e249f 100644
--- a/src/freedreno/ir3/ir3_disk_cache.c
+++ b/src/freedreno/ir3/ir3_disk_cache.c
@@ -105,17 +105,17 @@ ir3_disk_cache_init_shader_key(struct ir3_compiler 
*compiler,
 }
 
 static void
-compute_variant_key(struct ir3_compiler *compiler, struct ir3_shader_variant 
*v,
+compute_variant_key(struct ir3_shader *shader, struct ir3_shader_variant *v,
                     cache_key cache_key)
 {
    struct blob blob;
    blob_init(&blob);
 
-   blob_write_bytes(&blob, &v->shader->cache_key, 
sizeof(v->shader->cache_key));
+   blob_write_bytes(&blob, &shader->cache_key, sizeof(shader->cache_key));
    blob_write_bytes(&blob, &v->key, sizeof(v->key));
    blob_write_uint8(&blob, v->binning_pass);
 
-   disk_cache_compute_key(compiler->disk_cache, blob.data, blob.size,
+   disk_cache_compute_key(shader->compiler->disk_cache, blob.data, blob.size,
                           cache_key);
 
    blob_finish(&blob);
@@ -164,15 +164,15 @@ store_variant(struct blob *blob, struct 
ir3_shader_variant *v)
 }
 
 bool
-ir3_disk_cache_retrieve(struct ir3_compiler *compiler,
+ir3_disk_cache_retrieve(struct ir3_shader *shader,
                         struct ir3_shader_variant *v)
 {
-   if (!compiler->disk_cache)
+   if (!shader->compiler->disk_cache)
       return false;
 
    cache_key cache_key;
 
-   compute_variant_key(compiler, v, cache_key);
+   compute_variant_key(shader, v, cache_key);
 
    if (debug) {
       char sha1[41];
@@ -181,7 +181,7 @@ ir3_disk_cache_retrieve(struct ir3_compiler *compiler,
    }
 
    size_t size;
-   void *buffer = disk_cache_get(compiler->disk_cache, cache_key, &size);
+   void *buffer = disk_cache_get(shader->compiler->disk_cache, cache_key, 
&size);
 
    if (debug)
       fprintf(stderr, "%s\n", buffer ? "found" : "missing");
@@ -203,15 +203,15 @@ ir3_disk_cache_retrieve(struct ir3_compiler *compiler,
 }
 
 void
-ir3_disk_cache_store(struct ir3_compiler *compiler,
+ir3_disk_cache_store(struct ir3_shader *shader,
                      struct ir3_shader_variant *v)
 {
-   if (!compiler->disk_cache)
+   if (!shader->compiler->disk_cache)
       return;
 
    cache_key cache_key;
 
-   compute_variant_key(compiler, v, cache_key);
+   compute_variant_key(shader, v, cache_key);
 
    if (debug) {
       char sha1[41];
@@ -227,6 +227,6 @@ ir3_disk_cache_store(struct ir3_compiler *compiler,
    if (v->binning)
       store_variant(&blob, v->binning);
 
-   disk_cache_put(compiler->disk_cache, cache_key, blob.data, blob.size, NULL);
+   disk_cache_put(shader->compiler->disk_cache, cache_key, blob.data, 
blob.size, NULL);
    blob_finish(&blob);
 }
diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c
index 37eba7de827..73535808738 100644
--- a/src/freedreno/ir3/ir3_shader.c
+++ b/src/freedreno/ir3/ir3_shader.c
@@ -288,19 +288,19 @@ assemble_variant(struct ir3_shader_variant *v)
 }
 
 static bool
-compile_variant(struct ir3_shader_variant *v)
+compile_variant(struct ir3_shader *shader, struct ir3_shader_variant *v)
 {
-   int ret = ir3_compile_shader_nir(v->shader->compiler, v);
+   int ret = ir3_compile_shader_nir(shader->compiler, shader, v);
    if (ret) {
-      mesa_loge("compile failed! (%s:%s)", v->shader->nir->info.name,
-                v->shader->nir->info.label);
+      mesa_loge("compile failed! (%s:%s)", shader->nir->info.name,
+                shader->nir->info.label);
       return false;
    }
 
    assemble_variant(v);
    if (!v->bin) {
-      mesa_loge("assemble failed! (%s:%s)", v->shader->nir->info.name,
-                v->shader->nir->info.label);
+      mesa_loge("assemble failed! (%s:%s)", shader->nir->info.name,
+                shader->nir->info.label);
       return false;
    }
 
@@ -329,7 +329,6 @@ alloc_variant(struct ir3_shader *shader, const struct 
ir3_shader_key *key,
 
    v->id = ++shader->variant_count;
    v->shader_id = shader->id;
-   v->shader = shader;
    v->binning_pass = !!nonbinning;
    v->nonbinning = nonbinning;
    v->key = *key;
@@ -410,7 +409,7 @@ create_variant(struct ir3_shader *shader, const struct 
ir3_shader_key *key,
       v->binning->disasm_info.write_disasm = write_disasm;
    }
 
-   if (ir3_disk_cache_retrieve(shader->compiler, v))
+   if (ir3_disk_cache_retrieve(shader, v))
       return v;
 
    if (!shader->nir_finalized) {
@@ -428,13 +427,13 @@ create_variant(struct ir3_shader *shader, const struct 
ir3_shader_key *key,
       shader->nir_finalized = true;
    }
 
-   if (!compile_variant(v))
+   if (!compile_variant(shader, v))
       goto fail;
 
-   if (needs_binning_variant(v) && !compile_variant(v->binning))
+   if (needs_binning_variant(v) && !compile_variant(shader, v->binning))
       goto fail;
 
-   ir3_disk_cache_store(shader->compiler, v);
+   ir3_disk_cache_store(shader, v);
 
    return v;
 
diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h
index 24c0203629f..c9d1518b220 100644
--- a/src/freedreno/ir3/ir3_shader.h
+++ b/src/freedreno/ir3/ir3_shader.h
@@ -529,7 +529,6 @@ struct ir3_shader_variant {
 
    /* replicated here to avoid passing extra ptrs everywhere: */
    gl_shader_stage type;
-   struct ir3_shader *shader;
    struct ir3_compiler *compiler;
 
    char *name;
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c 
b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
index 63cc1355100..8cc3abacf98 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
@@ -425,7 +425,6 @@ main(int argc, char **argv)
 
    struct ir3_shader_variant *v = rzalloc_size(shader, sizeof(*v));
    v->type = shader->type;
-   v->shader = shader;
    v->compiler = compiler;
    v->key = key;
    v->const_state = rzalloc_size(v, sizeof(*v->const_state));
@@ -436,7 +435,7 @@ main(int argc, char **argv)
    ir3_nir_lower_variant(v, nir);
 
    info = "NIR compiler";
-   ret = ir3_compile_shader_nir(compiler, v);
+   ret = ir3_compile_shader_nir(compiler, shader, v);
    if (ret) {
       fprintf(stderr, "compiler failed!\n");
       return ret;

Reply via email to