Skip to content

Commit

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

## v2.0.0
### Features
* Add option to merge simple toggles in the fx layer into one big direct blend tree.
Expand Down
5 changes: 3 additions & 2 deletions Editor/ShaderAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,8 @@ private void ParseCodeLines(List<string> source, ref int sourceLineIndex, Parsed
var type = match.type;
foreach (var name in match.names)
{
if (type == "SamplerState" && name.StartsWith("sampler") && !texturesToReplaceCalls.Contains(name.Substring("sampler".Length)))
bool isTextureSamplerState = (type == "SamplerState" || type == "sampler") && name.StartsWith("sampler");
if (isTextureSamplerState && name.StartsWith("sampler") && !texturesToReplaceCalls.Contains(name.Substring("sampler".Length)))
{
if (parsedShader.properties.Any(p => p.name == name.Substring("sampler".Length)))
{
Expand All @@ -1901,7 +1902,7 @@ private void ParseCodeLines(List<string> source, ref int sourceLineIndex, Parsed
else if (!arrayPropertyValues.ContainsKey(name)
&& !animatedPropertyValues.ContainsKey(name)
&& !texturesToReplaceCalls.Contains(name)
&& !(type == "SamplerState" && name.StartsWith("sampler") && texturesToReplaceCalls.Contains(name.Substring("sampler".Length))))
&& !(isTextureSamplerState && texturesToReplaceCalls.Contains(name.Substring("sampler".Length))))
{
output.Add(type + " " + name + ";");
}
Expand Down

0 comments on commit a73d3c0

Please sign in to comment.