48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
// =============================================
|
|
// Aster: frame.h
|
|
// Copyright (c) 2020-2024 Anish Bhobe
|
|
// =============================================
|
|
|
|
#pragma once
|
|
|
|
#include "global.h"
|
|
#include "helpers.h"
|
|
|
|
#include <EASTL/fixed_vector.h>
|
|
|
|
struct Device;
|
|
struct Window;
|
|
struct Swapchain;
|
|
|
|
struct Frame
|
|
{
|
|
// Persistent
|
|
const Device *m_Device;
|
|
vk::CommandPool m_Pool;
|
|
vk::CommandBuffer m_CommandBuffer;
|
|
vk::Fence m_FrameAvailableFence;
|
|
vk::Semaphore m_ImageAcquireSem;
|
|
vk::Semaphore m_RenderFinishSem;
|
|
u32 m_FrameIdx;
|
|
|
|
// Transient
|
|
u32 m_ImageIdx;
|
|
|
|
void Present(vk::Queue commandQueue, Swapchain *swapchain, const Window *window);
|
|
|
|
Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount);
|
|
~Frame();
|
|
};
|
|
|
|
struct FrameManager
|
|
{
|
|
const Device *m_Device;
|
|
eastl::fixed_vector<Frame, 4> m_Frames{};
|
|
u32 m_CurrentFrameIdx = 0;
|
|
u32 m_FramesInFlight = 0;
|
|
|
|
FrameManager(const Device *device, u32 queueFamilyIndex, u32 framesInFlight);
|
|
|
|
Frame *GetNextFrame(Swapchain *swapchain, const Window *window);
|
|
};
|