vkCreateGraphicsPipeline segfault due to fragment shader

Hello guys,

I’m failing to create a graphics pipeline with segfault error. I’ve enabled the validation layers and after the fragment shader gets created, I get following message:

UNASSIGNED-CoreValidation-Shader-InconsistentSpirv(ERROR / SPEC): msgNum: 0 - SPIR-V module not valid: Invalid SPIR-V magic number. Objects: 1 [0] 0, type: 0, name: NULL

I’ve checked the frag.spv file with a hex editor and the sequence appears to be alright:

0302 2307 0000 0100 0700 0800 0D00 0000

I’ve tried to remove the fragment shader from the VkPipelineShaderStageCreateInfo (only vertex shader left) and the pipeline creation succeeded. So it appears the validation is right and the fragment shader is somehow wrong?

However, I’m stucked at how to proceed, as the shader appears to be alright (the magic number is ok). Any hints how to proceed debugging this issue?

Thank you very much,
Renegade

Just a thought… I don’t know about the validation layers, but generally in programming the error that is reported is not necessarily the actual error. I would make sure the shader source is correct. Maybe try a minimalistic fragment shader.

Well, the error is reported while the Fragment shader is created. If the fragment shader is part of the pipeline creation, the pipeline creation fails with segfault. (I’ve tried to remove the fragment shader from the pipeline creation process and this solved the issue) Apparently the issue is with the fragment shader, however, I have no clue what it can be.

The question is, whether the shader is somehow linked to other resources? Do I need to initialize the rest of all resources properly to use it or not? Can I provide an empty fragment shader to create the pipeline?

At the moment I’m only suspicious about fragment shader, however, I’ve no clue, whether the issue is in the shader or the stuff around it.

Hmm… you should check if you are reading the file correctly. Debug the program and make sure what you are reading is the same as what is in the file.

You could also check that you are using the right version of your compiled shaders and that the glslangvalidator version matches your SDK version (in case you have multiple installed).

If it isn’t any of that, then I can only point you to this site, where you can find what checks the core validation layer performs:
https://vulkan.lunarg.com/doc/view/1.1.70.0/windows/core_validation_layer.html

Oh, it’s interesting that the creation of the shaders succeeds, but the creation of the pipeline fails. The validation layers check the VS -> FS interface. Do all the relevant types in your shaders match?

I don’t see how the reported error would have anything to do with this, but from the behaviour you are describing, I would assume that only the combination of the two shaders is a problem, not the shaders individually.