cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
SPIRV.hpp
Go to the documentation of this file.
1///
2/// @file SPIRV.hpp
3/// @brief This file contains the SpirvIR class declaration
4/// @namespace cae
5///
6
7#pragma once
8
10
11namespace cae
12{
13
14 ///
15 /// @class SPIRV
16 /// @brief Class for the SPIR-V IR plugin
17 /// @namespace cae
18 ///
19 class SPIRV final : public AShaderIR
20 {
21 public:
22 SPIRV() = default;
23 ~SPIRV() override = default;
24
25 SPIRV(const SPIRV &) = delete;
26 SPIRV &operator=(const SPIRV &) = delete;
27 SPIRV(SPIRV &&) = delete;
28 SPIRV &operator=(SPIRV &&) = delete;
29
30 [[nodiscard]] std::string getName() const override { return "SPIRV"; }
31 [[nodiscard]] utl::PluginType getType() const override { return utl::PluginType::SHADER_IR; }
32 [[nodiscard]] utl::PluginPlatform getPlatform() const override { return utl::PluginPlatform::ALL; }
33
34 [[nodiscard]] ShaderSourceType irType() const override { return ShaderSourceType::SPIRV; }
35
36 ShaderIRModule process(const ShaderIRModule &module) override
37 {
38 ShaderIRModule out = module;
39 return out;
40 }
41
42 void optimize(std::span<ShaderIRModule> modules) override {}
43
44 ShaderIRModule crossCompile(const ShaderIRModule &module, const ShaderSourceType targetType) override
45 {
46 if (targetType == ShaderSourceType::MSL)
47 {
48 ShaderIRModule out = module;
49 return out;
50 }
51
52 throw std::runtime_error("Cross-compilation to this target not implemented");
53 }
54
55 }; // class SPIRV
56
57} // namespace cae
This file contains the ShaderIR abstract class.
Abstract class for shader IR.
Definition AShaderIR.hpp:20
Class for the SPIR-V IR plugin.
Definition SPIRV.hpp:20
SPIRV & operator=(const SPIRV &)=delete
SPIRV(SPIRV &&)=delete
ShaderIRModule crossCompile(const ShaderIRModule &module, const ShaderSourceType targetType) override
Optional: cross-compile from one IR to another (SPIR-V -> MSL, etc.)
Definition SPIRV.hpp:44
utl::PluginPlatform getPlatform() const override
Get the handled platform of the plugin.
Definition SPIRV.hpp:32
SPIRV & operator=(SPIRV &&)=delete
std::string getName() const override
Get the name of the plugin.
Definition SPIRV.hpp:30
ShaderSourceType irType() const override
Get the IR type this processor handles.
Definition SPIRV.hpp:34
SPIRV()=default
~SPIRV() override=default
utl::PluginType getType() const override
Get the type of the plugin.
Definition SPIRV.hpp:31
void optimize(std::span< ShaderIRModule > modules) override
Optional: optimize a batch of IR modules.
Definition SPIRV.hpp:42
SPIRV(const SPIRV &)=delete
ShaderIRModule process(const ShaderIRModule &module) override
Transform or validate a shader IR module.
Definition SPIRV.hpp:36
PluginPlatform
Definition IPlugin.hpp:33
PluginType
Definition IPlugin.hpp:22
Struct for shader intermediate representation module.