Added memory arena
Fixed frames in flight validation error in vulkan Added some utility macros Added function decorator macros Added some consolidation headers/code include files
This commit is contained in:
@@ -294,10 +294,16 @@ bool Vk_Setup(SDL_Window *window) {
|
||||
vk.GetSwapchainImagesKHR(vk.device, vk.swapchain.handle, &n_images, 0);
|
||||
vk.GetSwapchainImagesKHR(vk.device, vk.swapchain.handle, &n_images, vk.swapchain.images);
|
||||
|
||||
vk.in_flight = n_images + 1;
|
||||
|
||||
if (n_images != vk.swapchain.n_images) {
|
||||
printf("[Warn] :: Swapchain image count mismatch\n");
|
||||
vk.swapchain.n_images = n_images;
|
||||
}
|
||||
else if (n_images >= VK_MAX_FRAMES_IN_FLIGHT) {
|
||||
printf("[Warn] :: Min image count too high: %d\n", n_images);
|
||||
vk.in_flight = VK_MAX_FRAMES_IN_FLIGHT;
|
||||
}
|
||||
|
||||
VkImageViewCreateInfo create_info = { 0 };
|
||||
create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
@@ -314,7 +320,7 @@ bool Vk_Setup(SDL_Window *window) {
|
||||
}
|
||||
}
|
||||
|
||||
for (U32 it = 0; it < VK_FRAMES_IN_FLIGHT && vk.err == VK_SUCCESS; ++it) {
|
||||
for (U32 it = 0; it < vk.in_flight && vk.err == VK_SUCCESS; ++it) {
|
||||
Vk_Frame *frame = &vk.frames[it];
|
||||
|
||||
VkCommandPoolCreateInfo pool = { 0 };
|
||||
@@ -353,7 +359,7 @@ bool Vk_Setup(SDL_Window *window) {
|
||||
|
||||
Vk_Frame *Vk_FrameBegin(SDL_Window *window) {
|
||||
(void) window; // might need this for the resize later
|
||||
Vk_Frame *frame = &vk.frames[vk.n_frames & 1];
|
||||
Vk_Frame *frame = &vk.frames[vk.n_frames % vk.in_flight];
|
||||
|
||||
vk.WaitForFences(vk.device, 1, &frame->fence, VK_TRUE, UINT64_MAX);
|
||||
|
||||
@@ -372,7 +378,7 @@ Vk_Frame *Vk_FrameBegin(SDL_Window *window) {
|
||||
}
|
||||
|
||||
void Vk_FrameEnd() {
|
||||
Vk_Frame *frame = &vk.frames[vk.n_frames & 1];
|
||||
Vk_Frame *frame = &vk.frames[vk.n_frames % vk.in_flight];
|
||||
|
||||
vk.EndCommandBuffer(frame->cmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user