fix(rendering): bound portal resource lifetime
Separate logical ownership, render publication, and GPU retirement across live entities, landblocks, particles, textures, mesh arenas, portal/UI teardown, and per-frame scratch storage. Add bounded DAT/texture caches, upload budgets, three-frame fence retirement, exact-incarnation appearance reconciliation, frame pacing, and extensive lifetime conformance coverage.\n\nThe seven-destination connected route now cuts peak working/private memory roughly in half, returns Caul to 125-153 FPS locally, and produces no WER or AMD reset.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
parent
3971997689
commit
749e8ceeb1
225 changed files with 29107 additions and 3914 deletions
|
|
@ -6,6 +6,7 @@ namespace AcDream.App.Rendering;
|
|||
public sealed class Shader : IDisposable
|
||||
{
|
||||
private readonly GL _gl;
|
||||
private readonly Dictionary<string, int> _uniformLocations = new(StringComparer.Ordinal);
|
||||
public uint Program { get; }
|
||||
|
||||
public Shader(GL gl, string vertexPath, string fragmentPath)
|
||||
|
|
@ -42,39 +43,54 @@ public sealed class Shader : IDisposable
|
|||
|
||||
public unsafe void SetMatrix4(string name, Matrix4x4 m)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.UniformMatrix4(loc, 1, false, (float*)&m);
|
||||
}
|
||||
|
||||
public void SetInt(string name, int value)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.Uniform1(loc, value);
|
||||
}
|
||||
|
||||
public void SetFloat(string name, float value)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.Uniform1(loc, value);
|
||||
}
|
||||
|
||||
public void SetVec3(string name, Vector3 v)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.Uniform3(loc, v.X, v.Y, v.Z);
|
||||
}
|
||||
|
||||
public void SetVec2(string name, Vector2 v)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.Uniform2(loc, v.X, v.Y);
|
||||
}
|
||||
|
||||
public void SetVec4(string name, Vector4 v)
|
||||
{
|
||||
int loc = _gl.GetUniformLocation(Program, name);
|
||||
int loc = GetUniformLocation(name);
|
||||
_gl.Uniform4(loc, v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
|
||||
public void Dispose() => _gl.DeleteProgram(Program);
|
||||
private int GetUniformLocation(string name)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(name);
|
||||
if (_uniformLocations.TryGetValue(name, out int location))
|
||||
return location;
|
||||
|
||||
location = _gl.GetUniformLocation(Program, name);
|
||||
_uniformLocations.Add(name, location);
|
||||
return location;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_uniformLocations.Clear();
|
||||
_gl.DeleteProgram(Program);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue