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

Flag that disables removal of forward declarations by reordering #26

Open
LeStahL opened this issue Feb 9, 2021 · 1 comment
Open

Comments

@LeStahL
Copy link

LeStahL commented Feb 9, 2021

Shader_Minifier by default reorders functions to be able to remove forward declarations.

While dealing with a single shader file containing all functions, or when combining shader sources before compilation, this technique is very useful to reduce shader source size in the executable.

In my use-case (32k intros) however, I compile shaders containing single functions, to avoid inlining and reduce compile time. The technique requires forward declarations to be present, but those will be optimized by Shader_Minifier.

I suggest

  • either adding a command line switch to disable forward declaration removal by reordering
  • or verifying that the forward declaration in question has a definition inside the minified sources before reordering and dropping it, keeping the forward declaration and not reordering if none is present.

to enable the use of Shader_Minifier when compiling functions separately.

I would be willing to submit a PR, should you decide you like the suggestion - just let me know if you like the idea (and which approach you prefer).

@laurentlb
Copy link
Owner

This sounds like a nice feature

If I remember correctly, the forward declaration is removed immediately (there's no AST node for it at all). So we need a change in the parser as well as the printer.

In your second proposal: we could drop the declaration if it isn't used at all. So "keep the forward declaration if it is referenced but not defined in the file".

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