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
Add support for generating linkable SPIR-V modules #2013
Conversation
Indeed it looks like there's some uninitialized variable issue which caused the mismatches when I ran the tests without the change in this PR, as appveyor didn't generate the same failures due to the missing "Validation failed" message in the outputs, like my local build with MSVC. I'll include the updated and new expected outputs in the PR with a second commit (again, to allow reviewing the PR without the data pollution). I'll also try to figure out where the variable initialization is missing in the test suite. |
7f6b73f
to
b05faaa
Compare
Ok, now it passes all tests. One thing to note is that I did not enable exporting the entry point functions themselves. If that would be desirable I can update the code. |
SPIR-V explicitly does not allow compilation unit linkage. For graphical stages it requires a fully linked stage within a single module. This is for a few reasons:
Some pretty important extension or specification work needs to be done to resolve these. I'm surprised SPIR-V Tools would be going against the specification as well; maybe I'm missing something. |
Also note that Vulkan excludes the Linkage capability from its list of allowed capabilities. |
Okay, I need to clarify a few things (I've sent you an e-mail about this on Sunday, but I didn't get a response):
I suggest you to talk with @dneto0, as we had some preliminary conversation with him about this. |
@aqnuep @johnkslang What is the status of this feature? Is there any ETA on when this might get merged to master? |
Waiting for a GLSL-level specification of what the linkage semantics are and how they mapped to SPIR-V. Note that GLSL and C don't have the same semantics for how to combine what might appear to the be same object in different compilation units. The semantics are currently handled by AST merging. I think this PR subsets those, and to support the code, there should be specification for it. |
@johnkslang Right, makes sense. Is there a link or reference you could give me to the internal Khronos threads about that on GitLab? I'm struggling to find the relevant info there. |
I think it can be posted here, looking to @aqnuep for that. |
This is partially news to me too. Sure, I guess writing a GLSL extension for documenting the mapping from GLSL to SPIR-V (without introducing any new capabilities) makes sense. I assume it would practically act as a documentation of the glslang implementation of the mapping (sort of like a partial ABI). That sound like a reasonable plan! P.S.: I may also have most of the changes needed on the shaderc side of things lying around somewhere, so I can share that too if needed. |
@aqnuep do you still plan to work on this? If not, we would like to close the PR. |
No, @arcady-lunarg. This one is really old at this point and there seems to be no traction to make this happen. Closing. |
Added support for generating linkabe SPIR-V modules from shaders that only go through the compile stage without linking.
Due to the nature of GLSL this only enables function linkage, because global variable linkage in GLSL are so called "shared globals" which don't have a canonical copy, thus don't map well to SPIR-V's Linkage capability which works in a traditional export/import model. However, in practice this should not limit possible uses.
The generated SPIR-V files will use the Linkage SPIR-V capability without enabling any additional SPIR-V extensions, though an explicit SPIR-V extension enabling the usage of the Linkage capability in SPIR-V shader modules would probably be preferable.
The resulting linkable SPIR-V modules can be linked using the spirv-link tool once KhronosGroup/SPIRV-Tools#3081 gets merged.
New tests have been added to cover the functionality, but this change also has an effect on the output of existing test cases (due to the new EOpLinkerFunction nodes in the compiled but not linked ASTs). The reasons I didn't include the baseline expected outputs for the new and existing tests are the following:
The final piece of the puzzle will be a PR to shaderc which hopefully will solve issue google/shaderc#315.