83 lines
2.6 KiB
C
83 lines
2.6 KiB
C
|
#ifndef HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|
|||
|
#define HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|
|||
|
|
|||
|
#include<hgl/graph/Vulkan/VK.h>
|
|||
|
#include<hgl/graph/vulkan/VKFramebuffer.h>
|
|||
|
#include<hgl/graph/vulkan/VKFence.h>
|
|||
|
#include<hgl/graph/vulkan/VKSemaphore.h>
|
|||
|
VK_NAMESPACE_BEGIN
|
|||
|
class Swapchain
|
|||
|
{
|
|||
|
protected:
|
|||
|
|
|||
|
Device *device;
|
|||
|
|
|||
|
VkExtent2D extent;
|
|||
|
|
|||
|
VkQueue graphics_queue =VK_NULL_HANDLE;
|
|||
|
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
|||
|
|
|||
|
uint32_t swap_chain_count;
|
|||
|
|
|||
|
ObjectList<Texture2D> sc_texture;
|
|||
|
Texture2D * sc_depth =nullptr;
|
|||
|
|
|||
|
protected:
|
|||
|
|
|||
|
VkPipelineStageFlags pipe_stage_flags;
|
|||
|
|
|||
|
uint32_t current_frame;
|
|||
|
ObjectList<Framebuffer> render_frame;
|
|||
|
|
|||
|
uint32_t current_fence;
|
|||
|
ObjectList<Fence> fence_list;
|
|||
|
|
|||
|
RenderPass *main_rp =nullptr;
|
|||
|
|
|||
|
Semaphore *present_complete_semaphore =nullptr,
|
|||
|
*render_complete_semaphore =nullptr;
|
|||
|
|
|||
|
VkSubmitInfo submit_info;
|
|||
|
VkPresentInfoKHR present_info;
|
|||
|
|
|||
|
public:
|
|||
|
|
|||
|
const VkExtent2D & GetExtent ()const {return extent;}
|
|||
|
const uint32_t GetImageCount ()const {return sc_texture.GetCount();}
|
|||
|
|
|||
|
RenderPass * GetMainRenderPass () {return main_rp;}
|
|||
|
Framebuffer * GetFramebuffer (int index) {return render_frame[index];}
|
|||
|
const uint32_t GetCurrentFrameIndices () {return current_frame;}
|
|||
|
Framebuffer * GetCurrentFramebuffer () {return render_frame[current_frame];}
|
|||
|
|
|||
|
public:
|
|||
|
|
|||
|
Swapchain(Device *);
|
|||
|
virtual ~Swapchain();
|
|||
|
|
|||
|
void Clear ();
|
|||
|
|
|||
|
void Recreate ();
|
|||
|
|
|||
|
bool Wait (bool wait_all=VK_TRUE,uint64_t time_out=HGL_NANO_SEC_PER_SEC*0.1); ///<<3C>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
*/
|
|||
|
bool AcquireNextImage (VkSemaphore); ///<<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡<D2BB><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD>ύһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|||
|
* @param cmd_list <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|||
|
* @param wait_sems ָ<EFBFBD>ʼǰҪ<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϵ<EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
* @param complete_semaphores <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
*/
|
|||
|
bool SubmitDraw (List<VkCommandBuffer> &cmd_list,List<VkSemaphore> &wait_sems,List<VkSemaphore> &complete_semaphores); ///<<3C>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
|
|||
|
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<<3C>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
bool PresentBackbuffer (); ///<<3C>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ǰ̨
|
|||
|
};//class Swapchain
|
|||
|
VK_NAMESPACE_END
|
|||
|
#endif//HGL_GRAPH_VULKAN_SWAP_CHAIN_INCLUDE
|