From a1c393ee140d99f60b63590c1582fdebbd205a9c Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 26 May 2026 08:16:42 +0200 Subject: [PATCH] =?UTF-8?q?hardening(render):=20Phase=20A8=20=E2=80=94=20I?= =?UTF-8?q?ndoorCellStencilPipeline=20robustness?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three small improvements from Task 5 code review: - MarkAndPunch now enables DepthTest explicitly (was relying on GameWindow's startup enable; this makes the method self-contained). - Uniform location fields marked readonly (set once in ctor). - AllocateVbo gets a comment noting that mid-session reallocation is safe because the VAO bakes the VBO association at ConfigureVao time. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/AcDream.App/Rendering/IndoorCellStencilPipeline.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/AcDream.App/Rendering/IndoorCellStencilPipeline.cs b/src/AcDream.App/Rendering/IndoorCellStencilPipeline.cs index 0f113d8..605309d 100644 --- a/src/AcDream.App/Rendering/IndoorCellStencilPipeline.cs +++ b/src/AcDream.App/Rendering/IndoorCellStencilPipeline.cs @@ -99,8 +99,8 @@ public sealed unsafe class IndoorCellStencilPipeline : IDisposable private readonly uint _vbo; private int _vboCapacityVerts; private int _lastVertexCount; - private int _uViewProjectionLoc; - private int _uWriteFarDepthLoc; + private readonly int _uViewProjectionLoc; + private readonly int _uWriteFarDepthLoc; public IndoorCellStencilPipeline(GL gl, string vertPath, string fragPath) { @@ -153,6 +153,7 @@ public sealed unsafe class IndoorCellStencilPipeline : IDisposable if (_lastVertexCount == 0) return; _gl.Enable(EnableCap.StencilTest); + _gl.Enable(EnableCap.DepthTest); // idempotent if already on; makes MarkAndPunch self-contained _gl.ClearStencil(0); _gl.Clear(ClearBufferMask.StencilBufferBit); @@ -227,6 +228,9 @@ public sealed unsafe class IndoorCellStencilPipeline : IDisposable _gl.DeleteBuffer(_vbo); } + // Safe to call mid-session after ConfigureVao — the VAO bakes the + // VBO association at VertexAttribPointer time, so reallocating the + // VBO with new size does NOT require re-running ConfigureVao. private void AllocateVbo(int capacityVerts) { _vboCapacityVerts = capacityVerts;