1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:43:01 +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; SampleStore.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
CacheAs(SampleStore = new FallbackSampleStore(SampleStore, parent.Get<ISampleStore>())); CacheAs(SampleStore = new FallbackSampleStore(SampleStore, parent.Get<ISampleStore>()));
ShaderManager = new ShaderManager(host.Renderer, new NamespacedResourceStore<byte[]>(resources, @"Shaders")); CacheAs(ShaderManager = new RulesetShaderManager(host.Renderer, new NamespacedResourceStore<byte[]>(resources, @"Shaders"), parent.Get<ShaderManager>()));
CacheAs(ShaderManager = new FallbackShaderManager(host.Renderer, ShaderManager, parent.Get<ShaderManager>()));
RulesetConfigManager = parent.Get<IRulesetConfigCache>().GetConfigFor(ruleset); RulesetConfigManager = parent.Get<IRulesetConfigCache>().GetConfigFor(ruleset);
if (RulesetConfigManager != null) 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 parent;
private readonly ShaderManager fallback;
public FallbackShaderManager(IRenderer renderer, ShaderManager primary, ShaderManager fallback) public RulesetShaderManager(IRenderer renderer, NamespacedResourceStore<byte[]> rulesetResources, ShaderManager parent)
: base(renderer, new ResourceStore<byte[]>()) : base(renderer, rulesetResources)
{ {
this.primary = primary; this.parent = parent;
this.fallback = fallback;
} }
public override byte[]? LoadRaw(string name) => primary.LoadRaw(name) ?? fallback.LoadRaw(name); public override IShader Load(string vertex, string fragment)
protected override void Dispose(bool disposing)
{ {
base.Dispose(disposing); try
if (primary.IsNotNull()) primary.Dispose(); {
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);
}
} }
} }
} }