-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Refactoring the ShaderLab Compiler Module using the LALR Algorithm for Enhanced GLSL Compatibility and Reduced Build Size #2113
Merged
GuoLei1990
merged 111 commits into
galacean:dev/1.3
from
Sway007:refactor/shaderlab_1.3
Jul 15, 2024
Merged
Refactoring the ShaderLab Compiler Module using the LALR Algorithm for Enhanced GLSL Compatibility and Reduced Build Size #2113
GuoLei1990
merged 111 commits into
galacean:dev/1.3
from
Sway007:refactor/shaderlab_1.3
Jul 15, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…actor/shaderlab_1.3
Sway007
added
enhancement
New feature or request
shader
Shader related functions
high priority
High priority issue
labels
Jun 13, 2024
16 tasks
|
zhuxudong
reviewed
Jun 17, 2024
packages/shader-lab/src/ShaderLab.ts
Outdated
const ast = this._visitor.visit(cst); | ||
const shaderInfo = this._context.parse(ast); | ||
return shaderInfo; | ||
parseShader(source: string, includeMap: Record<string, string> = {}, backend = EBackend.GLES300) { |
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.
includeMap
it's not exported in Shader.create(***)
Merge logger to engine logger |
GuoLei1990
reviewed
Jul 9, 2024
} | ||
for (let i = 0; i < platformMacros.length; i++) { | ||
Preprocessor.addPredefinedMacro(platformMacros[0]); | ||
} |
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.
- platformMacros[0]???
- Why not cache n?
GuoLei1990
approved these changes
Jul 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
high priority
High priority issue
shader
Shader related functions
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
In this update, we made a significant overhaul of the
ShaderLab
module, employing the LALR (Look-Ahead Left-to-Right) parsing algorithm to achieve several substantial improvements over the previous version. This refactoring effort aligns more closely with the GLES syntax standard, providing improved compatibility with the GLSL language. Below are the key highlights of this update:Completely Rewrite using the LALR Algorithm
The compiler has been rebuilt from the ground up utilizing the LALR algorithm. This strategic choice not only enhances the parsing efficiency but also ensures that our compiler adheres closely to the GLES syntax standard. Through this approach, we have achieved a more robust compatibility with GLSL, catering to a wider range of shader programming needs.
Elimination of Third-party Dependency
A significant advancement in this version is the removal of third-party package
chevrotain
dependency. This decision drastically reduces the overall package size, leading to leaner build outputs. This reduction in dependencies not only simplifies the build process but also minimizes potential conflicts and enhances the portability of the compiler.User-friendly Programming with Less Syntax Restriction
Compared to version 1.2, the current iteration of the compiler introduces fewer syntax restrictions, offering a more user-friendly programming experience. We've also simplified syntax extension, making it easier for developers to introduce new features and customizations. This flexibility encourages experimentation and innovation within shader programming.
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
Struct declaration mandates a semicolon at the end of a struct declaration
After update
Declare shader main entry function (vertex and fragment shader main) assignment after main function definition
After update