I try to parse glsl code to spir-v code, but it doesn't work. I searched in forum but didn't find anything about it. If there is a post I didn't find pls send me a link.


Code :
std::vector<char> glslcode = Readfile("//shaderpath", std::iostream::in); //just a method to parse the textfile in the container.
UProgramPtr program(new glslang::TProgram()); 
glslang::TShader* shader = new glslang::TShader(EShLanguage::EShLangVertex); // I will post my example with vertex shader. 
const char* const string[] = {glslcode.data()};
 
shader->setStrings(string, 1); 
shader->setEnvInput(glslang::EShSource::EShSourceGlsl, EShLanguage::EShLangVertex, glslang::EShClient::EShClientVulkan, 110); 
shader->setEnvClient(glslang::EShClient::EShClientVulkan, glslang::EShTargetVulkan_1_1); //Tried every combination of EShTargetVulkan version and EShTargetSpv version
shader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_0); 
 
shader->parse(&glslang::DefaultTBuiltInResource, 110, false, EShMsgDefault); 
 
program->addShader(shader); 
program->link(EShMsgDefault); 
 
std::vector<uint32_t> spvCode; 
glslang::GlslangToSpv(*program->getIntermediate(EShLangVertex), spvCode); 
 
 
VkShaderModuleCreateInfo createInfo = {}; 
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; 
createInfo.codeSize = spvCode.size(); 
createInfo.pCode = spvCode.data(); 
 
std::array<VkShaderModuleCreateInfo, 1> createInfos = {createInfo};
VkShaderModule shaderModule; 
if(vkCreateShaderModule(logicalDevice, createInfos.data(), nullptr, &shaderModule) != VK_SUCCESS
{
throw std::runtime_error("failed to create shader module"); 
}

My error code is for the vertex shader:
"validation layer: Object: VK_NULL_HANDLE (Type = 0) | SPIR-V module not valid: End of input reached while decoding OpMemberDecorate starting at word 189: missing ID operand at word offset 1."

The error code for the fragment shader is different but I think it's just a parsing error. Does anybody know what I do wrong here? The glsl code is right because the glslangvalidator.exe parse it right into spv without an error message.