Skip to content

Commit

Permalink
Parse and ignore const keyword in shader function parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkc0d3r committed Apr 11, 2023
1 parent a73d3c0 commit 4ef99b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Next Version
### Bug Fixes
* Apparently `sampler` is also a way to declare a `SamplerState`. So now the optimizer also replaces those.
* Parse and ignore const keyword in shader function parameters.

## v2.0.0
### Features
Expand Down
8 changes: 4 additions & 4 deletions Editor/ShaderAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ private void AddParameterStructWrapper(List<string> funcParams, List<string> out
output.Add(line);
continue;
}
var match = Regex.Match(line, @"^((in|out|inout)\s)?\s*(\w+\s+\w+(\s*:\s*\w+)?)");
var match = Regex.Match(line, @"^((in|out|inout)\s+)?(?:const\s)?\s*(\w+\s+\w+(\s*:\s*\w+)?)");
if (match.Success)
{
if (isInput ^ match.Groups[2].Value != "out")
Expand All @@ -1108,7 +1108,7 @@ private void InitializeParameterFromWrapper(List<string> funcParams, List<string
output.Add(line);
continue;
}
var match = Regex.Match(line, @"^((in|out|inout)\s)?\s*(\w+)\s+(\w+)(\s*:\s*\w+)?");
var match = Regex.Match(line, @"^((in|out|inout)\s+)?(?:const\s)?\s*(\w+)\s+(\w+)(\s*:\s*\w+)?");
if (match.Success)
{
var type = match.Groups[3].Value;
Expand Down Expand Up @@ -1142,7 +1142,7 @@ private void AddOutParametersToFunctionDeclaration(List<string> funcParams, List
output.Add(line);
continue;
}
var match = Regex.Match(line, @"^((in|out|inout)\s)?\s*(\w+\s+\w+(\s*:\s*\w+))?");
var match = Regex.Match(line, @"^((in|out|inout)\s+)?(?:const\s)?\s*(\w+\s+\w+(\s*:\s*\w+))?");
if (match.Success)
{
if (match.Groups[2].Value == "out")
Expand All @@ -1164,7 +1164,7 @@ private void InitializeOutputParameter(List<string> funcParams, List<string> out
output.Add(line);
continue;
}
var match = Regex.Match(line, @"^((in|out|inout)\s)?\s*(\w+)\s+(\w+)(\s*:\s*\w+)?");
var match = Regex.Match(line, @"^((in|out|inout)\s+)?(?:const\s)?\s*(\w+)\s+(\w+)(\s*:\s*\w+)?");
if (match.Success)
{
if (match.Groups[2].Value == "out")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "d4rkpl4y3r.d4rkavataroptimizer",
"displayName": "d4rkAvatarOptimizer",
"version": "2.0.0",
"version": "2.0.1",
"unity": "2019.4",
"description": "An optimizer aiming to reduce mesh & material count and more of VRChat 3.0 avatars.",
"dependencies": {},
Expand Down

0 comments on commit 4ef99b8

Please sign in to comment.