Compare commits

...

1 Commits

View File

@ -1156,8 +1156,8 @@ typedef struct {
void recreate_swapchain(state_r0 *state) {
// We are about stop program and rebuild our sem+sem+fence synchronization mechanism
vkDeviceWaitIdle(state->vk_ctx.device);
Jane_r0_destroy(state->vk_ctx.device, state->vk_ctx.jane);
state->vk_ctx.jane = Jane_r0_create(state->vk_ctx.device);
// Jane_r0_destroy(state->vk_ctx.device, state->vk_ctx.jane);
// state->vk_ctx.jane = Jane_r0_create(state->vk_ctx.device);
VkSwapchainKHR old_swapchain = MargaretSwapchainBundle_pop_swapchain_drop_rest(
state->vk_ctx.device, state->vk_ctx.swfb);
// old swfb is 83% dropped
@ -1220,27 +1220,22 @@ void update_state(state_r0* state, uint32_t dur) {
}
void vulkano_frame_drawing(state_r0* state) {
check(vkWaitForFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence, VK_TRUE, UINT64_MAX) == VK_SUCCESS);
check(vkResetFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence) == VK_SUCCESS);
and_again:
vkWaitForFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence, VK_TRUE, UINT64_MAX);
uint32_t ij;
VkResult aq_ret = vkAcquireNextImageKHR(
state->vk_ctx.device, state->vk_ctx.swfb.swapchain,
UINT64_MAX, state->vk_ctx.jane.image_available_semaphore, VK_NULL_HANDLE, &ij
);
if (aq_ret == VK_ERROR_OUT_OF_DATE_KHR) {
if (aq_ret == VK_ERROR_OUT_OF_DATE_KHR || aq_ret == VK_SUBOPTIMAL_KHR) {
fprintf(stderr, "vkAcquireNextImageKHR: VK_ERROR_OUT_OF_DATE_KHR\n");
recreate_swapchain(state);
goto and_again;
} else if (aq_ret == VK_SUBOPTIMAL_KHR) {
fprintf(stderr, "vkAcquireNextImageKHR: VK_SUBOPTIMAL_KHR\n");
recreate_swapchain(state);
goto and_again;
} else if (aq_ret != VK_SUCCESS) {
abortf("vkAcquireNextImageKHR");
}
vkResetFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence);
state->vk_ctx.scene.color = (VkClearColorValue){{0, 0.5f, 0.9f, 1}};
mat4 projection_matrix = marie_perspective_projection_fov_mat4(
(float)state->width_confirmed, (float)state->height_confirmed,
@ -1368,16 +1363,14 @@ void vulkano_frame_drawing(state_r0* state) {
};
VkResult pres_ret = vkQueuePresentKHR(state->vk_ctx.queues.presentation_queue, &present_info);
// todo: ponder more over this
if (pres_ret == VK_ERROR_OUT_OF_DATE_KHR) {
if (pres_ret == VK_ERROR_OUT_OF_DATE_KHR || pres_ret == VK_SUBOPTIMAL_KHR) {
fprintf(stderr, "vkQueuePresentKHR: VK_ERROR_OUT_OF_DATE_KHR\n");
check(vkWaitForFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence, VK_TRUE, UINT64_MAX) == VK_SUCCESS);
check(vkResetFences(state->vk_ctx.device, 1, &state->vk_ctx.jane.in_flight_fence) == VK_SUCCESS);
recreate_swapchain(state);
goto and_again;
} else if (pres_ret == VK_SUBOPTIMAL_KHR) {
fprintf(stderr, "vkQueuePresentKHR: VK_SUBOPTIMAL_KHR\n");
recreate_swapchain(state);
goto and_again;
} else if (pres_ret != VK_SUCCESS) {
}
if (pres_ret != VK_SUCCESS) {
abortf("vkQueuePresentKHR");
}
}