-
Notifications
You must be signed in to change notification settings - Fork 863
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
[4.0] Implement version 400 function-overloading disambiguation algorithm #142
Comments
FYI, this is specified in section 6.1 of GLSL as the following, and I know it is possible to implement this as a two-pass linear algorithm across the set of choices.
|
Here is a high-level design for a generic selector, which I believe can be used by both GLSL and HLSL, and probably other more C++-like languages too. Generic SelectorThis would live in place usable by multiple languages, e.g. Assumptions
Input
Output
Operation
Note there were three linear passes to find the best. GLSL
HLSL
|
I think this will work for HLSL, I suspect the right thing to do will be take the function which has the minimum best of each individual argument rather then the sum of them, but that's just a guess. I think it's fine for SVSL (Spir-V Shading Language) to issue an ambiguous error in cases where HLSL would have picked one. It's pretty easy to add some explicit casts to fix those cases, and it's probably whacky code anyway. |
@dneto0 Have any (or know where to get some) input on how well this generalizes to C++ rules? |
I haven't worked on a C++ front end, but a good reference would be See the section "Best viable function", especially paragraph 2 beginning with "F1 is determined to be a better funtion than F2...". That rule looks very similar in spirit to the GLSL rules stated above, by checking for one better argument and no argument being worse. So at first blush your algorithm looks like a good framework. The next place I'd look after that is the C++ standard itself. |
Thanks @dneto0, I analyzed/compared with this result:
Generally, for all languages
|
Actually, I should say my algorithm would get the correct result for C++, as neither C++ nor GLSL are giving an algorithm, but rather a description of what is correct. The descriptions are O(V^2), for V being number of viable candidates, whereas the algorithm I'm proposing is O(C), for C being number of candidates. |
This is implemented for the generic selector and the GLSL #version 400 predicates in https://github.com/KhronosGroup/glslang/tree/overloaded-400 (last commit there) if anyone wants to check it out or comment. Will pull into master in a few days. |
This is completed with commit fcc0aa3. |
…trol_bits Allocate three loop control bits for an upcoming Intel extension
Currently, only the pre-version 400 function-overloading algorithm is present. Version 400 and above should be using the second-generation algorithm.
The text was updated successfully, but these errors were encountered: