MCPcopy Create free account
hub / github.com/KomputeProject/kompute / compileSource

Function compileSource

test/shaders/Utils.cpp:10–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include <vector>
9
10std::vector<uint32_t>
11compileSource(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}

Callers 8

TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50

Calls 3

beginMethod · 0.80
sizeMethod · 0.80
dataMethod · 0.45

Tested by 8

TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40