hardening(render): Phase A8 — IndoorCellStencilPipeline robustness

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) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-26 08:16:42 +02:00
parent 3973596468
commit a1c393ee14

View file

@ -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;