Fix freeze on fullscreen

This commit is contained in:
qwertzuiopy 2025-02-28 17:54:00 +01:00
parent 8efe95258a
commit f0892fd902
2 changed files with 8 additions and 22 deletions

View file

@ -1,7 +1,6 @@
#include "vulkan.h"
#include "kitty.h"
#include "log.h"
#include "matrix.h"
#include "types.h"
#include "image.h"
@ -12,24 +11,6 @@
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#define VERTEX_ATTRIBUTE_COUNT 2
#define QUAD_VERTEX_COUNT 3
struct Vertex quad_vertices[QUAD_VERTEX_COUNT] = {
(struct Vertex){(struct Vec2){.x = 0.0f, .y = -0.5f},
(struct Vec3){1.0f, 0.0f, 1.0f}},
(struct Vertex){(struct Vec2){.x = 0.5f, .y = 0.5f},
(struct Vec3){1.0f, 0.0f, 0.2f}},
(struct Vertex){(struct Vec2){.x = -0.5f, .y = 0.5f},
(struct Vec3){0.2f, 0.0f, 1.0f}},
};
struct UBO {
struct mat3x3 model;
struct mat3x3 view;
struct mat3x3 proj;
};
VkVertexInputBindingDescription get_vertex_binding_description() {
VkVertexInputBindingDescription description = {0};
description.binding = 0;
@ -796,9 +777,12 @@ void uninit_vk(struct Vk *state) {
}
void vk_draw(struct Vk *state) {
CHECK_VK_RESULT(vkWaitForFences(
state->device, 1, &state->flights[state->current_frame].in_flight_fence,
VK_TRUE, UINT64_MAX));
if (state->should_wait_for_fences) {
CHECK_VK_RESULT(vkWaitForFences(
state->device, 1, &state->flights[state->current_frame].in_flight_fence,
VK_TRUE, UINT64_MAX));
state->should_wait_for_fences = true;
}
CHECK_VK_RESULT(vkResetFences(
state->device, 1, &state->flights[state->current_frame].in_flight_fence));
@ -815,6 +799,7 @@ void vk_draw(struct Vk *state) {
meow("recreating swapchain");
CHECK_VK_RESULT(vkDeviceWaitIdle(state->device));
recreate_swapchain(state);
state->should_wait_for_fences = false;
return;
} else if (result < 0) {
CHECK_VK_RESULT(result);

View file

@ -95,6 +95,7 @@ struct Vk {
uint32_t width;
uint32_t heigh;
VkRenderPass render_pass;
bool should_wait_for_fences;
struct GpuMem *mem;
struct da_Kitty kitties;