-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Preprocessor to resolve ifdefs is applied to shader programs #4156
Conversation
Does this affect the sourcemap generation? |
This is only used to process shaders in memory .. so no. |
Co-authored-by: Will Eastcott <will@playcanvas.com>
This is definitely something for @slimbuck to review - I'll pass. |
Updates based on comments @slimbuck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably update the preprocessor over time, but this is a reasonable first pass.
A new private class is added to preprocess defines and ifdefs in the shader with the goal of removing unused code. This is a first preparation step. Following steps will further modify the shader code, in order to convert uniforms to uniform blocks.
New (private) API:
Note - Simple expression evaluation only is supported for ifdefs, handles cases:
It does not handle more complex cases, which would require more complex system:
And so few use cases in the shaders were converted to the supported format.
Unit test has also been added.
Additionally, Debug logging functionality has been extended with trace function.
New (private) API (and also examples of use):
and this is displayed in the console:
[Preprocessor] message