yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
1.8 KiB63 linesraw
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:
20    SLANG_COM_OBJECT_IUNKNOWN_ALL
21    ISwapchain* getInterface(const Guid& guid);
22
23public:
24    VkSwapchainKHR m_swapChain;
25    VkSurfaceKHR m_surface;
26    VkSemaphore m_nextImageSemaphore; // Semaphore to signal after `acquireNextImage`.
27    ISwapchain::Desc m_desc;
28    VkFormat m_vkformat;
29    RefPtr<CommandQueueImpl> m_queue;
30    ShortList<RefPtr<TextureResourceImpl>> m_images;
31    RefPtr<DeviceImpl> m_renderer;
32    VulkanApi* m_api;
33    uint32_t m_currentImageIndex = 0;
34    WindowHandle m_windowHandle;
35#if SLANG_APPLE_FAMILY
36    void* m_metalLayer;
37#endif
38
39    void destroySwapchainAndImages();
40
41    void getWindowSize(int* widthOut, int* heightOut) const;
42
43    Result createSwapchainAndImages();
44
45public:
46    ~SwapchainImpl();
47
48    static Index _indexOfFormat(List<VkSurfaceFormatKHR>& formatsIn, VkFormat format);
49
50    Result init(DeviceImpl* renderer, const ISwapchain::Desc& desc, WindowHandle window);
51
52    virtual SLANG_NO_THROW const Desc& SLANG_MCALL getDesc() override { return m_desc; }
53    virtual SLANG_NO_THROW Result SLANG_MCALL
54    getImage(GfxIndex index, ITextureResource** outResource) override;
55    virtual SLANG_NO_THROW Result SLANG_MCALL resize(GfxCount width, GfxCount height) override;
56    virtual SLANG_NO_THROW Result SLANG_MCALL present() override;
57    virtual SLANG_NO_THROW int SLANG_MCALL acquireNextImage() override;
58    virtual SLANG_NO_THROW bool SLANG_MCALL isOccluded() override { return false; }
59    virtual SLANG_NO_THROW Result SLANG_MCALL setFullScreenMode(bool mode) override;
60};
61
62} // namespace vk
63} // namespace gfx