Skip to content

Commit

Permalink
Merge pull request #23228 from smoogipoo/shader-cache-stages
Browse files Browse the repository at this point in the history
Apply framework changes to custom ShaderManager
  • Loading branch information
peppy authored Apr 19, 2023
2 parents ee5658c + 01260e5 commit cc96d27
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 26 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.417.1" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.418.0" />
</ItemGroup>
<ItemGroup>
<AndroidManifestOverlay Include="$(MSBuildThisFileDirectory)osu.Android\Properties\AndroidManifestOverlay.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public TestShaderManager(IRenderer renderer, ShaderManager parentManager)
this.parentManager = parentManager;
}

public override byte[] LoadRaw(string name) => parentManager.LoadRaw(name);
public override byte[] GetRawData(string fileName) => parentManager.GetRawData(fileName);

public bool IsDisposed { get; private set; }

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Testing/TestSceneRulesetDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void TestRetrieveShader()
{
AddStep("ruleset shaders retrieved without error", () =>
{
Dependencies.Get<ShaderManager>().LoadRaw(@"sh_TestVertex.vs");
Dependencies.Get<ShaderManager>().LoadRaw(@"sh_TestFragment.fs");
Dependencies.Get<ShaderManager>().GetRawData(@"sh_TestVertex.vs");
Dependencies.Get<ShaderManager>().GetRawData(@"sh_TestFragment.fs");
});
}

Expand Down
24 changes: 4 additions & 20 deletions osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,11 @@ public RulesetShaderManager(IRenderer renderer, NamespacedResourceStore<byte[]>
this.parent = parent;
}

// When the debugger is attached, exceptions are expensive.
// Manually work around this by caching failed lookups and falling back straight to parent.
private readonly HashSet<(string, string)> failedLookups = new HashSet<(string, string)>();
public override IShader? GetCachedShader(string vertex, string fragment) => base.GetCachedShader(vertex, fragment) ?? parent.GetCachedShader(vertex, fragment);

public override IShader Load(string vertex, string fragment)
{
if (!failedLookups.Contains((vertex, fragment)))
{
try
{
return base.Load(vertex, fragment);
}
catch
{
// Shader lookup is very non-standard. Rather than returning null on missing shaders, exceptions are thrown.
failedLookups.Add((vertex, fragment));
}
}

return parent.Load(vertex, fragment);
}
public override IShaderPart? GetCachedShaderPart(string name) => base.GetCachedShaderPart(name) ?? parent.GetCachedShaderPart(name);

public override byte[]? GetRawData(string fileName) => base.GetRawData(fileName) ?? parent.GetRawData(fileName);
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.20.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.417.1" />
<PackageReference Include="ppy.osu.Framework" Version="2023.418.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.417.0" />
<PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" />
Expand Down
2 changes: 1 addition & 1 deletion osu.iOS.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.417.1" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.418.0" />
</ItemGroup>
</Project>

0 comments on commit cc96d27

Please sign in to comment.