Open DataBeaver opened 3 years ago
That’s an issue with spirv-link; it de-duplicates types and exported/imported variables/functions, but does nothing regarding uniform/buffer/input/ouput blocks as it was first started for OpenCL.
Thank you for providing the shaders and details. I will try to have a look at it soon, but no idea when.
Is there any sort of comprehensive documentation on the limitations of SPIR-V linker?
Is there any sort of comprehensive documentation on the limitations of SPIR-V linker?
There is not. I would say, this is the main ones that I am aware of for graphics, and #3128 for OpenGL or Vulkan compute. For OpenCL, it is mostly lacking some features like supporting the SPV_KHR_linkonce_odr extension, or specifying math flags at link time.
When compiling and linking the attached shaders using these commands:
The resulting binary has two pointer declarations for the Lighting block, with identical bindings:
One pointer is used in the vertex stage and the other in the fragment stage. Apparently this arrangement confuses at least Nvidia Linux drivers (460.56) when using OpenGL, resulting in the vertex shader not being able to read values from the uniform block. If I disassemble the module, remove the declaration and decorations of %8, replace all uses with %2, and finally reassemble the module, it works fine and my object renders correctly.
I'm uncertain of whether this is an issue with spirv-link generating a duplicate pointer or Nvidia drivers not processing it correctly. My best guess is that it has something to do with aliasing, though I haven't tried if adding an AliasedPointer decoration would help. If it's an Nvidia issue, maybe you can at least give me some extra information to present to them.
Test shaders: phong.zip