34 template<
typename U>
friend struct std::hash;
82 template<
typename T> [[nodiscard]]
bool is() const noexcept;
85 template<> [[nodiscard]]
bool is<
String>() const noexcept {
return super::is<String>(); }
88 template<> [[nodiscard]]
bool is<StringView>() const noexcept {
return super::is<String>(); }
91 template<> [[nodiscard]]
bool is<bool>() const noexcept {
return super::is<bool>(); }
94 template<> [[nodiscard]]
bool is<UInt8>() const noexcept {
return isConvertibleAs<UInt8>(); }
97 template<> [[nodiscard]]
bool is<UInt16>() const noexcept {
return isConvertibleAs<UInt16>(); }
100 template<> [[nodiscard]]
bool is<UInt32>() const noexcept {
return isConvertibleAs<UInt32>(); }
103 template<> [[nodiscard]]
bool is<Int8>() const noexcept {
return isConvertibleAs<Int8>(); }
106 template<> [[nodiscard]]
bool is<Int16>() const noexcept {
return isConvertibleAs<Int16>(); }
109 template<> [[nodiscard]]
bool is<Int32>() const noexcept {
return isConvertibleAs<Int32>(); }
112 template<> [[nodiscard]]
bool is<Int64>() const noexcept {
return isConvertibleAs<Int64>(); }
118 template<
typename T>
decltype(
auto)
as()
const;
121 template<> [[nodiscard]]
decltype(
auto) as<String>()
const {
return super::as<String>(); }
124 template<> [[nodiscard]]
decltype(
auto) as<StringView>()
const {
return StringView(super::as<String>()); }
127 template<> [[nodiscard]]
decltype(
auto) as<bool>()
const {
return super::as<bool>(); }
130 template<> [[nodiscard]]
decltype(
auto) as<UInt8>()
const {
return convertAs<UInt8>(); }
133 template<> [[nodiscard]]
decltype(
auto) as<UInt16>()
const {
return convertAs<UInt16>(); }
136 template<> [[nodiscard]]
decltype(
auto) as<UInt32>()
const {
return convertAs<UInt32>(); }
139 template<> [[nodiscard]]
decltype(
auto) as<Int8>()
const {
return convertAs<Int8>(); }
142 template<> [[nodiscard]]
decltype(
auto) as<Int16>()
const {
return convertAs<Int16>(); }
145 template<> [[nodiscard]]
decltype(
auto) as<Int32>()
const {
return convertAs<Int32>(); }
148 template<> [[nodiscard]]
decltype(
auto) as<Int64>()
const {
return convertAs<Int64>(); }
155 if(!super::is<Int64>()) {
159 const Int64 value = super::as<Int64>();
160 return value >= std::numeric_limits<T>::min() && value <= std::numeric_limits<T>::max();
164 template<
typename T> [[nodiscard]]
T convertAs() const noexcept {
165 const Int64 value = super::as<Int64>();
166 CE_ASSERT(value >= std::numeric_limits<T>::min() && value <= std::numeric_limits<T>::max());
321template<>
struct std::hash<
CeresEngine::ShaderSpecializationConstant> {
323 inline size_t operator()(
const Type&
object)
const noexcept {
return CeresEngine::hash(
static_cast<const Type::super&
>(
object)); }
#define CE_ASSERT(...)
Definition Macros.hpp:323
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
#define CE_META_CLASS_FRIEND(T)
Definition Forward.hpp:48
A shader that must be compiled as a "CeresEngine Shading Language".
Definition Shader.hpp:259
ShadingLanguage getShadingLanguage() const noexcept final
Specifies the shading language of the shader resource.
Definition Shader.hpp:267
Optional< ShaderBinary > compile(ShaderType type, const ShaderSpecializationConstants &specializationConstants={}) const final
Compiles the shader into a binary that can be loaded by the render API.
A shader that must be compiled as a "GLSL Shading Language".
Definition Shader.hpp:289
ShadingLanguage getShadingLanguage() const noexcept final
Specifies the shading language of the shader resource.
Definition Shader.hpp:297
Optional< ShaderBinary > compile(ShaderType type, const ShaderSpecializationConstants &specializationConstants={}) const final
Compiles the shader into a binary that can be loaded by the render API.
A shader that must be compiled as a "HLSL Shading Language".
Definition Shader.hpp:274
Optional< ShaderBinary > compile(ShaderType type, const ShaderSpecializationConstants &specializationConstants={}) const final
Compiles the shader into a binary that can be loaded by the render API.
ShadingLanguage getShadingLanguage() const noexcept final
Specifies the shading language of the shader resource.
Definition Shader.hpp:282
Definition Optional.hpp:17
A shader that is already compiled in the SPIR-V format.
Definition Shader.hpp:304
Optional< ShaderBinary > compile(ShaderType type, const ShaderSpecializationConstants &specializationConstants={}) const final
Compiles the shader into a binary that can be loaded by the render API.
ShadingLanguage getShadingLanguage() const noexcept final
Specifies the shading language of the shader resource.
Definition Shader.hpp:312
A ShaderBinary is an object responsible for wrapping the binary representation of a shader (i....
Definition ShaderSource.hpp:40
A resource that represents a shader that can be compiled and loaded into the runtime.
Definition Shader.hpp:192
String getSourceName() const
Gets the shader source name.
Shader(const ShaderSource &source, const ShaderStages &stage)
void setSource(const ShaderSource &source)
The shader source to compile the final shader to.
virtual Optional< ShaderBinary > compile(ShaderType type, const ShaderSpecializationConstants &specializationConstants={}) const =0
Compiles the shader into a binary that can be loaded by the render API.
virtual ShadingLanguage getShadingLanguage() const noexcept=0
Specifies the shading language of the shader resource.
~Shader() noexcept override=default
ShaderStages mStages
A set of stages supported by the shader.
Definition Shader.hpp:197
ShaderSource mSource
The shader source to compile the final shader to.
Definition Shader.hpp:200
Optional< ShaderBinary > compileShaderInternal(const ShaderSource &sourceCode, ShadingLanguage language, const URI &includeSearchPath) const
Internal method to compile the given shaderSource using the ShaderC compiler.
const ShaderSource & getSource() const noexcept
The shader source to compile the final shader to.
Definition Shader.hpp:209
ShaderSource preProcessShader(const ShaderSource &sourceCode, const ShaderSpecializationConstants &specializationConstants, const URI &includeSearchPath) const
Runs the shader pre-processor on the shader.
Async< Optional< ShaderBinary > > compileAsync(ShaderType type, ShaderSpecializationConstants specializationConstants={})
Asynchronously compiles the shader into a binary that can be loaded by the render API.
A ShaderSource is an object responsible for wrapping the textual representation of a shader (i....
Definition ShaderSource.hpp:112
A variant type that describes a value that can be used as a shader specialization constant.
Definition Shader.hpp:32
ShaderSpecializationConstant & operator=(ShaderSpecializationConstant &&)=default
bool isConvertibleAs() const noexcept
Checks if the value is numeric is a type and convertible to T.
Definition Shader.hpp:154
T convertAs() const noexcept
Converts a numeric type to T.
Definition Shader.hpp:164
decltype(auto) as() const
Gets the shader specialization constant value as type T.
ShaderSpecializationConstant()
Cretaes a new specialization constant with a default value of 0.
Definition Shader.hpp:39
ShaderSpecializationConstant & operator=(const ShaderSpecializationConstant &)=default
ShaderSpecializationConstant(const ShaderSpecializationConstant &)=default
bool is() const noexcept
Checks if the shader specialization constant holds a given type T.
ShaderSpecializationConstant(ShaderSpecializationConstant &&)=default
Utility template class that can be extended by Resources to automatically implement methods that are ...
Definition Resource.hpp:272
A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or p...
Definition URI.hpp:54
Definition Variant.hpp:15
constexpr decltype(auto) visit(Visitor &&visitor) &
Definition Variant.hpp:37
Definition Application.hpp:19
sfl::small_unordered_flat_map< Key, T, N, KeyEqual, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallUnorderedFlatMap
SmallUnorderedFlatMap is an unordered associative container similar to HashMap.
Definition SmallFlatMap.hpp:69
BasicStringView< char > StringView
Narrow string view used for handling narrow encoded text in UTF-8.
Definition String.hpp:190
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
std::int32_t Int32
Definition DataTypes.hpp:21
std::uint16_t UInt16
Definition DataTypes.hpp:20
std::uint8_t UInt8
Definition DataTypes.hpp:17
std::int64_t Int64
Definition DataTypes.hpp:24
std::uint32_t UInt32
Definition DataTypes.hpp:23
SmallUnorderedFlatMap< String, ShaderSpecializationConstant, 5 > ShaderSpecializationConstants
A map type that represents a map of shader specialization constants.
Definition Shader.hpp:172
ShadingLanguage
Enumeration that indicates the supported shading languages.
Definition Shader.hpp:175
@ CESL
Specifies that the shader is using the CeresEngine Shading Language, an extension to HLSL with CeresE...
@ GLSL
Specifies that the shader is using the GLSL Shading Language.
@ SPIRV
Specifies that the shader compiled with SPIR-V.
@ HLSL
Specifies that the shader is using the HLSL Shading Language.
std::int8_t Int8
Definition DataTypes.hpp:15
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
std::int16_t Int16
Definition DataTypes.hpp:18
Shader type enumeration.
Definition ShaderType.hpp:59
@ Undefined
Undefined shader type.
Definition ShaderType.hpp:62