1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Fix ruleset-local shader manager not correctly falling back to existing cached shaders

This commit is contained in:
Dean Herbert 2023-03-28 14:53:08 +09:00
parent 5dfac02b11
commit 0d77ec013a

View File

@ -68,8 +68,7 @@ namespace osu.Game.Rulesets.UI
SampleStore.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
CacheAs(SampleStore = new FallbackSampleStore(SampleStore, parent.Get<ISampleStore>()));
ShaderManager = new ShaderManager(host.Renderer, new NamespacedResourceStore<byte[]>(resources, @"Shaders"));
CacheAs(ShaderManager = new FallbackShaderManager(host.Renderer, ShaderManager, parent.Get<ShaderManager>()));
CacheAs(ShaderManager = new RulesetShaderManager(host.Renderer, new NamespacedResourceStore<byte[]>(resources, @"Shaders"), parent.Get<ShaderManager>()));
RulesetConfigManager = parent.Get<IRulesetConfigCache>().GetConfigFor(ruleset);
if (RulesetConfigManager != null)
@ -197,24 +196,27 @@ namespace osu.Game.Rulesets.UI
}
}
private class FallbackShaderManager : ShaderManager
private class RulesetShaderManager : ShaderManager
{
private readonly ShaderManager primary;
private readonly ShaderManager fallback;
private readonly ShaderManager parent;
public FallbackShaderManager(IRenderer renderer, ShaderManager primary, ShaderManager fallback)
: base(renderer, new ResourceStore<byte[]>())
public RulesetShaderManager(IRenderer renderer, NamespacedResourceStore<byte[]> rulesetResources, ShaderManager parent)
: base(renderer, rulesetResources)
{
this.primary = primary;
this.fallback = fallback;
this.parent = parent;
}
public override byte[]? LoadRaw(string name) => primary.LoadRaw(name) ?? fallback.LoadRaw(name);
protected override void Dispose(bool disposing)
public override IShader Load(string vertex, string fragment)
{
base.Dispose(disposing);
if (primary.IsNotNull()) primary.Dispose();
try
{
return base.Load(vertex, fragment);
}
catch
{
// Shader lookup is very non-standard. Rather than returning null on missing shaders, exceptions are thrown.
return parent.Load(vertex, fragment);
}
}
}
}