Skip to content

Commit

Permalink
1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueAmulet committed Sep 15, 2024
1 parent d2b609a commit 0920563
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"VRC.SDK3.Editor",
"VRC.SDKBase",
"VRC.SDKBase.Editor",
"UdonSharp.Runtime",
"UdonSharp.Editor"
],
"includePlatforms": [
Expand Down
313 changes: 239 additions & 74 deletions Packages/blueamulet.udonsharpoptimizer/Editor/Optimizer.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ internal class OptimizerEditorWindow : EditorWindow
SerializedProperty _optimization3;
SerializedProperty _optimization4;
SerializedProperty _optimizationVar;
SerializedProperty _optimizationBR;
SerializedProperty _optimizationSL;
SerializedProperty _optimizationThis;

[MenuItem("Tools/UdonSharp Optimizer")]
Expand All @@ -31,6 +33,8 @@ public void OnEnable()
_optimization3 = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableOPT03));
_optimization4 = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableOPT04));
_optimizationVar = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableVariableReduction));
_optimizationBR = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableBlockReduction));
_optimizationSL = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableStoreLoad));
_optimizationThis = _settingsSO.FindProperty(nameof(OptimizerSettings.EnableThisBugFix));
}

Expand Down Expand Up @@ -73,9 +77,12 @@ public void OnGUI()
EditorGUILayout.PropertyField(_optimization2, false);
EditorGUILayout.PropertyField(_optimization3, false);
EditorGUILayout.PropertyField(_optimization4, false);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(_optimizationVar, false);
using (new EditorGUI.DisabledScope(!_settings.EnableVariableReduction))
{
EditorGUILayout.PropertyField(_optimizationBR, false);
EditorGUILayout.PropertyField(_optimizationSL, false);
EditorGUILayout.PropertyField(_optimizationThis, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Unoffical UdonSharp Optimizer
* Unofficial UdonSharp Optimizer
* Integrates the Optimizer with UdonSharp
* Written by BlueAmulet
*/
Expand All @@ -25,7 +25,7 @@ internal static class OptimizerInject
private static readonly MethodInfo optimizerInject = AccessTools.Method(typeof(Optimizer), nameof(Optimizer.OptimizeProgram));

private static bool patchSuccess;
public static bool PatchSuccess { get => patchSuccess; }
public static bool PatchSuccess => patchSuccess;

static OptimizerInject()
{
Expand Down Expand Up @@ -117,7 +117,7 @@ private static IEnumerable<CodeInstruction> TranspilerDump(IEnumerable<CodeInstr
return instrs;
}

public static int LocalIndex(CodeInstruction code)
private static int LocalIndex(CodeInstruction code)
{
if (code.opcode == OpCodes.Ldloc_0 || code.opcode == OpCodes.Stloc_0) return 0;
else if (code.opcode == OpCodes.Ldloc_1 || code.opcode == OpCodes.Stloc_1) return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ internal class OptimizerSettings : ScriptableObject
public bool EnableOPT04 = true;
[Tooltip("Reduce amount of temporary variables")]
public bool EnableVariableReduction = true;
[Tooltip("Map variables to same variable in different blocks")]
public bool EnableBlockReduction = true;
[Tooltip("Map Store+Load variables to same variable")]
public bool EnableStoreLoad = true;
[Tooltip("Fix extra __this_ variables")]
public bool EnableThisBugFix = true;

Expand Down
3 changes: 2 additions & 1 deletion Packages/blueamulet.udonsharpoptimizer/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Changelog:
1.0.5 - Added ExternWrite+Copy check for variables, added missing jump checks
1.0.6 - Added tail call optimization
1.0.7 - Single .unitypackage installation
1.0.8 - Added basic Settings panel
1.0.8 - Added basic Settings panel
1.0.9 - Moved TCO into first pass, added block based variable reduction
2 changes: 1 addition & 1 deletion Packages/blueamulet.udonsharpoptimizer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blueamulet.udonsharpoptimizer",
"displayName": "UdonSharpOptimizer",
"version": "1.0.8",
"version": "1.0.9",
"description": "UdonSharp postprocessor to reduce instruction and variable counts",
"gitDependencies": {},
"vpmDependencies": {
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ UdonSharp makes a *LOT* of temporary variables. We detect places where we can re
1.0.6 - Added tail call optimization
1.0.7 - Single .unitypackage installation
1.0.8 - Added basic Settings panel
1.0.9 - Moved TCO into first pass, added block based variable reduction

0 comments on commit 0920563

Please sign in to comment.