Skip to content

Preprocess: filter out #line directives #457

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

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

therontarigo
Copy link
Contributor

Also removes any #extension GL_GOOGLE_include_directive line. This extension is used by glslang to turn on #include support, but glslang emits this extension line in its preprocessed output.

Also removes any #extension GL_GOOGLE_include_directive line.  This extension
is used by glslang to turn on #include support, but glslang emits this
extension line in its preprocessed output.
@therontarigo
Copy link
Contributor Author

I use glslang -E as a preprocessor before minifying. This can result in inputs to the minifier such as

#version 450
#extension GL_GOOGLE_include_directive : enable
#line 1 "linedir2.glsl"
void foo() { }
#line 4 "linedir.glsl"
 void main() { }

#line is useful for tracking original line numbers in case of error/warning messages, but this is undesirable when optimizing for size.
#extension GL_GOOGLE_include_directive : enable is needed on the input to turn on #include support in glslang, but is useless on the output since no GL implements it and any includes have already been processed. This is arguably a glslang bug, but it is easy to handle within the minifier.

@laurentlb laurentlb merged commit ea37461 into laurentlb:master Sep 18, 2024
1 check passed
@laurentlb
Copy link
Owner

Thanks!
As you can see, the preprocessor is very limited. I didn't know if anyone was using it in the current state.

@therontarigo therontarigo deleted the linedirective branch September 19, 2024 13:45
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

Successfully merging this pull request may close these issues.

2 participants