zink: add zink_program struct as a base class for compute/gfx structs
this is going to be useful for managing descriptors Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9273>
This commit is contained in:

committed by
Marge Bot

parent
50ca42dc43
commit
5503ffecfb
@@ -510,19 +510,19 @@ update_descriptors(struct zink_context *ctx, struct zink_screen *screen, bool is
|
|||||||
unsigned num_descriptors;
|
unsigned num_descriptors;
|
||||||
VkDescriptorSetLayout dsl;
|
VkDescriptorSetLayout dsl;
|
||||||
if (is_compute) {
|
if (is_compute) {
|
||||||
num_descriptors = ctx->curr_compute->num_descriptors;
|
num_descriptors = ctx->curr_compute->base.num_descriptors;
|
||||||
dsl = ctx->curr_compute->dsl;
|
dsl = ctx->curr_compute->base.dsl;
|
||||||
batch = &ctx->compute_batch;
|
batch = &ctx->compute_batch;
|
||||||
} else {
|
} else {
|
||||||
batch = zink_batch_rp(ctx);
|
batch = zink_batch_rp(ctx);
|
||||||
num_descriptors = ctx->curr_program->num_descriptors;
|
num_descriptors = ctx->curr_program->base.num_descriptors;
|
||||||
dsl = ctx->curr_program->dsl;
|
dsl = ctx->curr_program->base.dsl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_compute)
|
if (is_compute)
|
||||||
zink_batch_reference_program(batch, &ctx->curr_compute->reference);
|
zink_batch_reference_program(batch, &ctx->curr_compute->base.reference);
|
||||||
else
|
else
|
||||||
zink_batch_reference_program(batch, &ctx->curr_program->reference);
|
zink_batch_reference_program(batch, &ctx->curr_program->base.reference);
|
||||||
|
|
||||||
if (batch->descs_used + num_descriptors >= batch->max_descs) {
|
if (batch->descs_used + num_descriptors >= batch->max_descs) {
|
||||||
if (is_compute)
|
if (is_compute)
|
||||||
@@ -769,7 +769,7 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||||||
barrier_vertex_buffers(ctx);
|
barrier_vertex_buffers(ctx);
|
||||||
barrier_draw_buffers(ctx, dinfo, dindirect, index_buffer);
|
barrier_draw_buffers(ctx, dinfo, dindirect, index_buffer);
|
||||||
|
|
||||||
if (gfx_program->num_descriptors)
|
if (gfx_program->base.num_descriptors)
|
||||||
update_descriptors(ctx, screen, false);
|
update_descriptors(ctx, screen, false);
|
||||||
|
|
||||||
struct zink_batch *batch = zink_batch_rp(ctx);
|
struct zink_batch *batch = zink_batch_rp(ctx);
|
||||||
@@ -971,7 +971,7 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
|
|||||||
VkPipeline pipeline = zink_get_compute_pipeline(screen, comp_program,
|
VkPipeline pipeline = zink_get_compute_pipeline(screen, comp_program,
|
||||||
&ctx->compute_pipeline_state);
|
&ctx->compute_pipeline_state);
|
||||||
|
|
||||||
if (comp_program->num_descriptors)
|
if (comp_program->base.num_descriptors)
|
||||||
update_descriptors(ctx, screen, true);
|
update_descriptors(ctx, screen, true);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -457,7 +457,7 @@ zink_create_gfx_program(struct zink_context *ctx,
|
|||||||
if (!prog)
|
if (!prog)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
pipe_reference_init(&prog->reference, 1);
|
pipe_reference_init(&prog->base.reference, 1);
|
||||||
|
|
||||||
init_slot_map(ctx, prog);
|
init_slot_map(ctx, prog);
|
||||||
|
|
||||||
@@ -478,12 +478,12 @@ zink_create_gfx_program(struct zink_context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prog->dsl = create_desc_set_layout(screen->dev, stages,
|
prog->base.dsl = create_desc_set_layout(screen->dev, stages,
|
||||||
&prog->num_descriptors);
|
&prog->base.num_descriptors);
|
||||||
if (prog->num_descriptors && !prog->dsl)
|
if (prog->base.num_descriptors && !prog->base.dsl)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
prog->layout = create_gfx_pipeline_layout(screen->dev, prog->dsl);
|
prog->layout = create_gfx_pipeline_layout(screen->dev, prog->base.dsl);
|
||||||
if (!prog->layout)
|
if (!prog->layout)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ zink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader
|
|||||||
if (!comp)
|
if (!comp)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
pipe_reference_init(&comp->reference, 1);
|
pipe_reference_init(&comp->base.reference, 1);
|
||||||
|
|
||||||
if (!ctx->curr_compute || !ctx->curr_compute->shader_cache) {
|
if (!ctx->curr_compute || !ctx->curr_compute->shader_cache) {
|
||||||
/* TODO: cs shader keys placeholder for now */
|
/* TODO: cs shader keys placeholder for now */
|
||||||
@@ -578,12 +578,12 @@ zink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader
|
|||||||
|
|
||||||
struct zink_shader *stages[ZINK_SHADER_COUNT] = {};
|
struct zink_shader *stages[ZINK_SHADER_COUNT] = {};
|
||||||
stages[0] = shader;
|
stages[0] = shader;
|
||||||
comp->dsl = create_desc_set_layout(screen->dev, stages,
|
comp->base.dsl = create_desc_set_layout(screen->dev, stages,
|
||||||
&comp->num_descriptors);
|
&comp->base.num_descriptors);
|
||||||
if (comp->num_descriptors && !comp->dsl)
|
if (comp->base.num_descriptors && !comp->base.dsl)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
comp->layout = create_compute_pipeline_layout(screen->dev, comp->dsl);
|
comp->layout = create_compute_pipeline_layout(screen->dev, comp->base.dsl);
|
||||||
if (!comp->layout)
|
if (!comp->layout)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -612,8 +612,8 @@ zink_destroy_gfx_program(struct zink_screen *screen,
|
|||||||
if (prog->layout)
|
if (prog->layout)
|
||||||
vkDestroyPipelineLayout(screen->dev, prog->layout, NULL);
|
vkDestroyPipelineLayout(screen->dev, prog->layout, NULL);
|
||||||
|
|
||||||
if (prog->dsl)
|
if (prog->base.dsl)
|
||||||
vkDestroyDescriptorSetLayout(screen->dev, prog->dsl, NULL);
|
vkDestroyDescriptorSetLayout(screen->dev, prog->base.dsl, NULL);
|
||||||
|
|
||||||
for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
|
for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
|
||||||
if (prog->shaders[i])
|
if (prog->shaders[i])
|
||||||
@@ -643,8 +643,8 @@ zink_destroy_compute_program(struct zink_screen *screen,
|
|||||||
if (comp->layout)
|
if (comp->layout)
|
||||||
vkDestroyPipelineLayout(screen->dev, comp->layout, NULL);
|
vkDestroyPipelineLayout(screen->dev, comp->layout, NULL);
|
||||||
|
|
||||||
if (comp->dsl)
|
if (comp->base.dsl)
|
||||||
vkDestroyDescriptorSetLayout(screen->dev, comp->dsl, NULL);
|
vkDestroyDescriptorSetLayout(screen->dev, comp->base.dsl, NULL);
|
||||||
|
|
||||||
if (comp->shader)
|
if (comp->shader)
|
||||||
_mesa_set_remove_key(comp->shader->programs, comp);
|
_mesa_set_remove_key(comp->shader->programs, comp);
|
||||||
|
@@ -62,29 +62,32 @@ struct zink_shader_cache {
|
|||||||
struct hash_table *shader_cache;
|
struct hash_table *shader_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zink_gfx_program {
|
struct zink_program {
|
||||||
struct pipe_reference reference;
|
struct pipe_reference reference;
|
||||||
|
|
||||||
|
VkDescriptorSetLayout dsl;
|
||||||
|
unsigned num_descriptors;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct zink_gfx_program {
|
||||||
|
struct zink_program base;
|
||||||
|
|
||||||
struct zink_shader_module *modules[ZINK_SHADER_COUNT]; // compute stage doesn't belong here
|
struct zink_shader_module *modules[ZINK_SHADER_COUNT]; // compute stage doesn't belong here
|
||||||
struct zink_shader *shaders[ZINK_SHADER_COUNT];
|
struct zink_shader *shaders[ZINK_SHADER_COUNT];
|
||||||
struct zink_shader_cache *shader_cache;
|
struct zink_shader_cache *shader_cache;
|
||||||
unsigned char shader_slot_map[VARYING_SLOT_MAX];
|
unsigned char shader_slot_map[VARYING_SLOT_MAX];
|
||||||
unsigned char shader_slots_reserved;
|
unsigned char shader_slots_reserved;
|
||||||
VkDescriptorSetLayout dsl;
|
|
||||||
VkPipelineLayout layout;
|
VkPipelineLayout layout;
|
||||||
unsigned num_descriptors;
|
|
||||||
struct hash_table *pipelines[11]; // number of draw modes we support
|
struct hash_table *pipelines[11]; // number of draw modes we support
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zink_compute_program {
|
struct zink_compute_program {
|
||||||
struct pipe_reference reference;
|
struct zink_program base;
|
||||||
|
|
||||||
struct zink_shader_module *module;
|
struct zink_shader_module *module;
|
||||||
struct zink_shader *shader;
|
struct zink_shader *shader;
|
||||||
struct zink_shader_cache *shader_cache;
|
struct zink_shader_cache *shader_cache;
|
||||||
VkDescriptorSetLayout dsl;
|
|
||||||
VkPipelineLayout layout;
|
VkPipelineLayout layout;
|
||||||
unsigned num_descriptors;
|
|
||||||
struct hash_table *pipelines;
|
struct hash_table *pipelines;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,7 +121,7 @@ zink_gfx_program_reference(struct zink_screen *screen,
|
|||||||
{
|
{
|
||||||
struct zink_gfx_program *old_dst = dst ? *dst : NULL;
|
struct zink_gfx_program *old_dst = dst ? *dst : NULL;
|
||||||
|
|
||||||
if (pipe_reference_described(old_dst ? &old_dst->reference : NULL, &src->reference,
|
if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference,
|
||||||
(debug_reference_descriptor)debug_describe_zink_gfx_program))
|
(debug_reference_descriptor)debug_describe_zink_gfx_program))
|
||||||
zink_destroy_gfx_program(screen, old_dst);
|
zink_destroy_gfx_program(screen, old_dst);
|
||||||
if (dst) *dst = src;
|
if (dst) *dst = src;
|
||||||
@@ -140,7 +143,7 @@ zink_compute_program_reference(struct zink_screen *screen,
|
|||||||
{
|
{
|
||||||
struct zink_compute_program *old_dst = dst ? *dst : NULL;
|
struct zink_compute_program *old_dst = dst ? *dst : NULL;
|
||||||
|
|
||||||
if (pipe_reference_described(old_dst ? &old_dst->reference : NULL, &src->reference,
|
if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference,
|
||||||
(debug_reference_descriptor)debug_describe_zink_compute_program))
|
(debug_reference_descriptor)debug_describe_zink_compute_program))
|
||||||
zink_destroy_compute_program(screen, old_dst);
|
zink_destroy_compute_program(screen, old_dst);
|
||||||
if (dst) *dst = src;
|
if (dst) *dst = src;
|
||||||
|
Reference in New Issue
Block a user