Refactor tracing
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "copium/util/FileSystem.h"
|
||||
#include "copium/core/Vulkan.h"
|
||||
#include "copium/util/RuntimeException.h"
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Copium
|
||||
fragShaderModule = InitializeShaderModule(FileSystem::ReadFile(fragmentInput));
|
||||
break;
|
||||
default:
|
||||
CP_ASSERT(false, "Shader : Unreachable switch case %d", (int)type);
|
||||
CP_ASSERT(false, "Unreachable switch case %d", (int)type);
|
||||
}
|
||||
|
||||
shaderStages.resize(2);
|
||||
@@ -78,17 +79,17 @@ namespace Copium
|
||||
{
|
||||
if (FileSystem::DateModified(filename) < FileSystem::DateModified(spvFilename))
|
||||
{
|
||||
CP_DEBUG("InitializeShaderModuleFromGlslFile : Loading cached shader file: %s", filename.c_str());
|
||||
CP_DEBUG("Loading cached shader file: %s", filename.c_str());
|
||||
std::vector<uint32_t> data = FileSystem::ReadFile32(spvFilename);
|
||||
return InitializeShaderModule(data.data(), data.size() * sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
catch (const RuntimeException& e)
|
||||
{
|
||||
CP_WARN("InitializeShaderModuleFromGlslFile : Cached shader file is invalid, recreating it");
|
||||
CP_WARN("Cached shader file is invalid, recreating it");
|
||||
}
|
||||
CP_DEBUG("InitializeShaderModuleFromGlslFile : Compiling shader file: %s", filename.c_str());
|
||||
CP_DEBUG("Compiling shader file: %s", filename.c_str());
|
||||
shaderc::Compiler compiler;
|
||||
shaderc::CompileOptions options;
|
||||
|
||||
@@ -96,7 +97,7 @@ namespace Copium
|
||||
|
||||
std::vector<char> glslCode = FileSystem::ReadFile(filename);
|
||||
shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(glslCode.data(), glslCode.size(), type, filename.c_str(), options);
|
||||
CP_ASSERT(result.GetCompilationStatus() == shaderc_compilation_status_success, "InitializeShaderModuleFromGlslFile : Failed to compile shader: %s\n%s", filename.c_str(), result.GetErrorMessage().c_str());
|
||||
CP_ASSERT(result.GetCompilationStatus() == shaderc_compilation_status_success, "Failed to compile shader: %s\n%s", filename.c_str(), result.GetErrorMessage().c_str());
|
||||
|
||||
std::vector<uint32_t> data{result.cbegin(), result.cend()};
|
||||
FileSystem::WriteFile(spvFilename, (const char*)data.data(), data.size() * sizeof(uint32_t));
|
||||
@@ -111,7 +112,7 @@ namespace Copium
|
||||
options.SetOptimizationLevel(shaderc_optimization_level_size);
|
||||
|
||||
shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(code.data(), type, "inline_shader_code", options);
|
||||
CP_ASSERT(result.GetCompilationStatus() == shaderc_compilation_status_success, "InitializeShaderModuleFromGlslCode : Failed to compile inline shader code: %s", result.GetErrorMessage());
|
||||
CP_ASSERT(result.GetCompilationStatus() == shaderc_compilation_status_success, "Failed to compile inline shader code: %s", result.GetErrorMessage());
|
||||
|
||||
std::vector<uint32_t> data{result.cbegin(), result.cend()};
|
||||
return InitializeShaderModule(data.data(), data.size() * sizeof(uint32_t));
|
||||
@@ -125,7 +126,7 @@ namespace Copium
|
||||
createInfo.pCode = data;
|
||||
|
||||
VkShaderModule shaderModule;
|
||||
CP_VK_ASSERT(vkCreateShaderModule(Vulkan::GetDevice(), &createInfo, nullptr, &shaderModule), "InitializeShaderModule : Failed to initialize shader module");
|
||||
CP_VK_ASSERT(vkCreateShaderModule(Vulkan::GetDevice(), &createInfo, nullptr, &shaderModule), "Failed to initialize shader module");
|
||||
|
||||
return shaderModule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user