diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index abde829dfc0..af57faa8adf 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -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); diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index 17a12ff89f5..87c4c73f6d4 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -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);