Skip to content

#[inline(never)] ignored when using borrowed push constant as argument. #847

Closed
@SiebenCorgie

Description

@SiebenCorgie

Expected Behaviour

The function

#[inline(never)]
fn sdf(coord: Vec2, con: &PushConst) -> f32{
    let result = (coord - Vec2::splat(200.0)).length() - 150.0;
    result - con.color[0]
}

is expected to be emitted as a NoInline tagged spirV function, but it gets inlined.

Fix

This can be fixed by cloning the constant, which results in the function actually being emitted like this:

#[inline(never)]
fn sdf(coord: Vec2, con: PushConst) -> f32{
    let result = (coord - Vec2::splat(200.0)).length() - 150.0;
    result - con.color[0]
}

compiles to

%19 = OpFunction  %25  DontInline %34
%52 = OpFunctionParameter  %32
%53 = OpFunctionParameter  %18
%54 = OpLabel
OpLine %5 30 4	

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: codegenIssues related to code generationt: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions