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

In the shared crate: Annotate functions/methods with #[inline(always)] #15

Open
Boscop opened this issue Dec 13, 2020 · 0 comments
Open

Comments

@Boscop
Copy link

Boscop commented Dec 13, 2020

When compiling Rust shaders to GLSL I noticed that a lot of functions are not inlined by default that should be.
I used the shared crate from this repo when porting some shadertoy shaders to Rust, e.g.
https://www.shadertoy.com/view/tsyBDm
You can see it has a lot of small functions that should be inlined (several of them from the shared crate), like:

float shared_saturate(float _3518)
{
    return min(max(_3518, 0.0), 1.0);
}
float shared_smoothstep(float _3522, float _3523, float _3524)
{
    float _3529 = shared_saturate((_3524 - _3522) / (_3523 - _3522));
    return (_3529 * _3529) * (3.0 - (2.0 * _3529));
}
float shared_mix_f32_f32_(float _394, float _395, float _396)
{
    return (_394 - (_394 * _396)) + (_395 * _396);
}

Inlining is especially important considering that the spirv backend doesn't really optimize much at the moment, and spirv-opt often produces invalid output (on which spirv validation fails).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant