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

Strip unused global functions and vars #181

Open
Lutymane opened this issue Dec 28, 2022 · 2 comments
Open

Strip unused global functions and vars #181

Lutymane opened this issue Dec 28, 2022 · 2 comments

Comments

@Lutymane
Copy link

Any chance of adding a separate option for this?

Input:

float f(){
  float r = 1.;

  return r;
}

vec2 pos = vec2(0.5);

void main(){
  gl_FragColor = vec4(1.);
}

Current output:

float n(){return 1.;}vec2 r=vec2(.5);void main(){gl_FragColor=vec4(1.);}

Desired:

void main(){gl_FragColor=vec4(1.);}
@laurentlb
Copy link
Owner

Partially implemented in #182, more work is needed.

@Lutymane
Copy link
Author

Also it should be extended to remove unused overloads

Input example:

#version 300 es

/*
contributors: [Stefan Gustavson, Ian McEwan]
description: modulus of 289
use: mod289(<float|vec2|vec3|vec4> x)
*/
// #ifndef FNC_MOD289
// #define FNC_MOD289
float mod289(const in float x) { return x - floor(x * (1. / 289.)) * 289.; }
vec2 mod289(const in vec2 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec3 mod289(const in vec3 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec4 mod289(const in vec4 x) { return x - floor(x * (1. / 289.)) * 289.; }
// #endif

in vec4 v_aaa;
out vec4 color;

void main(){
    color = mod289(v_aaa);
}

Current output (1.3.6):

#version 300 es

float v(const float v)
{
  return v-floor(v*(1./289.))*289.;
}
vec2 v(const vec2 v)
{
  return v-floor(v*(1./289.))*289.;
}
vec3 v(const vec3 v)
{
  return v-floor(v*(1./289.))*289.;
}
vec4 v(const vec4 v)
{
  return v-floor(v*(1./289.))*289.;
}
in vec4 v_aaa;
out vec4 color;
void main()
{
  color=v(v_aaa);
}

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

2 participants