-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(shader_file): fallback to compat. no transform if
#moj_import
i…
…s involved As highlighted in issue #187, a significant number of practical shaders use `#moj_import`s in ways that are tricky for PackSquash to handle without import expansion capabilities. The necessary redesign to achieve expansion will ikely take some time, but there is stakeholder pressure to get better (and more correct) solutions working now: PackSquash has arguably been incorrect in how it processes shaders for months, and justifying the status quo with upcoming plans to tackle the problems at their source is no longer a tenable proposition, leading to relatively frequent uncomfortable situations for both me and users. Therefore, let's play the cards very close to our chest when it comes to transforming GLSL sources: don't do it unless we can be certain that we have a full AST and all the preprocessor state is known. This entails significant optimization regressions for any shader that uses `#moj_import`, as not expanding that directive is the root of all evil, but PackSquash will at least just work in much more cases. In particular, these changes were tested with FancyPants, TextEffects v2.1 and objmc, which are interesting shaders from a parsing standpoint due to their popularity and intensive usage of GLSL language features.
- Loading branch information
1 parent
39a29c0
commit a44d173
Showing
10 changed files
with
216 additions
and
198 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
8 changes: 8 additions & 0 deletions
8
packages/packsquash/src/pack_file/shader_file/example_false_positive_parse_error.glsl
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// unresolvable.glsl may be resolvable by the game, but | ||
// not by us, and contain preprocessor directives that | ||
// may render otherwise invalid GLSL source valid. In | ||
// the example below, unresolvable.glsl may define | ||
// SEMICOLON to be ; | ||
#moj_import <unresolvable.glsl> | ||
|
||
vec2 var SEMICOLON |
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
Oops, something went wrong.