| 8 | #include <vector> |
| 9 | |
| 10 | std::vector<uint32_t> |
| 11 | compileSource(const std::string& source) |
| 12 | { |
| 13 | std::ofstream fileOut("tmp_kp_shader.comp"); |
| 14 | fileOut << source; |
| 15 | fileOut.close(); |
| 16 | if (system( |
| 17 | std::string( |
| 18 | "glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv") |
| 19 | .c_str())) { |
| 20 | throw std::runtime_error("Error running glslangValidator command"); |
| 21 | } |
| 22 | std::ifstream fileStream("tmp_kp_shader.comp.spv", std::ios::binary); |
| 23 | std::vector<char> buffer; |
| 24 | buffer.insert( |
| 25 | buffer.begin(), std::istreambuf_iterator<char>(fileStream), {}); |
| 26 | return { reinterpret_cast<uint32_t*>(buffer.data()), |
| 27 | reinterpret_cast<uint32_t*>(buffer.data() + buffer.size()) }; |
| 28 | } |