struct ir3 * ir3_create(struct ir3_compiler *compiler,
struct ir3_shader_variant *v)
{
- struct ir3 *shader = rzalloc(NULL, struct ir3);
+ struct ir3 *shader = rzalloc(v, struct ir3);
shader->compiler = compiler;
shader->type = v->type;
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) {
unsigned sfu_delay = 0;
struct ir3_shader *
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->type = MESA_SHADER_COMPUTE;
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->shader = shader;
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
* is executed, so max_regs from the shader instructions might not properly
* reflect the # of registers actually used, especially in case passthrough
create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key,
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;
if (!v)
return v;
fail:
- delete_variant(v);
+ ralloc_free(v);
return NULL;
}
void
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);
ralloc_free(shader->nir);
mtx_destroy(&shader->variants_lock);
- free(shader);
+ ralloc_free(shader);
}
/**
ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir,
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);
shader->compiler = compiler;