Skip to content

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

@Boscop

Description

@Boscop

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions