Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shader error in Builder #1358

Closed
rolandhill opened this issue Jan 8, 2025 · 7 comments
Closed

Shader error in Builder #1358

rolandhill opened this issue Jan 8, 2025 · 7 comments

Comments

@rolandhill
Copy link
Contributor

Hi Robert,

Running examples that call Builder functions results in shader error messages. I'm using the latest VSG libraries pulled today on Kubuntu 24.04 with Nvidia 3070Ti.

VUID-VkShaderModuleCreateInfo-pCode-08737(ERROR / SPEC): msgNum: -1520283006 - Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
Expected Image to have the same type as Result Type Image
%184 = OpSampledImage %183 %177 %181
. The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.3.290.0/linux/1.3-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08737)
Objects: 0
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849(ERROR / SPEC): msgNum: 1132206547 - Validation Error: [ VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 ] | MessageID = 0x437c19d3 | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[1] After specialization was applied, VkShaderModule 0x95a125000000001a[] produces a spirv-val error (stage VK_SHADER_STAGE_FRAGMENT_BIT):
Expected Image to have the same type as Result Type Image
%184 = OpSampledImage %183 %177 %181
. The Vulkan spec states: If a shader module identifier is not specified, the shader code used by the pipeline must be valid as described by the Khronos SPIR-V Specification after applying the specializations provided in pSpecializationInfo, if any, and then converting all specialization constants into fixed constants (https://vulkan.lunarg.com/doc/view/1.3.290.0/linux/1.3-extensions/vkspec.html#VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849)
Objects: 0
Average frame rate = 116.443

The easiest way to replicate is to run:
vsgbuilder --debug
vsgaxes data/models/teapot.vsgt --debug

As a verification, this runs perfectly with no errors:
vsgviewer data/models/teapot.vsgt --debug

Regards,
Roland

@robertosfield
Copy link
Collaborator

I am across this when I upgraded to Kubuntu 24.04 but never found any issues on the VSG setup side, the SPRIR-V code is generated entirely by glslang so the issue likely it stems from there.

Which version of glslang are you building the VSG against?

@rolandhill
Copy link
Contributor Author

rolandhill commented Jan 8, 2025 via email

@robertosfield
Copy link
Collaborator

robertosfield commented Jan 8, 2025

I see the same error when I run vsgbuilder --debug, I don't really know the cause so don't know where to start with trying to resolve it. Nothing has changed with the VSG, it's just recent updates to glslang/drivers appear to resulted in the warning.

Here's my Kubuntu 24.04's glslang details:

$ glslang --version
Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

@AnyOldName3
Copy link
Contributor

I was running into this yesterday, but thought it was down to the shader optimiser work I was doing. The root cause is basically that the SPIRV-Tools team realised they'd been not forcing the depth parameter of images and samplers to match, so added a check to do that, then it turned out that glslang had been generating shaders with that problem for years, so they rolled the check back and I think they also amended the SPIR-V specification so it was no longer a requirement that it matched.

KhronosGroup/SPIRV-Tools#5781 was the bug report, and KhronosGroup/SPIRV-Tools#5789 was the fix.

Your graphics drivers or Vulkan SDK's validation layer must be using the broken version of SPIRV-Tools. My understanding is that there's nothing that can be changed in the shader to make glslang emit something that will pass validation with the overly-strict version.

@rolandhill
Copy link
Contributor Author

Today I updated to Vulkan SDK 1.3.296.0 and rebuilt everything. The error messages have gone away! The odd thing is that I now appear to be using exactly the same version as you.

$glslang --version

Glslang Version: 11:15.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 15.0.0
GLSL Version: 4.60 glslang Khronos. 15.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

@AnyOldName3
Copy link
Contributor

As I said, glslang isn't the problem, it's the validation layer being overly strict due to a SPIRV-Tools bug.

@rolandhill
Copy link
Contributor Author

Thanks, Chris. I'll close this as it doesn't look like any action is required from the VSG side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants