7 static bool glslangInitialized =
false;
8 if (!glslangInitialized)
10 glslang::InitializeProcess();
11 glslangInitialized =
true;
15 glslang::TShader shader(lang);
16 const char *shaderStrings[1] = {src.c_str()};
17 shader.setStrings(shaderStrings, 1);
19 shader.setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientVulkan,
VERSION);
20 shader.setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_3);
21 shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_6);
23 TBuiltInResource Resources = {};
24 Resources.maxLights = 32;
25 Resources.maxClipPlanes = 6;
26 Resources.maxTextureUnits = 32;
27 Resources.maxTextureCoords = 32;
28 Resources.maxVertexAttribs = 64;
29 Resources.maxVertexUniformComponents = 4096;
30 Resources.maxVaryingFloats = 64;
31 Resources.maxVertexTextureImageUnits = 32;
32 Resources.maxCombinedTextureImageUnits = 80;
33 Resources.maxTextureImageUnits = 32;
34 Resources.maxFragmentUniformComponents = 4096;
35 Resources.maxDrawBuffers = 32;
36 Resources.maxVertexUniformVectors = 128;
37 Resources.maxVaryingVectors = 8;
38 Resources.maxFragmentUniformVectors = 16;
39 Resources.maxVertexOutputVectors = 16;
40 Resources.maxFragmentInputVectors = 15;
41 Resources.minProgramTexelOffset = -8;
42 Resources.maxProgramTexelOffset = 7;
43 Resources.maxClipDistances = 8;
44 Resources.maxComputeWorkGroupCountX = 65535;
45 Resources.maxComputeWorkGroupCountY = 65535;
46 Resources.maxComputeWorkGroupCountZ = 65535;
47 Resources.maxComputeWorkGroupSizeX = 1024;
48 Resources.maxComputeWorkGroupSizeY = 1024;
49 Resources.maxComputeWorkGroupSizeZ = 64;
50 Resources.maxComputeUniformComponents = 1024;
51 Resources.maxComputeTextureImageUnits = 16;
52 Resources.maxComputeImageUniforms = 8;
53 Resources.maxComputeAtomicCounters = 8;
54 Resources.maxComputeAtomicCounterBuffers = 1;
55 Resources.maxVaryingComponents = 60;
56 Resources.maxVertexOutputComponents = 64;
57 Resources.maxGeometryInputComponents = 64;
58 Resources.maxGeometryOutputComponents = 128;
59 Resources.maxFragmentInputComponents = 128;
60 Resources.maxImageUnits = 8;
61 Resources.maxCombinedImageUnitsAndFragmentOutputs = 8;
62 Resources.maxCombinedShaderOutputResources = 8;
64 constexpr auto messages =
static_cast<EShMessages
>(EShMsgSpvRules | EShMsgVulkanRules);
66 if (!shader.parse(&Resources,
VERSION,
false, messages))
68 throw std::runtime_error(
"GLSL parsing failed: " + std::string(shader.getInfoLog()));
71 glslang::TProgram program;
72 program.addShader(&shader);
74 if (!program.link(messages))
76 throw std::runtime_error(
"GLSL linking failed: " + std::string(program.getInfoLog()));
79 std::vector<uint32_t> spirv;
80 glslang::GlslangToSpv(*program.getIntermediate(lang), spirv);