yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
1.0 KiB56 linesraw
1// vk-module.h
2#pragma once
3
4#include "slang-com-helper.h"
5#include "slang.h"
6
7#if SLANG_WINDOWS_FAMILY
8#define VK_USE_PLATFORM_WIN32_KHR 1
9#elif SLANG_APPLE_FAMILY
10#define VK_USE_PLATFORM_METAL_EXT 1
11#else
12#if SLANG_ENABLE_XLIB
13#define VK_USE_PLATFORM_XLIB_KHR 1
14#endif
15#endif
16
17#define VK_NO_PROTOTYPES
18
19#include <vulkan/vulkan.h>
20
21// Undef xlib macros
22#ifdef Always
23#undef Always
24#endif
25#ifdef None
26#undef None
27#endif
28
29namespace gfx
30{
31
32struct VulkanModule
33{
34    /// true if has been initialized
35    SLANG_FORCE_INLINE bool isInitialized() const { return m_module != nullptr; }
36
37    /// Get a function by name
38    PFN_vkVoidFunction getFunction(const char* name) const;
39
40    /// true if using a software Vulkan implementation.
41    bool isSoftware() const { return m_isSoftware; }
42
43    /// Initialize
44    Slang::Result init(bool useSoftwareImpl);
45    /// Destroy
46    void destroy();
47
48    /// Dtor
49    ~VulkanModule() { destroy(); }
50
51protected:
52    void* m_module = nullptr;
53    bool m_isSoftware = false;
54};
55
56} // namespace gfx