Skip to content

Commit

Permalink
cube: Fix incremental present on swapchain recreate
Browse files Browse the repository at this point in the history
  • Loading branch information
ziga-lunarg committed May 6, 2024
1 parent 09f5cc6 commit e743dc2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ struct demo {
VkPresentModeKHR presentMode;
VkFence fences[FRAME_LAG];
int frame_index;
bool first_frame;
bool first_swapchain_frame;

VkCommandPool cmd_pool;
VkCommandPool present_cmd_pool;
Expand Down Expand Up @@ -1135,7 +1135,7 @@ static void demo_draw(struct demo *demo) {
uint32_t eighthOfWidth = demo->width / 8;
uint32_t eighthOfHeight = demo->height / 8;

if (demo->first_frame) {
if (demo->first_swapchain_frame) {
rect.offset.x = 0;
rect.offset.y = 0;
rect.extent.width = demo->width;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ static void demo_draw(struct demo *demo) {
err = vkQueuePresentKHR(demo->present_queue, &present);
demo->frame_index += 1;
demo->frame_index %= FRAME_LAG;
demo->first_frame = false;
demo->first_swapchain_frame = false;

if (err == VK_ERROR_OUT_OF_DATE_KHR) {
// demo->swapchain is out of date (e.g. the window was resized) and
Expand Down Expand Up @@ -2366,6 +2366,7 @@ static void demo_prepare(struct demo *demo) {

demo->current_buffer = 0;
demo->prepared = true;
demo->first_swapchain_frame = true;
}

static void demo_cleanup(struct demo *demo) {
Expand Down

0 comments on commit e743dc2

Please sign in to comment.