aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziga-lunarg <ziga@lunarg.com>2024-04-26 22:50:59 +0200
committerziga-lunarg <87310389+ziga-lunarg@users.noreply.github.com>2024-04-26 23:14:24 +0200
commiteaf7af1a937f3e9624bef112a1c8c4ca86c1c55d (patch)
tree211ca12a9eec4aaed4ab0daf14d9bef495fb2423
parent9aec60c387fb0cd065d3ba921b56c3ef19ad958e (diff)
downloadusermoji-eaf7af1a937f3e9624bef112a1c8c4ca86c1c55d.tar.xz
cube: Fix incremental present
-rw-r--r--cube/cube.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/cube/cube.c b/cube/cube.c
index 07d4a97a..cdfadac8 100644
--- a/cube/cube.c
+++ b/cube/cube.c
@@ -394,6 +394,7 @@ struct demo {
VkPresentModeKHR presentMode;
VkFence fences[FRAME_LAG];
int frame_index;
+ bool first_frame;
VkCommandPool cmd_pool;
VkCommandPool present_cmd_pool;
@@ -1134,10 +1135,17 @@ static void demo_draw(struct demo *demo) {
uint32_t eighthOfWidth = demo->width / 8;
uint32_t eighthOfHeight = demo->height / 8;
- rect.offset.x = eighthOfWidth;
- rect.offset.y = eighthOfHeight;
- rect.extent.width = eighthOfWidth * 6;
- rect.extent.height = eighthOfHeight * 6;
+ if (demo->first_frame) {
+ rect.offset.x = 0;
+ rect.offset.y = 0;
+ rect.extent.width = demo->width;
+ rect.extent.height = demo->height;
+ } else {
+ rect.offset.x = eighthOfWidth;
+ rect.offset.y = eighthOfHeight;
+ rect.extent.width = eighthOfWidth * 6;
+ rect.extent.height = eighthOfHeight * 6;
+ }
rect.layer = 0;
region.rectangleCount = 1;
@@ -1188,6 +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;
if (err == VK_ERROR_OUT_OF_DATE_KHR) {
// demo->swapchain is out of date (e.g. the window was resized) and
@@ -4023,6 +4032,7 @@ static void demo_init_vk_swapchain(struct demo *demo) {
}
}
demo->frame_index = 0;
+ demo->first_frame = true;
// Get Memory information and properties
vkGetPhysicalDeviceMemoryProperties(demo->gpu, &demo->memory_properties);