Add GL_EXT_spirv_intrinsics_variadic extension#332
Open
rdb wants to merge 1 commit into
Open
Conversation
This was referenced Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first half of #331, adding the extension text for the variadics part (the forthcoming string extension is designed to be independent). I've also got a working implementation in glslang, which I will submit separately.
The extension adds variadic syntax (like
void f(int x, ...)) forspirv_instructionfunctions, motivated by use cases likedebugPrintfEXTandabortEXT. The grammar is written to restrict the use of the ellipsis to onlyspirv_instruction-qualified functions, though I expect most implementations will reject invalid uses semantically rather than purely at the grammar level.I had underestimated how much work there was to define variadic functions properly, especially regarding overload resolution, which in practice won't come up much but must be addressed. The crux of it is this:
GLSL short-circuits function resolution: if there's an exact type match between the formal parameters and the calling arguments, that match is used and overload resolution is pre-empted. I've kept that rule intact by excluding variadic declarations from ever being considered an "exact match", so any call involving a variadic always goes through normal overload resolution. As it happens, glslang's existing variadics support (used only for builtins) already behaves this way.
Where I deliberately deviate from the current glslang behavior is that glslang currently reports
f(float)andf(float, ...)as ambiguous when called withf(1)but chooses the former silently withf(1.0)as per the exact-match rule, which I deemed too surprising. I have resolved this by adding a tie-break rule making it prefer the non-variadic overload in this specific case. The alternatives all turned out messy; the cleanest would require effectively redefining function calling in GLSL by gutting the exact-match rule, which I deemed to be far too invasive for an extension of this kind. Issue 5 lays out the arguments in more detail; the chosen option does have a pleasing analogy in C++.Another point of note is that I made this against 4.60.8 since I could not locate a copy of the 4.60.7 spec that the base extension is based on. I can submit a PR to update the base extension or verify my extension against a copy of the 4.60.7 spec if someone can point me to one, if this is considered a problem.
This is my first time submitting an extension, so please let me know if I have made mistakes. Thanks for your consideration!