First pass for rewriting the build system
* Refactored all CMake files * Started working on compiling shaders to header files in CMake Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
parent
c6a2b022f9
commit
b95df8d0a0
33 changed files with 559 additions and 2712 deletions
28
test/shaders/Utils.cpp
Normal file
28
test/shaders/Utils.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "Utils.hpp"
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
std::vector<uint32_t>
|
||||
compileSource(const std::string& source)
|
||||
{
|
||||
std::ofstream fileOut("tmp_kp_shader.comp");
|
||||
fileOut << source;
|
||||
fileOut.close();
|
||||
if (system(
|
||||
std::string(
|
||||
"glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv")
|
||||
.c_str())) {
|
||||
throw std::runtime_error("Error running glslangValidator command");
|
||||
}
|
||||
std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary);
|
||||
std::vector<char> buffer;
|
||||
buffer.insert(
|
||||
buffer.begin(), std::istreambuf_iterator<char>(fileStream), {});
|
||||
return { reinterpret_cast<uint32_t*>(buffer.data()),
|
||||
reinterpret_cast<uint32_t*>(buffer.data() + buffer.size()) };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue