// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #if COMPILE_WITH_SHADER_COMPILER #include "ShaderCompiler.h" class Asset; /// /// Shaders compilation service allows to compile shader source code for a desire platform. Supports multi-threading. /// class FLAXENGINE_API ShadersCompilation { public: /// /// Compiles the shader. /// /// Compilation options /// True if failed, otherwise false static bool Compile(ShaderCompilationOptions& options); /// /// Registers shader asset for the automated reloads on source includes changes. /// The asset. /// The included file path. static void RegisterForShaderReloads(Asset* asset, const String& includedPath); /// /// Unregisters shader asset from the automated reloads on source includes changes. /// /// The asset. static void UnregisterForShaderReloads(Asset* asset); /// /// Reads the included shader files stored in the shader cache data. /// /// The shader cache data. /// The shader cache data length (in bytes). /// The output included. static void ExtractShaderIncludes(byte* shaderCache, int32 shaderCacheLength, Array& includes); // Resolves shader path name into absolute file path. Resolves './/ShaderFile.hlsl' cases into a full path. static String ResolveShaderPath(StringView path); // Compacts the full shader file path into portable format with project name prefix such as './/ShaderFile.hlsl'. static String CompactShaderPath(StringView path); private: static ShaderCompiler* CreateCompiler(ShaderProfile profile); static ShaderCompiler* RequestCompiler(ShaderProfile profile); static void FreeCompiler(ShaderCompiler* compiler); }; #endif