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
|
|
@ -144,42 +144,56 @@ public sealed unsafe class TerrainModernRenderer : IDisposable
|
|||
if (_uTexTilingLoc < 0)
|
||||
throw new InvalidOperationException("terrain_modern.frag is missing the required uTexTiling uniform.");
|
||||
|
||||
var constructionResources = new ResourceCleanupGroup();
|
||||
try
|
||||
{
|
||||
_globalVao = TrackedGlResource.CreateVertexArray(
|
||||
_gl,
|
||||
"creating terrain global VAO");
|
||||
RetryableGpuResourceRelease globalVaoRelease =
|
||||
TrackedGlResource.CreateRetryableVertexArrayDeletion(
|
||||
_gl,
|
||||
_globalVao,
|
||||
"rolling back terrain global VAO");
|
||||
constructionResources.Add(
|
||||
"terrain global VAO",
|
||||
globalVaoRelease.Run);
|
||||
_globalVbo = TrackedGlResource.CreateBuffer(
|
||||
_gl,
|
||||
"creating terrain global vertex buffer");
|
||||
RetryableGpuResourceRelease globalVboRelease =
|
||||
TrackedGlResource.CreateRetryableBufferDeletion(
|
||||
_gl,
|
||||
_globalVbo,
|
||||
() => _globalVboCapacityBytes,
|
||||
"rolling back terrain global vertex buffer");
|
||||
constructionResources.Add(
|
||||
"terrain global vertex buffer",
|
||||
globalVboRelease.Run);
|
||||
_globalEbo = TrackedGlResource.CreateBuffer(
|
||||
_gl,
|
||||
"creating terrain global index buffer");
|
||||
RetryableGpuResourceRelease globalEboRelease =
|
||||
TrackedGlResource.CreateRetryableBufferDeletion(
|
||||
_gl,
|
||||
_globalEbo,
|
||||
() => _globalEboCapacityBytes,
|
||||
"rolling back terrain global index buffer");
|
||||
constructionResources.Add(
|
||||
"terrain global index buffer",
|
||||
globalEboRelease.Run);
|
||||
AllocateGpuBuffers(initialSlotCapacity);
|
||||
ConfigureVao(_globalVao, _globalVbo, _globalEbo);
|
||||
GlResourceCommand.Execute(
|
||||
_gl,
|
||||
"configure terrain global vertex array",
|
||||
() => ConfigureVao(_globalVao, _globalVbo, _globalEbo));
|
||||
constructionResources.TransferAll();
|
||||
}
|
||||
catch
|
||||
catch (Exception constructionFailure)
|
||||
{
|
||||
TrackedGlResource.DeleteVertexArray(
|
||||
_gl,
|
||||
_globalVao,
|
||||
"rolling back terrain global VAO");
|
||||
TrackedGlResource.DeleteBuffer(
|
||||
_gl,
|
||||
_globalVbo,
|
||||
_globalVboCapacityBytes,
|
||||
"rolling back terrain global vertex buffer");
|
||||
TrackedGlResource.DeleteBuffer(
|
||||
_gl,
|
||||
_globalEbo,
|
||||
_globalEboCapacityBytes,
|
||||
"rolling back terrain global index buffer");
|
||||
_globalVao = 0;
|
||||
_globalVbo = 0;
|
||||
_globalEbo = 0;
|
||||
_globalVboCapacityBytes = 0;
|
||||
_globalEboCapacityBytes = 0;
|
||||
throw;
|
||||
constructionResources.RollbackConstructionAndThrow(
|
||||
"TerrainModernRenderer construction failed and its GL prefix did not cleanly roll back.",
|
||||
constructionFailure);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue