ir3: Remove ir3_shader_variant::shader

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16147>
This commit is contained in:
Connor Abbott 2022-02-16 12:58:16 +01:00 committed by Marge Bot
parent 91160dab97
commit ceae844794
9 changed files with 29 additions and 29 deletions

View File

@ -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));

View File

@ -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 */

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;