2
3
4
5
9#include "Systems/ResourceSystem.h"
10#include "Core/Library/FileLibrary.h"
11#include "Resources/Shader/Shader.h"
12#include "Resources/Shader/ShaderCompiler.h"
13#include "Render/Vulkan/VulkanRenderBackend.h"
14#include "Render/Vulkan/VulkanShaderModule.h"
15#include "shaderc/shaderc.hpp"
20
21
30 for (
auto& it : ResourceSystem::GetSearchFolder())
32 filePath = it + defaultShaderPath +
"Shader." + fileName +
"." + ShaderHelper::ToString(stage);
33 if (FileLibrary::FileLibrary_Exists(filePath.c_str()))
42 ss <<
"Shader: " << fileName <<
"file is not found";
44 SPICES_CORE_WARN(ss.str());
50
51
52 std::ifstream stream(filePath);
53 std::stringstream strStream;
54 strStream << stream.rdbuf();
57
58
59 std::vector<uint8_t> spirv;
60 ShaderCompiler::CompileToSPV(strStream.str(), stage, fileName, spirv);
63
64
65 outShader->m_ShaderModule = std::make_shared<VulkanShaderModule>(VulkanRenderBackend::GetState(), fileName, stage, spirv, filePath);
#define SPICES_PROFILE_ZONE
static bool Load(const std::string &fileName, ShaderStage stage, Shader *outShader)
Public called API, it is entrance.
ShaderLoader Class. This class only defines static function for load data from shader file.
ShaderStage
enum of shader stage.
const std::string defaultShaderPath
Const variable: Original Shader File Path.