55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
// =============================================
|
|
// Aster: frame.h
|
|
// Copyright (c) 2020-2025 Anish Bhobe
|
|
// =============================================
|
|
|
|
#pragma once
|
|
|
|
#include "aster/aster.h"
|
|
#include "helpers.h"
|
|
|
|
#include "aster/core/size.h"
|
|
|
|
#include <EASTL/fixed_vector.h>
|
|
|
|
struct Device;
|
|
struct Window;
|
|
struct Swapchain;
|
|
struct Surface;
|
|
|
|
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 Surface *surface, Size2D size);
|
|
|
|
Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount);
|
|
~Frame();
|
|
|
|
Frame(Frame &&other) noexcept;
|
|
Frame &operator=(Frame &&other) noexcept;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(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 Surface *surface, Size2D size);
|
|
}; |