Commit 1cf39ec2 authored by Ryan Pavlik's avatar Ryan Pavlik Committed by Jakob Bornecrantz
Browse files

c/main: Add comp_target::has_images, and implement in comp_target_swapchain.

parent 90192118
......@@ -125,8 +125,18 @@ struct comp_target
VkColorSpaceKHR preferred_color_space,
VkPresentModeKHR present_mode);
/*!
* Has this target successfully had images created?
*
* Call before calling @ref acquire - if false but @ref check_ready is true, you'll need to call @ref
* create_images
*/
bool (*has_images)(struct comp_target *ct);
/*!
* Acquire the next image for rendering.
*
* @pre @ref has_images returns true
*/
VkResult (*acquire)(struct comp_target *ct, VkSemaphore semaphore, uint32_t *out_index);
......@@ -266,6 +276,20 @@ comp_target_create_images(struct comp_target *ct,
present_mode); //
}
/*!
* @copydoc comp_target::has_images
*
* @public @memberof comp_target
* @ingroup comp_main
*/
static inline bool
comp_target_has_images(struct comp_target *ct)
{
COMP_TRACE_MARKER();
return ct->has_images(ct);
}
/*!
* @copydoc comp_target::acquire
*
......
......@@ -251,10 +251,13 @@ comp_target_swapchain_acquire_next_image(struct comp_target *ct, VkSemaphore sem
struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct;
struct vk_bundle *vk = get_vk(cts);
if (!comp_target_swapchain_has_images(ct)) {
//! @todo what error to return here?
return VK_ERROR_INITIALIZATION_FAILED;
}
return vk->vkAcquireNextImageKHR( //
vk->device, // device
cts->swapchain.handle, // timeout
cts->swapchain.handle, // swapchain
UINT64_MAX, // timeout
semaphore, // semaphore
VK_NULL_HANDLE, // fence
......@@ -306,6 +309,13 @@ comp_target_swapchain_check_ready(struct comp_target *ct)
return cts->surface.handle != VK_NULL_HANDLE;
}
static bool
comp_target_swapchain_has_images(struct comp_target *ct)
{
struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct;
return cts->surface.handle != VK_NULL_HANDLE && cts->swapchain.handle != VK_NULL_HANDLE;
}
static bool
_find_surface_format(struct comp_target_swapchain *cts, VkSurfaceKHR surface, VkSurfaceFormatKHR *format)
{
......@@ -655,6 +665,7 @@ comp_target_swapchain_init_and_set_fnptrs(struct comp_target_swapchain *cts,
cts->timing_usage = timing_usage;
cts->base.check_ready = comp_target_swapchain_check_ready;
cts->base.create_images = comp_target_swapchain_create_images;
cts->base.has_images = comp_target_swapchain_has_images;
cts->base.acquire = comp_target_swapchain_acquire_next_image;
cts->base.present = comp_target_swapchain_present;
cts->base.calc_frame_timings = comp_target_swapchain_calc_frame_timings;
......
......@@ -85,6 +85,7 @@ struct comp_target_swapchain
*
* - comp_target::check_ready
* - comp_target::create_images
* - comp_target::has_images
* - comp_target::acquire
* - comp_target::present
* - comp_target::calc_frame_timings
......
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