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

Option to not strip spaces from macros #146

Open
pmhpereira opened this issue Sep 21, 2022 · 5 comments
Open

Option to not strip spaces from macros #146

pmhpereira opened this issue Sep 21, 2022 · 5 comments

Comments

@pmhpereira
Copy link

pmhpereira commented Sep 21, 2022

Hello,

I'm working with Unreal Engine (HLSL) and I noticed that it doesn't like #include with no spaces before the path.
Good: #include "/Engine/Private/Common.ush"
Bad: #include"/Engine/Private/Common.ush"

It refuses to compile the shaders, saying that it cannot resolve these paths.

I tried to use //[ and //] but it still strips spaces. So, currently, I need to have an extra build step to add an additional space after every #include.

Would it be possible to have a separate option to ignore pre-processor directives, or a different //[ combination that keeps the code-as-is (spaces included) ?

Thanks.

@pmhpereira
Copy link
Author

pmhpereira commented Sep 21, 2022

I've meanwhile found out that Unreal also doesn't like multiple declarations on the same line, although it is valid HLSL.

Good:

float a;
float b;

Bad:
float a,b;

So, in this case, it would more sense an alternative to the //[ approach, that did not touch that part at all.

I'm not familiar with F#, but if you can give me an overall idea on what I would need to do then I can give it a try.

@laurentlb
Copy link
Owner

Can you clarify your use-case? Unreal is usually quite big; are you using the tool just for obfuscating your shader code?

@pmhpereira
Copy link
Author

pmhpereira commented Sep 21, 2022

Exactly. I'm trying to minify some HLSL shader code from Unreal.

I'm using the following flags --hlsl --format text --preserve-externals --preserve-all-globals

It appears that Unreal has a very picky parser/compiler, so something like the "verbatim" operator but that didn't modify the text would work.

@pmhpereira
Copy link
Author

I was able to hardcode the Minifier for the things that I needed without implementing a new "verbatim" operator.

Feel free to close this issue if its use-case is out of scope for the intended use.

Thanks.

@laurentlb
Copy link
Owner

Thanks for the feedback.

We could have more flags to let you control more precisely the optimizations we apply.

I'll let this issue open. If anyone else hits the problem, please comment.

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