/* Cache miss. Build one instead, cache it, and go */
- struct panfrost_blend_shader generated =
- panfrost_compile_blend_shader(ctx, blend, fmt, rt);
-
- shader = mem_dup(&generated, sizeof(generated));
+ shader = panfrost_compile_blend_shader(ctx, blend, fmt, rt);
_mesa_hash_table_u64_insert(shaders, key, shader);
return shader;
}
}
static void
-panfrost_delete_blend_shader(struct hash_entry *entry)
-{
- struct panfrost_blend_shader *shader = (struct panfrost_blend_shader *)entry->data;
- free(shader->buffer);
- free(shader);
-}
-
-static void
panfrost_delete_blend_state(struct pipe_context *pipe,
void *cso)
{
struct panfrost_blend_state *blend = (struct panfrost_blend_state *) cso;
-
- for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
- struct panfrost_blend_rt *rt = &blend->rt[c];
- _mesa_hash_table_u64_clear(rt->shaders, panfrost_delete_blend_shader);
- }
ralloc_free(blend);
}
return nir_imin(b, nir_imax(b, v, nir_imm_int(b, lo)), nir_imm_int(b, hi));
}
-struct panfrost_blend_shader
-panfrost_compile_blend_shader(
- struct panfrost_context *ctx,
- struct panfrost_blend_state *state,
- enum pipe_format format,
- unsigned rt)
+struct panfrost_blend_shader *
+panfrost_compile_blend_shader(struct panfrost_context *ctx,
+ struct panfrost_blend_state *state,
+ enum pipe_format format,
+ unsigned rt)
{
struct panfrost_device *dev = pan_device(ctx->base.screen);
- struct panfrost_blend_shader res;
+ struct panfrost_blend_shader *res = ralloc(state, struct panfrost_blend_shader);
- res.ctx = ctx;
+ res->ctx = ctx;
/* Build the shader */
midgard_compile_shader_nir(shader, &program, &inputs);
/* Allow us to patch later */
- res.patch_index = program.blend_patch_offset;
- res.first_tag = program.first_tag;
- res.size = program.compiled.size;
- res.buffer = program.compiled.data;
- res.work_count = program.work_register_count;
+ res->patch_index = program.blend_patch_offset;
+ res->first_tag = program.first_tag;
+ res->size = program.compiled.size;
+ res->buffer = ralloc_size(res, res->size);
+ memcpy(res->buffer, program.compiled.data, res->size);
+ util_dynarray_fini(&program.compiled);
+ res->work_count = program.work_register_count;
return res;
}
#include "pan_context.h"
#include "pan_blend.h"
-struct panfrost_blend_shader
-panfrost_compile_blend_shader(
- struct panfrost_context *ctx,
- struct panfrost_blend_state *state,
- enum pipe_format format,
- unsigned rt);
+struct panfrost_blend_shader *
+panfrost_compile_blend_shader(struct panfrost_context *ctx,
+ struct panfrost_blend_state *state,
+ enum pipe_format format,
+ unsigned rt);
#endif