// SPDX-License-Identifier: Apache-2.0 #include "Utils.hpp" #include #include #include #include #include std::vector 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 buffer; buffer.insert( buffer.begin(), std::istreambuf_iterator(fileStream), {}); return { reinterpret_cast(buffer.data()), reinterpret_cast(buffer.data() + buffer.size()) }; }