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

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

Closed
SiebenCorgie opened this issue Feb 5, 2022 · 2 comments · May be fixed by #857
Closed

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

SiebenCorgie opened this issue Feb 5, 2022 · 2 comments · May be fixed by #857
Labels
a: codegen Issues related to code generation t: bug Something isn't working

Comments

@SiebenCorgie
Copy link
Contributor

SiebenCorgie commented Feb 5, 2022

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	
@SiebenCorgie SiebenCorgie added the t: bug Something isn't working label Feb 5, 2022
@oisyn oisyn added the a: codegen Issues related to code generation label Nov 17, 2022
@eddyb
Copy link
Contributor

eddyb commented Mar 29, 2023

We did land this:

Is that good enough? Sadly we can't fix the underlying pointer issue without doing what you did automatically. Maybe we will, eventually, but for big enough data we'd need heuristics to avoid accidentally copying kilobytes of buffers pointlessly.

@SiebenCorgie
Copy link
Contributor Author

Yeah that looks like a good fix for now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: codegen Issues related to code generation t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants