libdonut  2.3.2
Application framework for cross-platform game development in C++20
ShaderStage.hpp
Go to the documentation of this file.
1 #ifndef DONUT_GRAPHICS_SHADER_STAGE_HPP
2 #define DONUT_GRAPHICS_SHADER_STAGE_HPP
3 
4 #include <donut/UniqueHandle.hpp>
6 
7 namespace donut::graphics {
8 
12 enum class ShaderStageType : unsigned {
13  VERTEX_SHADER = 0x8B31,
14  FRAGMENT_SHADER = 0x8B30,
15 };
16 
20 class ShaderStage {
21 public:
25  constexpr explicit ShaderStage() noexcept = default;
26 
41  explicit ShaderStage(ShaderStageType type, const char* definitions, const char* sourceCode);
42 
48  explicit operator bool() const noexcept {
49  return static_cast<bool>(shader);
50  }
51 
62  [[nodiscard]] Handle get() const noexcept {
63  return shader.get();
64  }
65 
66 private:
67  struct ShaderDeleter {
68  void operator()(Handle handle) const noexcept;
69  };
70 
72 };
73 
74 } // namespace donut::graphics
75 
76 #endif
constexpr Handle get() const noexcept
Get the value of the underlying resource handle.
Definition: UniqueHandle.hpp:152
Compiled GPU code for a specific stage of a ShaderProgram.
Definition: ShaderStage.hpp:20
constexpr ShaderStage() noexcept=default
Construct an empty shader stage without a value.
Handle get() const noexcept
Get an opaque handle to the GPU representation of the shader stage.
Definition: ShaderStage.hpp:62
Definition: Buffer.hpp:7
std::uint32_t Handle
Generic GPU resource handle.
Definition: Handle.hpp:11
ShaderStageType
Type of a ShaderStage in a ShaderProgram.
Definition: ShaderStage.hpp:12
@ FRAGMENT_SHADER
Fragment/pixel shader.