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

msl return value deduction #61

Open
aconstlink opened this issue Mar 5, 2024 · 0 comments
Open

msl return value deduction #61

aconstlink opened this issue Mar 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@aconstlink
Copy link
Owner

If an overloaded function is used the generator picks all functions of the symbol regardless of the signature and puts them into the shader. Depending on the functions' size this could lead to miss-compilation.

There is no AST(or similar structure) for determining all the value types passed to a function so selecting the correct function is not possible.

Example:

There are two functions with the same name but different signature:

vec2_t xyz( in vec2_t vin ) {
    return vin ;
}

vec3_t xyz( in vec3_t vin ) {
    return vin ;
}

Selecting the right function can be done by name which is the current state. Selecting by signature is the problem here:

vec2_t some_other_function( in vec2_t vin ) {
    return vin ;
}

vec3_t some_other_function( in vec3_t vin ) {
    return vin ;
}
vec2_t some_vector ;
msl.xyz( some_vector ) ;
msl.xyz( some_other_function( some_vector ) ) ;

The first call could be resolved because variable types are present in the current state.
The second call is more of a problem.

Here is another example:

vec2_t some_vector1 ;
vec2_t some_vector2 ;
msl.xyz( some_vecto1 + some_vector2 ) ;

So any expression leads to a resulting type which need to be determined in order to be able to select the correct overloaded function.

In the above case the shader generator needs to select the vec2_t version of the xyz function. At the moment, in order to make this happen, the generators use all occurrences of the function called and put them in the resulting shader.

@aconstlink aconstlink added the enhancement New feature or request label Mar 5, 2024
@aconstlink aconstlink changed the title msl overloaded function selection msl return value deduction Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant