summaryrefslogtreecommitdiffstats
path: root/tools/gfx/vulkan/glslang-module.h
blob: 16fca5ce9e77a1382b9b0212ec4af51722d1b49b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// glslang-module.h
#pragma once

#include "core/slang-list.h"
#include "slang-com-helper.h"
#include "slang-com-ptr.h"
#include "slang-glslang/slang-glslang.h"
#include "slang.h"
#include "spirv-tools/include/spirv-tools/linker.hpp"

namespace gfx
{

struct GlslangModule
{
    /// true if has been initialized
    SLANG_FORCE_INLINE bool isInitialized() const { return m_module != nullptr; }

    /// Initialize
    Slang::Result init();

    /// Destroy
    void destroy();

    /// Dtor
    ~GlslangModule() { destroy(); }

    Slang::ComPtr<ISlangBlob> linkSPIRV(Slang::List<Slang::ComPtr<ISlangBlob>> spirvModules);

protected:
    void* m_module = nullptr;

    glslang_LinkSPIRVFunc m_linkSPIRVFunc = nullptr;
};

} // namespace gfx