review fix done

This commit is contained in:
Metehan Tuncbilek
2024-07-16 22:13:44 +03:00
parent dbd7b2dad5
commit 7ea6fc8dc4
2 changed files with 11 additions and 10 deletions

View File

@@ -1,13 +1,16 @@
#if defined(HAS_SHADERC)
#include "ShaderCompiler.hpp"
#include "Base/Logger.hpp"
#include <shaderc/shaderc.hpp>
#include <map>
#include <filesystem>
namespace OpenVulkano
{
#if defined(HAS_SHADERC)
class ShaderIncluder : public shaderc::CompileOptions::IncluderInterface
{
struct IncludeData
@@ -34,7 +37,7 @@ namespace OpenVulkano
shaderc_shader_kind CheckStage(const std::string& extensionName)
{
std::map<std::string, shaderc_shader_kind> stageMap = {
static std::map<std::string, shaderc_shader_kind> stageMap = {
{ "vert", shaderc_glsl_vertex_shader }, { "frag", shaderc_glsl_fragment_shader },
{ "comp", shaderc_glsl_compute_shader }, { "geom", shaderc_glsl_geometry_shader },
{ "tesc", shaderc_glsl_tess_control_shader }, { "tese", shaderc_glsl_tess_evaluation_shader },
@@ -50,7 +53,7 @@ namespace OpenVulkano
}
Array<uint32_t> ShaderCompiler::CompileGLSLToSpirv(const std::string& absPath, bool hasIncludes,
const std::string& incPath, const std::string& entryPoint)
const std::string& incPath, const std::string& entryPoint)
{
Array<char> file = Utils::ReadFile(absPath, false, true);
@@ -66,11 +69,11 @@ namespace OpenVulkano
shaderc::PreprocessedSourceCompilationResult preResult =
shaderCompiler.PreprocessGlsl(file.Data(), CheckStage(extensionSplit.second), entryPoint.c_str(), options);
#if defined(_DEBUG)
#if defined(_DEBUG)
std::string test = static_cast<const char*>(preResult.begin(), preResult.end());
// printf("Preprocessed shader: %s\n\n\n", test.c_str()); // Works fine
// Logger::APP->info("Preprocessed shader: {0}", test); gives error
#endif
// printf("Preprocessed shader: %s\n\n\n", test.c_str()); // Works fine
// Logger::APP->info("Preprocessed shader: {0}", test); gives error
#endif
if (preResult.GetCompilationStatus() != shaderc_compilation_status_success)
{
@@ -124,5 +127,5 @@ namespace OpenVulkano
if (std::filesystem::exists(path)) return path;
else throw std::runtime_error("Failed to resolve include '" + requestedSource + "'!");
}
#endif
}
#endif

View File

@@ -3,8 +3,6 @@
#include "Base/Utils.hpp"
#include "Base/Wrapper.hpp"
#include <shaderc/shaderc.hpp>
namespace OpenVulkano
{
class ShaderCompiler