refactor(lifetime): own render resource prefixes
Give terrain, sky, retained UI, portal preparation, and the update/render frame pair explicit single owners. Make shader, texture, text, bindless, and GL construction prefixes checked and retryable so partial failure cannot lose or replay resource ownership. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
fec0d94148
commit
c87b15303d
41 changed files with 3768 additions and 355 deletions
21
src/AcDream.App/Rendering/GameRenderResourceLifetime.cs
Normal file
21
src/AcDream.App/Rendering/GameRenderResourceLifetime.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
namespace AcDream.App.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Sole lifetime owner for render resources that are borrowed by, but not
|
||||
/// owned by, their renderers.
|
||||
/// </summary>
|
||||
internal sealed class GameRenderResourceLifetime
|
||||
{
|
||||
private readonly OwnedResourceSlot<TerrainAtlas> _terrainAtlas = new();
|
||||
private readonly OwnedResourceSlot<Shader> _skyShader = new();
|
||||
|
||||
public TerrainAtlas AcquireTerrainAtlas(Func<TerrainAtlas> factory) =>
|
||||
_terrainAtlas.Acquire(factory);
|
||||
|
||||
public Shader AcquireSkyShader(Func<Shader> factory) =>
|
||||
_skyShader.Acquire(factory);
|
||||
|
||||
public void ReleaseTerrainAtlas() => _terrainAtlas.Release();
|
||||
|
||||
public void ReleaseSkyShader() => _skyShader.Release();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue