vulkan: vulkan_compute initialize base on plugin creation

This commit is contained in:
columbarius 2023-08-11 23:03:31 +02:00 committed by Wim Taymans
parent 402ed65a79
commit 06a1d5151b
3 changed files with 11 additions and 2 deletions

View file

@ -650,6 +650,13 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
static int impl_clear(struct spa_handle *handle)
{
struct impl *this;
spa_return_val_if_fail(handle != NULL, -EINVAL);
this = (struct impl *) handle;
spa_vulkan_deinit(&this->state);
return 0;
}
@ -742,6 +749,7 @@ impl_init(const struct spa_handle_factory *factory,
SPA_DIRECTION_OUTPUT, NULL);
this->state.n_streams = 2;
spa_vulkan_init(&this->state);
spa_vulkan_prepare(&this->state);
return 0;

View file

@ -860,6 +860,8 @@ static int impl_clear(struct spa_handle *handle)
this = (struct impl *) handle;
spa_vulkan_deinit(&this->state);
if (this->data_loop)
spa_loop_invoke(this->data_loop, do_remove_timer, 0, NULL, 0, true, this);
spa_system_close(this->data_system, this->timer_source.fd);
@ -952,6 +954,7 @@ impl_init(const struct spa_handle_factory *factory,
SPA_DIRECTION_OUTPUT, NULL);
this->state.shaderName = "spa/plugins/vulkan/shaders/main.spv";
this->state.n_streams = 1;
spa_vulkan_init(&this->state);
return 0;
}

View file

@ -414,7 +414,6 @@ int spa_vulkan_init_stream(struct vulkan_compute_state *s, struct vulkan_stream
int spa_vulkan_prepare(struct vulkan_compute_state *s)
{
if (!s->prepared) {
CHECK(spa_vulkan_init(s));
CHECK(createFence(s));
CHECK(createDescriptors(s));
CHECK(createComputePipeline(s, s->shaderName));
@ -435,7 +434,6 @@ int spa_vulkan_unprepare(struct vulkan_compute_state *s)
vkDestroyPipeline(s->base.device, s->pipeline, NULL);
vkDestroyCommandPool(s->base.device, s->commandPool, NULL);
vkDestroyFence(s->base.device, s->fence, NULL);
spa_vulkan_deinit(s);
s->prepared = false;
}
return 0;