Updated to working test utils
This commit is contained in:
parent
075b94dcda
commit
04dc372780
1 changed files with 18 additions and 14 deletions
|
|
@ -5,23 +5,27 @@
|
|||
#include <shaderc/shaderc.hpp>
|
||||
|
||||
static std::vector<char> spirv_from_string(const std::string& source,
|
||||
shaderc_optimization_level optimization = shaderc_optimization_level_size,
|
||||
shaderc_optimization_level optimization = shaderc_optimization_level_zero,
|
||||
std::vector<std::pair<std::string,std::string>> definitions = {}) {
|
||||
shaderc::Compiler compiler;
|
||||
shaderc::CompileOptions options;
|
||||
shaderc::Compiler compiler;
|
||||
shaderc::CompileOptions options;
|
||||
|
||||
for (const std::pair<std::string,std::string>& def : definitions) {
|
||||
options.AddMacroDefinition(def.first, def.second);
|
||||
}
|
||||
if (optimization) options.SetOptimizationLevel(optimization);
|
||||
for (const std::pair<std::string,std::string>& def : definitions) {
|
||||
options.AddMacroDefinition(def.first, def.second);
|
||||
}
|
||||
if (optimization) options.SetOptimizationLevel(optimization);
|
||||
|
||||
std::string errorTag = "kompute";
|
||||
shaderc::SpvCompilationResult module =
|
||||
compiler.CompileGlslToSpv(source, shaderc_glsl_compute_shader, errorTag.c_str(), options);
|
||||
std::string errorTag = "kompute";
|
||||
shaderc::SpvCompilationResult module =
|
||||
compiler.CompileGlslToSpv(source, shaderc_glsl_compute_shader, errorTag.c_str(), options);
|
||||
|
||||
if (module.GetCompilationStatus() != shaderc_compilation_status_success) {
|
||||
throw std::runtime_error("Shader string invalid: " + module.GetErrorMessage());
|
||||
}
|
||||
if (module.GetCompilationStatus() != shaderc_compilation_status_success) {
|
||||
throw std::runtime_error("Shader string invalid: " + module.GetErrorMessage());
|
||||
}
|
||||
|
||||
return {module.cbegin(), module.cend()};
|
||||
std::vector<uint32_t> vi = {module.cbegin(), module.cend()};
|
||||
auto p = reinterpret_cast<char*>(vi.data());
|
||||
std::vector<char> vc{p, p + vi.size() * sizeof(int)};
|
||||
|
||||
return vc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue