zink: add function for refcounting zink_program structs
step one in maybe cleaning up and deduplicating some program code Acked-by: Emma Anholt <emma@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15226>
This commit is contained in:
parent
9a6c58b2f7
commit
cbd9a91f64
|
@ -84,13 +84,7 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs)
|
|||
set_foreach_remove(bs->programs, entry) {
|
||||
struct zink_program *pg = (struct zink_program*)entry->key;
|
||||
zink_batch_usage_unset(&pg->batch_uses, bs);
|
||||
if (pg->is_compute) {
|
||||
struct zink_compute_program *comp = (struct zink_compute_program*)pg;
|
||||
zink_compute_program_reference(ctx, &comp, NULL);
|
||||
} else {
|
||||
struct zink_gfx_program *prog = (struct zink_gfx_program*)pg;
|
||||
zink_gfx_program_reference(ctx, &prog, NULL);
|
||||
}
|
||||
zink_program_reference(ctx, &pg, NULL);
|
||||
}
|
||||
|
||||
pipe_resource_reference(&bs->flush_res, NULL);
|
||||
|
|
|
@ -272,6 +272,23 @@ zink_compute_program_reference(struct zink_context *ctx,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
zink_program_reference(struct zink_context *ctx,
|
||||
struct zink_program **dst,
|
||||
struct zink_program *src)
|
||||
{
|
||||
struct zink_program *pg = src ? src : dst ? *dst : NULL;
|
||||
if (!pg)
|
||||
return false;
|
||||
if (pg->is_compute) {
|
||||
struct zink_compute_program *comp = (struct zink_compute_program*)pg;
|
||||
return zink_compute_program_reference(ctx, &comp, NULL);
|
||||
} else {
|
||||
struct zink_gfx_program *prog = (struct zink_gfx_program*)pg;
|
||||
return zink_gfx_program_reference(ctx, &prog, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
VkPipelineLayout
|
||||
zink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg, uint32_t *compat);
|
||||
|
||||
|
|
Loading…
Reference in New Issue