// Copyright (c) 2012-2023 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);
private:
static ShaderCompiler* CreateCompiler(ShaderProfile profile);
static ShaderCompiler* RequestCompiler(ShaderProfile profile);
static void FreeCompiler(ShaderCompiler* compiler);
};
#endif