refactor(app): compose world rendering startup
Move Region/environment, mandatory modern rendering, terrain, WB, texture, and sampler construction behind the typed Phase-4 composition boundary. Give every fallible GL constructor prefix retryable ownership so partial startup failure cannot leak or replay resource deletion while preserving the accepted render path and DAT inputs. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
cd7b519f78
commit
6a2fe98cc4
22 changed files with 1983 additions and 634 deletions
|
|
@ -29,6 +29,107 @@ public sealed class ResourceCleanupGroupTests
|
|||
Assert.Equal(["last", "middle", "first", "middle"], calls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransferAllLeavesPublishedResourcesUntouched()
|
||||
{
|
||||
int releaseCalls = 0;
|
||||
var resources = new ResourceCleanupGroup();
|
||||
resources.Add("published", () => releaseCalls++);
|
||||
|
||||
resources.TransferAll();
|
||||
resources.RetryCleanup();
|
||||
|
||||
Assert.True(resources.IsCleanupComplete);
|
||||
Assert.Equal(0, releaseCalls);
|
||||
Assert.Throws<InvalidOperationException>(() =>
|
||||
resources.Add("late", () => { }));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FailedConstructionRollbackRetainsOnlyUnreleasedOwnership()
|
||||
{
|
||||
int releases = 0;
|
||||
bool releaseFails = true;
|
||||
var resources = new ResourceCleanupGroup();
|
||||
resources.Add("retryable", () =>
|
||||
{
|
||||
releases++;
|
||||
if (releaseFails)
|
||||
throw new InvalidOperationException("release failed");
|
||||
});
|
||||
|
||||
GlResourceConstructionException failure =
|
||||
Assert.Throws<GlResourceConstructionException>(() =>
|
||||
resources.RollbackConstructionAndThrow(
|
||||
"construction failed",
|
||||
new InvalidOperationException("original failure")));
|
||||
|
||||
Assert.False(failure.IsCleanupComplete);
|
||||
Assert.Equal(1, releases);
|
||||
releaseFails = false;
|
||||
failure.RetryCleanup();
|
||||
failure.RetryCleanup();
|
||||
|
||||
Assert.True(failure.IsCleanupComplete);
|
||||
Assert.Equal(2, releases);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WorldRenderFoundationConstructorsPublishEveryOwnedPrefix()
|
||||
{
|
||||
string root = FindRepoRoot();
|
||||
string graphicsDevice = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
"Wb",
|
||||
"OpenGLGraphicsDevice.cs"));
|
||||
string shader = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
"Wb",
|
||||
"GLSLShader.cs"));
|
||||
string uniformBuffer = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"src",
|
||||
"AcDream.App",
|
||||
"Rendering",
|
||||
"Wb",
|
||||
"ManagedGLUniformBuffer.cs"));
|
||||
|
||||
AssertAppearsInOrder(
|
||||
graphicsDevice,
|
||||
"var resources = new ResourceCleanupGroup();",
|
||||
"InstanceVBO = CreateConstructionBuffer(resources",
|
||||
"WrapSampler = CreateConstructionSampler(",
|
||||
"ClampSampler = CreateConstructionSampler(",
|
||||
"_sceneDataBuffer = new ManagedGLUniformBuffer(",
|
||||
"resources.Add(",
|
||||
"\"WB scene-data uniform buffer\"",
|
||||
"InitializeSharedDebugResources(resources);",
|
||||
"resources.TransferAll();",
|
||||
"resources.RollbackConstructionAndThrow(");
|
||||
AssertAppearsInOrder(
|
||||
shader,
|
||||
"ShaderProgramConstruction.Build(",
|
||||
"resources.Add(\"WB shader program\"",
|
||||
"configure shader {Name} SceneData binding",
|
||||
"resources.TransferAll();",
|
||||
"resources.RollbackConstructionAndThrow(");
|
||||
AssertAppearsInOrder(
|
||||
uniformBuffer,
|
||||
"TrackedGlResource.CreateBuffer(",
|
||||
"resources.Add(",
|
||||
"TrackedGlResource.AllocateBufferStorage(",
|
||||
"resources.TransferAll();",
|
||||
"resources.RollbackConstructionAndThrow(");
|
||||
Assert.Contains("internal void DisposeImmediately()", uniformBuffer,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TextRendererPublishesEveryConstructorResourceBeforeLaterGlWork()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue