From 93ebd9e4331cbee50d1e02cdafd27bf75cf587d2 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 8 May 2026 20:15:06 +0200 Subject: [PATCH] phase(N.5) Task 6: GameWindow capability detection + plumb BindlessSupport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detects ARB_bindless_texture + ARB_shader_draw_parameters at startup when WbFoundationFlag is enabled. Stores BindlessSupport on GameWindow and passes it to TextureCache so the parallel Texture2DArray upload path is available to future bindless callers. Mesh shader load remains mesh_instanced for now — Task 10 swaps to mesh_modern after Tasks 7-9 rewire the dispatcher to consume the bindless + SSBO + indirect machinery. Capability missing → BindlessSupport stays null → TextureCache runs without the bindless path → legacy callers (StaticMeshRenderer, InstancedMeshRenderer, ParticleRenderer, current WbDrawDispatcher draw loop) are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/AcDream.App/Rendering/GameWindow.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index 1048e02..6ba12a7 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -33,6 +33,10 @@ public sealed class GameWindow : IDisposable private AcDream.App.Rendering.Wb.WbMeshAdapter? _wbMeshAdapter; private AcDream.App.Rendering.Wb.EntitySpawnAdapter? _wbEntitySpawnAdapter; private AcDream.App.Rendering.Wb.WbDrawDispatcher? _wbDrawDispatcher; + /// Phase N.5: ARB_bindless_texture + ARB_shader_draw_parameters + /// support. Non-null only when both extensions are present and WbFoundation + /// is enabled. Passed to TextureCache and (later) WbDrawDispatcher. + private AcDream.App.Rendering.Wb.BindlessSupport? _bindlessSupport; private SamplerCache? _samplerCache; private DebugLineRenderer? _debugLines; // K-fix4 (2026-04-26): default OFF. The orange BSP / green cylinder @@ -1419,7 +1423,26 @@ public sealed class GameWindow : IDisposable _heightTable = heightTable; _surfaceCache = new Dictionary(); - _textureCache = new TextureCache(_gl, _dats); + // N.5: detect ARB_bindless_texture + ARB_shader_draw_parameters when WB + // foundation is on. Store the BindlessSupport for TextureCache + future + // WbDrawDispatcher. Mesh shader load stays as mesh_instanced for now — + // Task 10 swaps to mesh_modern after the dispatcher is rewired. + if (AcDream.App.Rendering.Wb.WbFoundationFlag.IsEnabled + && AcDream.App.Rendering.Wb.BindlessSupport.TryCreate(_gl, out var bindless) + && bindless is not null) + { + if (bindless.HasShaderDrawParameters(_gl)) + { + _bindlessSupport = bindless; + Console.WriteLine("[N.5] modern path capabilities present (bindless + ARB_shader_draw_parameters)"); + } + else + { + Console.WriteLine("[N.5] GL_ARB_shader_draw_parameters not present — modern dispatch path will not activate"); + } + } + + _textureCache = new TextureCache(_gl, _dats, _bindlessSupport); // Two persistent GL sampler objects (Repeat + ClampToEdge) so // the sky pass can pick wrap mode per submesh without mutating // shared per-texture wrap state. See SamplerCache + the