-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIShaderFrontend.hpp
More file actions
106 lines (90 loc) · 2.38 KB
/
IShaderFrontend.hpp
File metadata and controls
106 lines (90 loc) · 2.38 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
///
/// @file IShaderFrontend.hpp
/// @brief This file contains the ShaderFrontend interface
/// @namespace cae
///
#pragma once
#include "Utils/Interfaces/IPlugin.hpp"
#include <vector>
namespace cae
{
using ShaderID = std::string;
enum class ShaderSourceType : uint8_t
{
GLSL = 0,
HLSL = 1,
WGSL = 2,
MSL = 3,
SPIRV = 4,
DXIL = 5,
DXBC = 6,
UNDEFINED = 255
};
enum class ShaderStage : uint8_t
{
VERTEX = 0,
FRAGMENT = 1,
GEOMETRY = 2,
COMPUTE = 3,
UNDEFINED = 255
};
///
/// @struct ShaderSourceDesc
/// @brief Struct for shader source description
/// @namespace cae
///
struct ShaderSourceDesc
{
ShaderID id;
ShaderSourceType type;
std::string source;
ShaderStage stage;
};
///
/// @struct ShaderIRModule
/// @brief Struct for shader intermediate representation module
/// @namespace cae
///
struct ShaderIRModule
{
ShaderID id;
ShaderStage stage;
ShaderSourceType irType;
// std::vector<uint8_t> dxbc;
// std::vector<uint8_t> dxil;
std::vector<uint8_t> bytecode;
std::string entryPoint = "main";
};
///
/// @struct ShaderPipelineDesc
/// @brief Struct for shader pipeline description
/// @namespace cae
///
struct ShaderPipelineDesc
{
ShaderID id;
ShaderID vertex;
ShaderID fragment;
};
///
/// @interface IShaderFrontend
/// @brief Interface for shaders frontend
/// @namespace cae
///
class IShaderFrontend : public utl::IPlugin
{
public:
~IShaderFrontend() override = default;
///
/// @return The source type this frontend handles
/// @brief Get the source type this frontend handles
///
virtual ShaderSourceType sourceType() const = 0;
///
/// @param desc Shader source description
/// @return Compiled shader intermediate representation module
/// @brief Compile shader source to intermediate representation
///
virtual ShaderIRModule compile(const ShaderSourceDesc &desc) = 0;
}; // interface IShaderFrontend
} // namespace cae