mirror of https://github.com/ppy/osu
Apply changes to custom ShaderManager
This commit is contained in:
parent
7aeab174eb
commit
c0a25144cf
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
public override IShaderPart? GetCachedShaderPart(string name) => base.GetCachedShaderPart(name) ?? parent.GetCachedShaderPart(name);
|
||||
|
||||
return parent.Load(vertex, fragment);
|
||||
}
|
||||
public override byte[]? GetRawData(string fileName) => base.GetRawData(fileName) ?? parent.GetRawData(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue