Commit a3d5026e authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Defer destroying Vulkan compute pipelines.

Vulkan pipelines should be destroyed only after the last command buffer using the pipeline is done executing. Since we do not track which pipelines are encoded into which command buffers, defer destruction until the current command buffer finishes. Signed-off-by: 's avatarJan Sikorski <jsikorski@codeweavers.com>
parent 6d4cf5b2
......@@ -964,6 +964,32 @@ static void wined3d_context_vk_reset_completed_queries(struct wined3d_context_vk
memset(pool_vk->completed, 0, sizeof(pool_vk->completed));
}
void wined3d_context_vk_destroy_vk_pipeline(struct wined3d_context_vk *context_vk,
VkPipeline vk_pipeline, uint64_t command_buffer_id)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
const struct wined3d_vk_info *vk_info = context_vk->vk_info;
struct wined3d_retired_object_vk *o;
if (context_vk->completed_command_buffer_id > command_buffer_id)
{
VK_CALL(vkDestroyPipeline(device_vk->vk_device, vk_pipeline, NULL));
TRACE("Destroyed pipeline 0x%s.\n", wine_dbgstr_longlong(vk_pipeline));
return;
}
if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
{
ERR("Leaking pipeline 0x%s.\n", wine_dbgstr_longlong(vk_pipeline));
return;
}
o->type = WINED3D_RETIRED_PIPELINE_VK;
o->u.vk_pipeline = vk_pipeline;
o->command_buffer_id = command_buffer_id;
}
void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk,
VkSampler vk_sampler, uint64_t command_buffer_id)
{
......@@ -1184,6 +1210,11 @@ static void wined3d_context_vk_cleanup_resources(struct wined3d_context_vk *cont
TRACE("Destroyed event 0x%s.\n", wine_dbgstr_longlong(o->u.vk_event));
break;
case WINED3D_RETIRED_PIPELINE_VK:
VK_CALL(vkDestroyPipeline(device_vk->vk_device, o->u.vk_pipeline, NULL));
TRACE("Destroyed pipeline 0x%s.\n", wine_dbgstr_longlong(o->u.vk_pipeline));
break;
default:
ERR("Unhandled object type %#x.\n", o->type);
break;
......
......@@ -926,10 +926,11 @@ static void shader_spirv_destroy_compute_vk(struct wined3d_shader *shader)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(shader->device);
struct shader_spirv_compute_program_vk *program = shader->backend_data;
struct wined3d_context_vk *context_vk = &device_vk->context_vk;
struct wined3d_vk_info *vk_info = &device_vk->vk_info;
shader_spirv_invalidate_contexts_compute_program(&device_vk->d, program);
VK_CALL(vkDestroyPipeline(device_vk->vk_device, program->vk_pipeline, NULL));
wined3d_context_vk_destroy_vk_pipeline(context_vk, program->vk_pipeline, context_vk->current_command_buffer.id);
VK_CALL(vkDestroyShaderModule(device_vk->vk_device, program->vk_module, NULL));
vkd3d_shader_free_scan_descriptor_info(&program->descriptor_info);
shader->backend_data = NULL;
......
......@@ -2479,6 +2479,7 @@ enum wined3d_retired_object_type_vk
WINED3D_RETIRED_SAMPLER_VK,
WINED3D_RETIRED_QUERY_POOL_VK,
WINED3D_RETIRED_EVENT_VK,
WINED3D_RETIRED_PIPELINE_VK,
};
struct wined3d_retired_object_vk
......@@ -2502,6 +2503,7 @@ struct wined3d_retired_object_vk
VkImageView vk_image_view;
VkSampler vk_sampler;
VkEvent vk_event;
VkPipeline vk_pipeline;
struct
{
struct wined3d_query_pool_vk *pool_vk;
......@@ -2735,6 +2737,8 @@ void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk
VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
void wined3d_context_vk_destroy_vk_event(struct wined3d_context_vk *context_vk,
VkEvent vk_event, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
void wined3d_context_vk_destroy_vk_pipeline(struct wined3d_context_vk *context_vk,
VkPipeline vk_pipeline, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
struct wined3d_pipeline_layout_vk *wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment