yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// metal-swap-chain.h 2#pragma once 3 4#include "metal-base.h" 5#include "metal-command-queue.h" 6#include "metal-device.h" 7#include "metal-texture.h" 8 9namespace gfx 10{ 11 12using namespace Slang ; 13 14namespace metal 15{ 16 17class SwapchainImpl :public ISwapchain ,public ComObject 18{ 19public : 20SLANG_COM_OBJECT_IUNKNOWN_ALL 21ISwapchain * getInterface (const Guid & guid ); 22 23public : 24RefPtr < DeviceImpl > m_device ; 25ISwapchain ::Desc m_desc ; 26WindowHandle m_windowHandle ; 27CA ::MetalLayer * m_metalLayer = nullptr ; 28ShortList < RefPtr < TextureResourceImpl >>m_images ; 29NS ::SharedPtr < CA ::MetalDrawable > m_currentDrawable ; 30Index m_currentImageIndex = -1 ; 31MTL ::PixelFormat m_metalFormat = MTL ::PixelFormat ::PixelFormatInvalid ; 32 33void getWindowSize (int & widthOut ,int & heightOut )const ; 34void createImages (); 35 36public : 37 ~SwapchainImpl (); 38 39Result init (DeviceImpl * device ,const ISwapchain ::Desc & desc ,WindowHandle window ); 40 41virtual SLANG_NO_THROW const Desc & SLANG_MCALL getDesc ()override {return m_desc ; } 42virtual SLANG_NO_THROW Result SLANG_MCALL 43getImage (GfxIndex index ,ITextureResource ** outResource )override ; 44virtual SLANG_NO_THROW Result SLANG_MCALL resize (GfxCount width ,GfxCount height )override ; 45virtual SLANG_NO_THROW Result SLANG_MCALL present ()override ; 46virtual SLANG_NO_THROW int SLANG_MCALL acquireNextImage () override; 47virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded () override { return false; } 48virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode ( bool mode) override; 49}; 50 51} // namespace metal 52} // namespace gfx