mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/main: Use cmd pool helpers in layer render
This commit is contained in:
parent
1ddfcaa5ab
commit
5ef2b647f1
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020, Collabora, Ltd.
|
// Copyright 2020-2023, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
|
@ -501,6 +501,12 @@ _init(struct comp_layer_renderer *self,
|
||||||
math_matrix_4x4_identity(&self->mat_eye_view[i]);
|
math_matrix_4x4_identity(&self->mat_eye_view[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult ret = vk_cmd_pool_init(vk, &self->pool, 0);
|
||||||
|
if (ret != VK_SUCCESS) {
|
||||||
|
VK_ERROR(vk, "vk_cmd_pool_init: %s", vk_result_string(ret));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_init_render_pass(vk, format, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, self->sample_count,
|
if (!_init_render_pass(vk, format, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, self->sample_count,
|
||||||
&self->render_pass))
|
&self->render_pass))
|
||||||
return false;
|
return false;
|
||||||
|
@ -627,22 +633,35 @@ void
|
||||||
comp_layer_renderer_draw(struct comp_layer_renderer *self)
|
comp_layer_renderer_draw(struct comp_layer_renderer *self)
|
||||||
{
|
{
|
||||||
COMP_TRACE_MARKER();
|
COMP_TRACE_MARKER();
|
||||||
|
VkResult ret;
|
||||||
|
|
||||||
struct vk_bundle *vk = self->vk;
|
struct vk_bundle *vk = self->vk;
|
||||||
|
struct vk_cmd_pool *pool = &self->pool;
|
||||||
|
|
||||||
|
// Writing and submitting commands.
|
||||||
|
vk_cmd_pool_lock(pool);
|
||||||
|
|
||||||
VkCommandBuffer cmd_buffer;
|
VkCommandBuffer cmd_buffer;
|
||||||
if (vk_cmd_buffer_create_and_begin(vk, &cmd_buffer) != VK_SUCCESS)
|
ret = vk_cmd_pool_create_and_begin_cmd_buffer_locked(vk, pool, 0, &cmd_buffer);
|
||||||
|
if (ret != VK_SUCCESS) {
|
||||||
|
vk_cmd_pool_unlock(pool);
|
||||||
return;
|
return;
|
||||||
os_mutex_lock(&vk->cmd_pool_mutex);
|
}
|
||||||
|
|
||||||
if (self->layer_count == 0) {
|
if (self->layer_count == 0) {
|
||||||
_render_stereo(self, vk, cmd_buffer, &background_color_idle);
|
_render_stereo(self, vk, cmd_buffer, &background_color_idle);
|
||||||
} else {
|
} else {
|
||||||
_render_stereo(self, vk, cmd_buffer, &background_color_active);
|
_render_stereo(self, vk, cmd_buffer, &background_color_active);
|
||||||
}
|
}
|
||||||
os_mutex_unlock(&vk->cmd_pool_mutex);
|
|
||||||
|
|
||||||
VkResult res = vk_cmd_buffer_submit(vk, cmd_buffer);
|
// Done writing commands, submit to queue, waits for command to finish.
|
||||||
vk_check_error("vk_submit_cmd_buffer", res, );
|
ret = vk_cmd_pool_end_submit_wait_and_free_cmd_buffer_locked(vk, pool, cmd_buffer);
|
||||||
|
|
||||||
|
// Done submitting commands.
|
||||||
|
vk_cmd_pool_unlock(pool);
|
||||||
|
|
||||||
|
// Check results from submit.
|
||||||
|
vk_check_error("vk_submit_cmd_buffer", ret, );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -699,6 +718,9 @@ comp_layer_renderer_destroy(struct comp_layer_renderer **ptr_clr)
|
||||||
vk_buffer_destroy(&self->vertex_buffer, vk);
|
vk_buffer_destroy(&self->vertex_buffer, vk);
|
||||||
|
|
||||||
vk->vkDestroyPipelineCache(vk->device, self->pipeline_cache, NULL);
|
vk->vkDestroyPipelineCache(vk->device, self->pipeline_cache, NULL);
|
||||||
|
|
||||||
|
vk_cmd_pool_destroy(vk, &self->pool);
|
||||||
|
|
||||||
free(self);
|
free(self);
|
||||||
*ptr_clr = NULL;
|
*ptr_clr = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2020-2021, Collabora, Ltd.
|
// Copyright 2020-2023, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
|
@ -29,6 +29,8 @@ struct comp_layer_renderer
|
||||||
VkFramebuffer handle;
|
VkFramebuffer handle;
|
||||||
} framebuffers[2];
|
} framebuffers[2];
|
||||||
|
|
||||||
|
struct vk_cmd_pool pool;
|
||||||
|
|
||||||
VkRenderPass render_pass;
|
VkRenderPass render_pass;
|
||||||
|
|
||||||
VkExtent2D extent;
|
VkExtent2D extent;
|
||||||
|
|
Loading…
Reference in a new issue