yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// vk-swap-chain.h 2#pragma once 3 4#include "vk-base.h" 5#include "vk-command-queue.h" 6#include "vk-device.h" 7#include "vk-texture.h" 8 9namespace gfx 10{ 11 12using namespace Slang ; 13 14namespace vk 15{ 16 17class SwapchainImpl :public ISwapchain ,public ComObject 18{ 19public : 20SLANG_COM_OBJECT_IUNKNOWN_ALL 21ISwapchain * getInterface (const Guid & guid ); 22 23public : 24VkSwapchainKHR m_swapChain ; 25VkSurfaceKHR m_surface ; 26VkSemaphore m_nextImageSemaphore ;// Semaphore to signal after `acquireNextImage`. 27ISwapchain ::Desc m_desc ; 28VkFormat m_vkformat ; 29RefPtr < CommandQueueImpl > m_queue ; 30ShortList < RefPtr < TextureResourceImpl >>m_images ; 31RefPtr < DeviceImpl > m_renderer ; 32VulkanApi * m_api ; 33uint32_t m_currentImageIndex = 0 ; 34WindowHandle m_windowHandle ; 35#if SLANG_APPLE_FAMILY 36void * m_metalLayer ; 37#endif 38 39void destroySwapchainAndImages (); 40 41void getWindowSize (int * widthOut ,int * heightOut )const ; 42 43Result createSwapchainAndImages (); 44 45public : 46 ~SwapchainImpl (); 47 48static Index _indexOfFormat (List < VkSurfaceFormatKHR >& formatsIn ,VkFormat format ); 49 50Result init (DeviceImpl * renderer ,const ISwapchain ::Desc & desc ,WindowHandle window ); 51 52virtual SLANG_NO_THROW const Desc & SLANG_MCALL getDesc ()override {return m_desc ; } 53virtual SLANG_NO_THROW Result SLANG_MCALL 54getImage (GfxIndex index ,ITextureResource ** outResource )override ; 55virtual SLANG_NO_THROW Result SLANG_MCALL resize (GfxCount width ,GfxCount height )override ; 56virtual SLANG_NO_THROW Result SLANG_MCALL present ()override ; 57virtual SLANG_NO_THROW int SLANG_MCALL acquireNextImage () override; 58virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded () override { return false; } 59virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode ( bool mode) override; 60}; 61 62} // namespace vk 63} // namespace gfx