title: SPIR-V module not valid: Codesize must be a multiple of 4 but is 191
body: <p>I've been getting this error trying to compile my glsl shaders to spirv at runtime. At this point I'm completely stumped, I have no clue what's causing the error and can't find anything online.</p>
  
  <p>The error only happens with my vertex shader, my fragment shader compiles with no issues (though they both 'compile' fine, error is happens when creating the vulkan module not with shaderc compilation). Also, when I compile from the command line and just read those already compiled files the shader modules are created with no issue.</p>
  
  <p>Here is my vertex shader:</p>
  
  <pre><code># version 450
  # extension GL_ARB_separate_shader_objects : enable
  
  layout(location = 0) in vec2 aPos;
  layout(location = 1) in vec3 aColor;
  
  layout(location = 0) out vec3 fragColor; 
  
  void main()
  {
      gl_Position = vec4(aPos, 1.0, 1.0);
      fragColor = aColor;
  }
  </code></pre>
  
  <p>And here is the code I'm using to read and compile the .vert file</p>
  
  <pre><code>std::vector&lt;char&gt; readFile(const std::string&amp; filename)
  {
      std::ifstream file(filename, std::ios::ate | std::ios::binary);
  
      if (!file.is_open())
      {
          throw std::runtime_error("failed to open file!");
      }
  
      size_t fileSize = (size_t) file.tellg();
      std::vector&lt;char&gt; buffer(fileSize);
  
      file.seekg(0);
      file.read(buffer.data(), fileSize);
  
      file.close();
  
      return buffer; 
  }
  
  std::vector&lt;uint32_t&gt; compileToSPIRV(const char* sPath, const shaderc_shader_kind kind)
  {
      auto shaderVect = readFile(sPath);
      std::string shaderText(shaderVect.begin(), shaderVect.end());
  
      shaderc::Compiler compiler;
      shaderc::CompileOptions options;
  
      options.AddMacroDefinition("MY_DEFINE", "1");
      options.SetOptimizationLevel(shaderc_optimization_level_size);
  
      auto assembly = compiler.CompileGlslToSpvAssembly(shaderText, kind, sPath, options);
      std::string ass(assembly.cbegin(), assembly.cend());
      auto compile = compiler.AssembleToSpv(ass.c_str(), ass.size());
      std::vector&lt;uint32_t&gt; comp(compile.cbegin(), compile.cend());
      return comp;
  }
  </code></pre>
  
  <p>Thanks for any help. Please let me know if there's any other code you want me to include. </p>
  
  <p>Edit: creating the shader module:</p>
  
  <pre><code>VkShaderModule createShaderModule(const std::vector&lt;uint32_t&gt;&amp; code)
      {
          VkShaderModuleCreateInfo moduleInfo = {};
          moduleInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
          moduleInfo.codeSize = code.size();
          moduleInfo.pCode = code.data();
  
          VkShaderModule shaderModule;
          if (vkCreateShaderModule(device, &amp;moduleInfo, nullptr, &amp;shaderModule) != VK_SUCCESS)
          {
              throw std::runtime_error("Failed to create shader module");
          }
  
          return shaderModule;
      }
  </code></pre>