mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 11:20:11 +01:00
freedreno/ir3: convert over to ralloc
The `ir3_shader` is the root mem ctx, with `ir3_shader_variant` hanging off that, and various variant specific allocations hanging off the variant. This lets us delete a bunch of cleanup code. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5508>
This commit is contained in:
parent
6039d083f7
commit
74140c2e85
3 changed files with 8 additions and 26 deletions
|
|
@ -48,7 +48,7 @@ void * ir3_alloc(struct ir3 *shader, int sz)
|
||||||
struct ir3 * ir3_create(struct ir3_compiler *compiler,
|
struct ir3 * ir3_create(struct ir3_compiler *compiler,
|
||||||
struct ir3_shader_variant *v)
|
struct ir3_shader_variant *v)
|
||||||
{
|
{
|
||||||
struct ir3 *shader = rzalloc(NULL, struct ir3);
|
struct ir3 *shader = rzalloc(v, struct ir3);
|
||||||
|
|
||||||
shader->compiler = compiler;
|
shader->compiler = compiler;
|
||||||
shader->type = v->type;
|
shader->type = v->type;
|
||||||
|
|
@ -944,7 +944,7 @@ void * ir3_assemble(struct ir3_shader_variant *v)
|
||||||
info->sizedwords = align(info->sizedwords, 4 * 2);
|
info->sizedwords = align(info->sizedwords, 4 * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = dwords = calloc(4, info->sizedwords);
|
ptr = dwords = rzalloc_size(v, 4 * info->sizedwords);
|
||||||
|
|
||||||
foreach_block (block, &shader->block_list) {
|
foreach_block (block, &shader->block_list) {
|
||||||
unsigned sfu_delay = 0;
|
unsigned sfu_delay = 0;
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,12 @@
|
||||||
struct ir3_shader *
|
struct ir3_shader *
|
||||||
ir3_parse_asm(struct ir3_compiler *c, struct ir3_kernel_info *info, FILE *in)
|
ir3_parse_asm(struct ir3_compiler *c, struct ir3_kernel_info *info, FILE *in)
|
||||||
{
|
{
|
||||||
struct ir3_shader *shader = calloc(1, sizeof(*shader));
|
struct ir3_shader *shader = rzalloc_size(NULL, sizeof(*shader));
|
||||||
shader->compiler = c;
|
shader->compiler = c;
|
||||||
shader->type = MESA_SHADER_COMPUTE;
|
shader->type = MESA_SHADER_COMPUTE;
|
||||||
mtx_init(&shader->variants_lock, mtx_plain);
|
mtx_init(&shader->variants_lock, mtx_plain);
|
||||||
|
|
||||||
struct ir3_shader_variant *v = calloc(1, sizeof(*v));
|
struct ir3_shader_variant *v = rzalloc_size(shader, sizeof(*v));
|
||||||
v->type = MESA_SHADER_COMPUTE;
|
v->type = MESA_SHADER_COMPUTE;
|
||||||
v->shader = shader;
|
v->shader = shader;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,6 @@ ir3_glsl_type_size(const struct glsl_type *type, bool bindless)
|
||||||
return glsl_count_attribute_slots(type, false);
|
return glsl_count_attribute_slots(type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
delete_variant(struct ir3_shader_variant *v)
|
|
||||||
{
|
|
||||||
if (v->ir)
|
|
||||||
ir3_destroy(v->ir);
|
|
||||||
assert(!v->bo);
|
|
||||||
if (v->binning)
|
|
||||||
delete_variant(v->binning);
|
|
||||||
free(v->bin);
|
|
||||||
free(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* for vertex shader, the inputs are loaded into registers before the shader
|
/* for vertex shader, the inputs are loaded into registers before the shader
|
||||||
* is executed, so max_regs from the shader instructions might not properly
|
* is executed, so max_regs from the shader instructions might not properly
|
||||||
* reflect the # of registers actually used, especially in case passthrough
|
* reflect the # of registers actually used, especially in case passthrough
|
||||||
|
|
@ -184,7 +172,7 @@ static struct ir3_shader_variant *
|
||||||
create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
||||||
struct ir3_shader_variant *nonbinning)
|
struct ir3_shader_variant *nonbinning)
|
||||||
{
|
{
|
||||||
struct ir3_shader_variant *v = CALLOC_STRUCT(ir3_shader_variant);
|
struct ir3_shader_variant *v = rzalloc_size(shader, sizeof(*v));
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!v)
|
if (!v)
|
||||||
|
|
@ -232,7 +220,7 @@ create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
delete_variant(v);
|
ralloc_free(v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,16 +271,10 @@ ir3_shader_get_variant(struct ir3_shader *shader, const struct ir3_shader_key *k
|
||||||
void
|
void
|
||||||
ir3_shader_destroy(struct ir3_shader *shader)
|
ir3_shader_destroy(struct ir3_shader *shader)
|
||||||
{
|
{
|
||||||
struct ir3_shader_variant *v, *t;
|
|
||||||
for (v = shader->variants; v; ) {
|
|
||||||
t = v;
|
|
||||||
v = v->next;
|
|
||||||
delete_variant(t);
|
|
||||||
}
|
|
||||||
free(shader->const_state.immediates);
|
free(shader->const_state.immediates);
|
||||||
ralloc_free(shader->nir);
|
ralloc_free(shader->nir);
|
||||||
mtx_destroy(&shader->variants_lock);
|
mtx_destroy(&shader->variants_lock);
|
||||||
free(shader);
|
ralloc_free(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -355,7 +337,7 @@ struct ir3_shader *
|
||||||
ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir,
|
ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir,
|
||||||
unsigned reserved_user_consts, struct ir3_stream_output_info *stream_output)
|
unsigned reserved_user_consts, struct ir3_stream_output_info *stream_output)
|
||||||
{
|
{
|
||||||
struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader);
|
struct ir3_shader *shader = rzalloc_size(NULL, sizeof(*shader));
|
||||||
|
|
||||||
mtx_init(&shader->variants_lock, mtx_plain);
|
mtx_init(&shader->variants_lock, mtx_plain);
|
||||||
shader->compiler = compiler;
|
shader->compiler = compiler;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue