Compile a GLSL compute shader with NonSemantic debug info enabled, targeting Vulkan 1.1 / SPIR-V 1.3, and return the disassembly.
| 47 | // Compile a GLSL compute shader with NonSemantic debug info enabled, targeting |
| 48 | // Vulkan 1.1 / SPIR-V 1.3, and return the disassembly. |
| 49 | std::string compileWithDebugInfo(const std::string& source) |
| 50 | { |
| 51 | glslang::TShader shader(EShLangCompute); |
| 52 | const char* str = source.c_str(); |
| 53 | shader.setStrings(&str, 1); |
| 54 | shader.setEnvInput(glslang::EShSourceGlsl, EShLangCompute, |
| 55 | glslang::EShClientVulkan, 110); |
| 56 | shader.setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_1); |
| 57 | shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_3); |
| 58 | |
| 59 | EShMessages messages = static_cast<EShMessages>(EShMsgDefault | EShMsgDebugInfo); |
| 60 | if (!shader.parse(GetDefaultResources(), 450, false, messages)) |
| 61 | return "COMPILATION_FAILED: " + std::string(shader.getInfoLog()); |
| 62 | |
| 63 | glslang::TProgram program; |
| 64 | program.addShader(&shader); |
| 65 | if (!program.link(messages)) |
| 66 | return "LINKING_FAILED: " + std::string(program.getInfoLog()); |
| 67 | |
| 68 | glslang::SpvOptions opts; |
| 69 | opts.generateDebugInfo = true; |
| 70 | opts.emitNonSemanticShaderDebugInfo = true; |
| 71 | opts.disableOptimizer = true; |
| 72 | |
| 73 | std::vector<uint32_t> spirv; |
| 74 | glslang::GlslangToSpv(*program.getIntermediate(EShLangCompute), spirv, &opts); |
| 75 | |
| 76 | std::ostringstream out; |
| 77 | spv::Disassemble(out, spirv); |
| 78 | return out.str(); |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | // DebugTypeVectorIdEXT (opcode 109) must be emitted for OpTypeCooperativeVectorNV |
nothing calls this directly
no test coverage detected