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

Out params / Merge += with previous line #449

Open
laurentlb opened this issue Aug 25, 2024 · 0 comments
Open

Out params / Merge += with previous line #449

laurentlb opened this issue Aug 25, 2024 · 0 comments

Comments

@laurentlb
Copy link
Owner

laurentlb commented Aug 25, 2024

Input:

vec3 Segment(vec3 p, out float h)
{
  h = 2.;
  return p;
}
vec3 meter4(vec2 uv, float value) {
  float dummy;
  return Segment(uv.xyy, dummy);
}
vec3 dash(vec2 uv)
{
    vec3 color;
    color = vec3(1);
    color += meter4(uv, 1.);
    color += meter4(uv, 2.);
    return color;
}

Current output:

vec3 Segment(vec3 p,out float h)
{
  h=2.;
  return p;
}
vec3 meter4(vec2 uv,float value)
{
  return Segment(uv.xyy,value);
}
vec3 dash(vec2 uv)
{
  vec3 color=vec3(1);
  color+=meter4(uv,1.);
  return color+meter4(uv,2.);
}

The function dash is not simplified as much as it should be. It appears that the out parameter in Segment disables those optimizations.

@laurentlb laurentlb changed the title Merge += with previous line Out params / Merge += with previous line Aug 25, 2024
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