7 #include <shared_mutex>
8 #include <unordered_map>
28 [[nodiscard]] virtual
bool isShader(const
std::
string& shaderName)
36 const
std::
string& shaderName) const noexcept;
44 std::shared_ptr<
Shader>&& shader) noexcept;
54 std::shared_ptr<
Shader>&& shader, const
std::
string& shaderName) noexcept;
63 std::shared_ptr<
Shader>&& shader) noexcept;
74 std::shared_ptr<
Shader>&& shader, const
std::
string& shaderName) noexcept;
82 std::shared_ptr<T>
get(const
std::
string& shaderName) noexcept {
84 if (!shader || shader->typeName() != T::Name) {
87 return std::static_pointer_cast<T>(shader);
95 typename std::enable_if_t<is_shader_v<T>,
bool>* =
nullptr>
96 std::shared_ptr<T>
get() noexcept {
98 if (!shader || shader->typeName() != T::Name) {
101 return std::static_pointer_cast<T>(shader);
111 typename std::enable_if_t<is_shader_v<T>,
bool>* =
nullptr>
118 if (!shader || shader->typeName() != T::Name) {
121 to = std::static_pointer_cast<T>(shader);
132 typename std::enable_if_t<is_shader_v<T>,
bool>* =
nullptr>
139 if (!shader || shader->typeName() != T::Name) {
142 to = std::static_pointer_cast<T>(shader);
149 std::shared_ptr<gfx::Shader>
151 mutable std::shared_mutex programLock;
A ShaderRegistry contains a collection of gfx::Shader instances. Using the registry,...
ShaderRegistry(ShaderRegistry &&) noexcept=delete
virtual bool isShader(const std::string &shaderName) const noexcept
Checks if a shader exists in the registry for the given name.
virtual bool registerShader(std::shared_ptr< Shader > &&shader) noexcept
Register a new shader with the registry. If a shader is present in the registry with a conflicting na...
bool populate(std::shared_ptr< T > &to, const std::string &shaderName) noexcept
Ensure the destination 'to' is populated with the requested shader. If already non-null,...
std::shared_ptr< T > get() noexcept
Shorthand helper to quickly get a derived type from the registry. This variant looks up shaders only ...
bool populate(std::shared_ptr< T > &to) noexcept
Ensure the destination 'to' is populated with the requested shader. If already non-null,...
ShaderRegistry(const ShaderRegistry &)=delete
virtual bool replaceShader(std::shared_ptr< Shader > &&shader) noexcept
Replace a matching shader in the registry with the provided instance. Shader type-names must match.
virtual const std::shared_ptr< gfx::Shader > getShader(const std::string &shaderName) const noexcept
Get a shader from the registry by name.
A shader is used as the base class for all programs across any supported backend API....
constexpr bool is_shader_v
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)