// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_UBERSHADERPREPROCESSOR_HPP #define NAZARA_UBERSHADERPREPROCESSOR_HPP #include #include #include #include #include #include #include namespace Nz { class UberShaderInstance; class UberShaderPreprocessor; using UberShaderPreprocessorConstRef = ObjectRef; using UberShaderPreprocessorRef = ObjectRef; class NAZARA_RENDERER_API UberShaderPreprocessor : public UberShader { public: UberShaderPreprocessor() = default; ~UberShaderPreprocessor(); UberShaderInstance* Get(const ParameterList& parameters) const override; void SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags = String()); bool SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags = String()); static bool IsSupported(); template static UberShaderPreprocessorRef New(Args&&... args); // Signals: NazaraSignal(OnUberShaderPreprocessorRelease, const UberShaderPreprocessor* /*uberShaderPreprocessor*/); private: struct CachedShader { mutable std::unordered_map cache; std::unordered_map flags; UInt32 requiredFlags; String source; bool present = false; }; mutable std::unordered_map m_cache; std::unordered_map m_flags; CachedShader m_shaders[ShaderStageType_Max+1]; }; } #include #endif // NAZARA_UBERSHADERPREPROCESSOR_HPP