phase(N.5) Task 15: delete legacy mesh_instanced shader files

mesh_instanced.vert + .frag deleted. WbDrawDispatcher always uses
mesh_modern when WB foundation is on. Legacy escape hatch
(ACDREAM_USE_WB_FOUNDATION=0 or bindless missing) runs through
InstancedMeshRenderer which has its own shader path — untouched.

GameWindow's else-branch removed; if bindless is missing, _meshShader
stays unloaded, _wbDrawDispatcher stays null, and _staticMesh is not
constructed (its guard requires _meshShader non-null). All downstream
_staticMesh usages were already null-safe (null-conditional operators
or explicit null guards). Two null-forgiving suppressors added at the
WbDrawDispatcher + SkyRenderer construction sites where the compiler
couldn't prove non-null but the logic guarantees it (both require
_bindlessSupport non-null, which implies _meshShader was assigned;
_textureCache is assigned unconditionally).

InstancedMeshRenderer.cs: the one reference to mesh_instanced was
a code comment (location 3 NOT used by mesh_instanced.vert) — not
a file load. Escape hatch code path is preserved; the shader comment
is now stale but low priority.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-08 21:13:05 +02:00
parent 39ccd29030
commit e6378b90ed
3 changed files with 16 additions and 145 deletions

View file

@ -1447,9 +1447,11 @@ public sealed class GameWindow : IDisposable
}
}
// N.5 Task 10: load mesh_modern when both extensions are present;
// fall back to mesh_instanced otherwise. Must be after capability
// detection so _bindlessSupport is known.
// N.5 Task 10/15: load mesh_modern when both extensions are present.
// If bindless is missing _meshShader stays null, _wbDrawDispatcher won't
// be constructed (its guard requires _bindlessSupport non-null), and
// rendering falls back to InstancedMeshRenderer — but only when
// _meshShader is non-null (see _staticMesh construction below).
if (_bindlessSupport is not null)
{
_meshShader = new Shader(_gl,
@ -1457,12 +1459,7 @@ public sealed class GameWindow : IDisposable
Path.Combine(shadersDir, "mesh_modern.frag"));
Console.WriteLine("[N.5] mesh_modern shader loaded");
}
else
{
_meshShader = new Shader(_gl,
Path.Combine(shadersDir, "mesh_instanced.vert"),
Path.Combine(shadersDir, "mesh_instanced.frag"));
}
// else: bindless missing — _meshShader stays null.
_textureCache = new TextureCache(_gl, _dats, _bindlessSupport);
// Two persistent GL sampler objects (Repeat + ClampToEdge) so
@ -1538,14 +1535,21 @@ public sealed class GameWindow : IDisposable
_worldState = new AcDream.App.Streaming.GpuWorldState(wbSpawnAdapter, wbEntitySpawnAdapter);
}
_staticMesh = new InstancedMeshRenderer(_gl, _meshShader, _textureCache, _wbMeshAdapter);
// Task 15: _meshShader is null when bindless is missing; skip constructing
// _staticMesh in that case. All downstream _staticMesh usages are already
// null-safe (null-conditional operators or explicit null guards).
if (_meshShader is not null && _textureCache is not null)
_staticMesh = new InstancedMeshRenderer(_gl, _meshShader, _textureCache, _wbMeshAdapter);
if (AcDream.App.Rendering.Wb.WbFoundationFlag.IsEnabled
&& _wbMeshAdapter is not null && _wbEntitySpawnAdapter is not null
&& _bindlessSupport is not null)
{
// _meshShader is non-null here: the _bindlessSupport guard implies
// the if(_bindlessSupport is not null) block above ran and assigned it.
// _textureCache is always non-null (assigned unconditionally above).
_wbDrawDispatcher = new AcDream.App.Rendering.Wb.WbDrawDispatcher(
_gl, _meshShader, _textureCache, _wbMeshAdapter, _wbEntitySpawnAdapter, _bindlessSupport);
_gl, _meshShader!, _textureCache!, _wbMeshAdapter, _wbEntitySpawnAdapter, _bindlessSupport);
}
// Phase G.1 sky renderer — its own shader (sky.vert / sky.frag)
@ -1555,7 +1559,7 @@ public sealed class GameWindow : IDisposable
Path.Combine(shadersDir, "sky.vert"),
Path.Combine(shadersDir, "sky.frag"));
_skyRenderer = new AcDream.App.Rendering.Sky.SkyRenderer(
_gl, _dats, skyShader, _textureCache, _samplerCache);
_gl, _dats, skyShader, _textureCache!, _samplerCache);
// Phase G.1 particle renderer — renders rain / snow / spell auras
// spawned into the shared ParticleSystem as billboard quads.