# RASM Code Review — October 2026

This review covers the whole repository as of `feat/pbr` @ `61d8028`. Every finding has an ID that the [development plan](development_plan.md) refers to.

| Prefix | Meaning |
|---|---|
| **B** | Bug: wrong behaviour, a crash, or undefined behaviour |
| **D** | Design or architecture issue |
| **P** | Performance |
| **C** | Code health and refactoring |

**Confidence.** *Confirmed* means the failure follows deterministically from the code as read. *Likely* means it follows from the code plus an assumption about driver or library behaviour; verify it at runtime before fixing.

---

## 1. Folder structure

This section describes the layout as of `6efdf48` and lists only the problems that remain.

### Current layout

```
CMakeLists.txt                  top level: options (RASM_ENABLE_AVX2, RASM_BUILD_EXAMPLES), add_subdirectory(...)
CMakePresets.json               x64-debug/release, macOS, macOS-release, macOS-Xcode
cmake/RasmExample.cmake         rasm_add_example()
include/rasm/                   public API (still includes third-party and private headers, see §1.1)
  rasm.h                        umbrella header
  engine.h scene.h entity.h transform.h camera.h light.h material.h mesh.h
  handle.h types.h window.h
  render/                       low-level API: renderContext.h, renderGraph.h, resource.h
src/
  CMakeLists.txt                target `rasm`, alias `rasm::rasm`
  engine.cpp                    frame loop (not yet split into renderer/)
  core/                         handle, utils
  platform/                     platform.h, sdlPlatform.cpp (SDL3 window + input), headlessPlatform.cpp
  assets/                       material.cpp (incl. glTF material import), mesh.cpp (mesh API, async loads),
                                  meshImport (glTF + OBJ parsing), texture.cpp (texture loads)
  scene/                        scene, entity, transform, camera, light
  renderer/                     gpuScene (GPU scene tables, drawScene), gpuTable, geometryPool, renderGraph, shaderCompiler,
                                  uberMaterialTypes.h (shader ABI)
  rhi/                          device.h (backend-neutral interface), renderContext.cpp (handle tables)
    vulkan/                     vulkanDevice, vulkanCommandBuffer, vulkanQueue, vulkanSwapchain, vulkanTypes.h, vulkanUtils
  thirdparty_impl.cpp           the only *_IMPLEMENTATION defines
shaders/
  lib/                          core.slang (GPU structs), pbr.slang, unlit.slang
  passes/                       rasm.slang
examples/
  CMakeLists.txt
  00_hello_scene/ 01_render_graph/ 02_gltf/
tools/compile-shaders.bat       offline compile check only (output unused)
assets/models/{gltf,obj}/       sample models (binary, in plain git)
docs/
```

### Problems

1. **Public headers expose implementation details (`D2`).** *Fixed 2026-11-01:* public headers include nothing from `src/` and no third-party header except glm. `RenderContext` keeps its Vulkan state in a private `Impl`, and `Engine` holds `ShaderCompiler` through a forward declaration. `src/`, the backend libraries and the tinygltf/stb include paths are PRIVATE. The original finding follows.
   - `engine.h` includes the private `renderer/shaderCompiler.h` and `renderer/uberMaterialTypes.h`; `render/renderContext.h` includes `rhi/vulkan/vulkanTypes.h` and `rhi/vulkan/vulkanContext.h` (→ vk-bootstrap, VMA).
   - `types.h` and `mesh.h` include `tiny_gltf.h`, `window.h` includes `vulkan/vulkan.h`, and `render/renderGraph.h` includes `spdlog/spdlog.h`.
   - Because of this, `src/` is temporarily a PUBLIC include directory, and Vulkan, VMA, vk-bootstrap, Slang, glm, Tracy, spdlog and the tinygltf/stb include paths are all linked PUBLIC. Applications still compile against the whole backend.
   - This keeps compiles slow, makes the backend impossible to swap, and blocks a stable API/ABI.
2. **Some files still mix concerns.** *Partly fixed 2026-11-04:* `prepareScene` and `drawScene` moved to `renderer/gpuScene.cpp`, glTF/OBJ parsing to `assets/meshImport.cpp`, texture loading to `assets/texture.cpp`, and `VulkanQueue` to its own pair. Still open:
   - `assets/material.cpp` holds both the material API and glTF material import;
   - `engine.cpp` (frame loop and pipeline creation) still sits at the root of `src/`.
3. **Shaders are found through the working directory (`D11`).** *Fixed 2026-11-01:* shaders load from `EngineConfig::shaderDir`, by default a `shaders/` folder beside the executable, and `EngineConfig::assetRoot` locates assets. The original finding follows. Paths are cwd-relative (`./shaders/passes/...` in `material.cpp`/`scene.cpp`, `cwd/shaders/lib` in `shaderCompiler.cpp`), so the examples only work when run from the repo root (not from the build directory, an IDE, or an installed app).
4. **No install/export.** *Fixed 2026-11-01:* `cmake/RasmInstall.cmake` installs the library, public headers and shaders and exports `rasm::rasm`, so `find_package(rasm)` works from an install tree or a build tree. The original finding follows. There is no `install()`/`export()`, so `find_package(rasm)` does not work.
5. **No `tests/` and no CI** (plan phase 1.5). *Partly resolved 2026-11-01:* `tests/` has a doctest target run through CTest. CI is still missing.
6. **Binary assets live in plain git.** The glTF/OBJ sample models are committed directly, so the clone grows with every asset added.

### What is left of the target layout

Compared with the current layout, the target still needs:

```
include/rasm/                   PUBLIC API ONLY — no third-party or src/ headers (D2)
  config.h                      EngineConfig incl. assetRoot / shader dir
  render/rhi.h                  device-agnostic types replacing the Vk structs in RenderContext::Impl (D1)
src/
  renderer/                     + frame loop and pipeline creation from engine.cpp,
                                  passes (forward, culling, shadow, post)
  assets/gltf/ obj/ image/      split loaders out of material.cpp / mesh.cpp
  rhi/metal/ d3d12/ webgpu/     future backends
shaders/
  lib/                          + brdf, color, bindings modules as they are factored out
  passes/                       + cull, shadow, tonemap ...
  materials/                    material evaluation modules
tests/                          unit tests (handles, desc hashing, glTF import) + image tests
tools/                          + asset download script
assets/                         keep small; large models via Git LFS or a download script
```

Next steps, in order:
- Keep moving code incrementally: move a file only while you are working on it, and change the CMake lists in the same commit.
- Add CI that builds the presets and runs `rasm_tests` (phase 1.5).

---

## 2. Bugs

### High severity

**B1 — Creation dedup aliases resources that must be distinct.** *Fixed 2026-10-26:* buffer, texture, descriptor-pool and descriptor-set dedup has been removed. Shader and pipeline dedup is now keyed on full state; shader equality used to compare the SPIR-V *pointer*. glTF images are cached per model by image index and color space. Resize destroys the old depth textures. The original finding follows.
`RenderContext::create{Buffer,Texture,…}` returns an existing handle when it has seen an equal `ResourceDesc` before ([renderContext.cpp:137-141](../src/rhi/renderContext.cpp#L137-L141), [renderContext.cpp:175-179](../src/rhi/renderContext.cpp#L175-L179)). This bites in several places:
- `prepareScene` creates `megaModelDataBuffer[i]` and `sceneDataBuffer[i]` in a loop with an identical desc ([scene.cpp:204-208](../src/scene/scene.cpp#L204-L208), [:229-233](../src/scene/scene.cpp#L229-L233)). Both frame slots get the **same** buffer, so the CPU rewrites `SceneData`/`Modeldata` while the GPU may still be reading them for the previous frame. That undoes the frames-in-flight fix in `27bb89a`.
- Render-target attachments per frame slot alias each other ([renderContext.cpp:590-593](../src/rhi/renderContext.cpp#L590-L593)).
- Two OBJ meshes with the same vertex and index counts share one buffer, and the second upload overwrites the first ([mesh.cpp:183-195](../src/assets/mesh.cpp#L183-L195)).
- glTF textures are named by `image.uri`, which is empty for images embedded in `.glb` files ([material.cpp:183](../src/assets/material.cpp#L183)). Two embedded images of the same size and format therefore become one texture, and the last upload wins.
- Even a "correct" cache hit re-uploads the texture and takes a new bindless slot (see B7).

*Fix:* remove desc-based dedup from buffer and texture creation. Keep dedup only for immutable objects (samplers, pipeline layouts, pipelines), keyed on their *complete* state. Asset-level caching (by path, or by model + image index) belongs in the asset layer.

**B2 — The projection uses the OpenGL depth range [-1, 1].** *Fixed 2026-10-26:* `GLM_FORCE_DEPTH_ZERO_TO_ONE` is now a PUBLIC compile definition of the `rasm` target in [src/CMakeLists.txt](../src/CMakeLists.txt), and the define in `engine.cpp` was removed. Reversed-Z with an infinite far plane followed on 2026-11-04 (plan 1.4, architecture.md §8 and §11), so the step suggested at the end of the fix is done. The original finding follows.
- `#define GLM_FORCE_DEPTH_ZERO_TO_ONE` sits at [engine.cpp:9](../src/engine.cpp#L9), *after* `engine.h` has already included glm through `rasm/types.h`, so it has no effect. `camera.cpp` never sees it either.
- `glm::perspective`/`glm::ortho` therefore emit z in [-1, 1]. Vulkan clips z < 0, which moves the effective near plane to ≈ 2·n·f/(n+f) (≈ 0.2 for n = 0.1, f = 32) and wastes half the depth range.

*Fix:* set `GLM_FORCE_DEPTH_ZERO_TO_ONE` (and `GLM_FORCE_RADIANS` if wanted) with `target_compile_definitions(rasm PUBLIC ...)`, or call `glm::perspectiveRH_ZO` explicitly. After that, move to reversed-Z (see the plan, phase 1).

**B3 — Debug-name calls without the debug-utils extension.** *Fixed 2026-10-27:* `initInstance` now enables `VK_EXT_debug_utils` whenever the instance reports it, independent of validation, and all naming goes through `VulkanContext::setObjectName`, which does nothing when the extension is not enabled. The original finding follows.
- `setDebugUtilsObjectNameEXT` is called for every buffer, image, view, shader and pipeline ([vulkanContext.cpp:232](../src/rhi/vulkan/vulkanContext.cpp#L232), [:425-426](../src/rhi/vulkan/vulkanContext.cpp#L425-L426), [:456](../src/rhi/vulkan/vulkanContext.cpp#L456), [:644](../src/rhi/vulkan/vulkanContext.cpp#L644)).
- `VK_EXT_debug_utils` is enabled only when validation is requested *and* available ([vulkanContext.cpp:1374-1380](../src/rhi/vulkan/vulkanContext.cpp#L1374-L1380)).
- With `enableValidation = false`, or on a machine without the SDK layers, the dispatch-table entry is most likely null, so the first `createBuffer` crashes. Every release build is affected.

*Fix:* always enable `VK_EXT_debug_utils` when it is available (it is cheap), and skip naming when it is not.

**B4 — Swapchain acquire and present results are ignored; the fence is reset before acquire.** *Fixed 2026-10-27:* acquire, present and recreation return `SwapchainStatus`. `beginFrame` waits on the fence, acquires, and resets the fence only after a successful acquire. It returns `false` to skip the frame on `OUT_OF_DATE`. `SUBOPTIMAL` from acquire and `SUBOPTIMAL`/`OUT_OF_DATE` from present set `swapchainOutOfDate`, and the swapchain is recreated at the start of the next frame. The original finding follows.
- `beginFrame` waits on and resets `inFlightFence`, then ignores the result of `acquireNextImage` ([engine.cpp:310-326](../src/engine.cpp#L310-L326)). `present` failures are only logged ([vulkanContext.cpp:1162-1168](../src/rhi/vulkan/vulkanContext.cpp#L1162-L1168)).
- On `VK_ERROR_OUT_OF_DATE_KHR` the image-acquired semaphore is never signaled, yet the frame still submits work that waits on it. That is invalid usage and can hang.
- `VK_SUBOPTIMAL_KHR` is treated as an error.

*Fix:* acquire first. On `OUT_OF_DATE`, recreate the swapchain and skip the frame. Reset the fence only after a successful acquire. Recreate on `SUBOPTIMAL` or `OUT_OF_DATE` from present.

**B5 — Resize and minimize can destroy the swapchain, and leak.** *Fixed 2026-10-27:* frames are skipped while the window is minimized or 0×0, and `pollEvents` blocks for events instead of spinning. `VulkanContext::recreateSwapchain` keeps the old swapchain when the surface extent is 0 (`OUT_OF_DATE`). When creation fails it destroys the retired swapchain and leaves none, so acquire reports `OUT_OF_DATE` and the engine retries. `get_images`/`get_image_views` are checked. `RenderContext::recreateSwapchain` drops the old swapchain image handles from `textureCache`. The depth textures were already destroyed on resize (`B1`). The original finding follows.
- Minimizing gives a 0×0 extent, so swapchain creation fails. `_recreate_swapchain` destroys the old swapchain anyway ([vulkanContext.cpp:1561-1568](../src/rhi/vulkan/vulkanContext.cpp#L1561-L1568)), `Engine::recreateSwapchain` ignores the failure ([engine.cpp:454](../src/engine.cpp#L454)), and the next acquire uses a destroyed swapchain.
- `get_images().value()` is called unchecked ([vulkanContext.cpp:862-863](../src/rhi/vulkan/vulkanContext.cpp#L862-L863)).
- Every resize leaks the previous depth textures ([engine.cpp:471-482](../src/engine.cpp#L471-L482)) and leaves stale swapchain `TextureVKHandle`s in `textureCache` ([renderContext.cpp:658-664](../src/rhi/renderContext.cpp#L658-L664)).

*Fix:* skip rendering while the extent is 0. Recreate only on success. Destroy the old depth textures and drop the old swapchain image handles.

**B39 — Drawing a point cloud scene through `render(views)`, then a scene with weighted and glyph draws, loses the device.** *Fixed 2026-11-27:* the point resolve (`resolveFrag` in `shaders/passes/pointRaster.slang`) read out of the point buffer in lanes whose pixel had no point. `discard` demotes a lane to a helper (`B33`), and a demoted lane runs the rest of the shader and does its loads: with its word 0, it read the point of instance row 0 as if that row were a point chunk. In the export tests' order that row was a mesh of the weighted scene (geometry 1, vertex offset 24), so its "chunk header" was the words at offset 24 of the point pool (the weighted scene's glyph chunk), and with the shell's material words as the point style, the color offset it gave sent `getPointBaseColor`'s read far past the point buffer: an access violation on lavapipe, a page fault (device lost) on the RTX 3060 when the address fell on no page. When row 0 is a point chunk, or the words it finds there lead to no far read (the points test run alone), the reads stay in the buffer, which is why the order mattered. Found by bisecting GPU-AV's safe mode (`VK_LAYER_GPUAV_SAFE_MODE` with `gpuav_shaders_to_instrument`): instrumenting `pointResolve.frag` alone stops the crash, which GPU-AV does not report because the lane that faults is a helper. Now a pixel that ends empty returns right after its `discard`, and a helper lane of a quad on the rect's edge, outside the rect (words not cleared this frame, and past the last row outside the buffer), reads no word. No pixel was ever wrong: a demoted or helper lane writes nothing. Tests `export_points` and `export_points_single` (after `export_weighted`, which crashes on the old shader). The original finding follows. Found 2026-11-27 while adding the export image tests; it is on main (1c8249c) without any export. In `rasm_image_tests`, a test that draws `buildPoints`' scene with `Engine::render(&view, 1)` (one view: the test camera, no bloom, no anti-aliasing) followed by a test that draws `buildWeighted`'s scene (weighted shells, an additive glow, a weighted glyph chunk) with the same camera, through `render(views)` or through its own graph, ends in `Failed to submit command buffer. Error: Device Lost` on an RTX 3060 (Release and Debug, validation on, no message before it) and a segfault on lavapipe. The other order does it too, and three `render(nullptr, 0)` frames between them do not help. Points then labels, helmet, glyphs, grid or terrain, and labels or glyphs then weighted, are fine; the points test drawn by its own graph followed by the weighted one is fine. GPU-AV reports nothing before the loss, so it is likely a dispatch or draw that runs far too long (a count read from a stale buffer). Steps: add `{.name = "p", .build = buildPoints, ...}` and `{.name = "w", .build = buildWeighted, ...}` tests that render through `Engine::render`, run `rasm_image_tests --scenes p,w`. Fix direction: capture the weighted scene's first frame after the points view (`frame-debug`), and look at what the point raster and the glyph cull leave behind for the next scene view in the same slot (the shared `cullStats`, the point batch header, the glyph cull header). The export image tests leave the point scene out until it is fixed. *Confirmed.*

### Medium severity

**B6 — Gaps in glTF geometry import.** *Fixed 2026-10-27:* `extractGLTFRaws` reads every attribute and index buffer through one accessor reader. It handles byte strides, accessors without a buffer view, sparse accessors, and normalized or integer components (`KHR_mesh_quantization`). It bounds-checks the accessor against its buffer view and the buffer view against its buffer. Non-indexed primitives get generated indices, which the smooth-normal path now shares. Triangle strips and fans become triangle lists. Points and lines are skipped with a warning. Primitives with a missing or invalid `POSITION`, invalid indices, or indices out of range are also skipped with a warning. An invalid optional attribute is ignored with a warning. `TANGENT` is imported and used for normal mapping (see `B19`). The original finding follows.
- Primitives without indices get an empty index list and are never drawn. Indices are filled only when `primitive.indices > -1` ([mesh.cpp:336-362](../src/assets/mesh.cpp#L336-L362)), and the smooth-normal path generates indices but does not keep them.
- `primitive.mode` is ignored, so lines, points and strips are drawn as triangle lists.
- Accessors are assumed to be tightly typed `float`. This breaks `KHR_mesh_quantization`, normalized integer UVs, and sparse accessors.
- `ByteStride()` returning -1 and `bufferView == -1` are not checked.
- The tangent attribute is ignored. That is acceptable for now because tangents are reconstructed in the shader.

**B7 — glTF materials and textures are duplicated for every primitive.** *Fixed 2026-10-27:* `loadMaterial` caches materials per model by material index, next to the per-model image cache from `B1`. Both live in a `GltfImportCache` that `processGLTF` creates for each import. A global texture cache is still open. The original finding follows.
- `extractGLTFRaws` calls `loadMaterial` for each primitive ([mesh.cpp:365-366](../src/assets/mesh.cpp#L365-L366)). Each call creates a new material and uploads every one of its textures again, taking new bindless slots ([material.cpp:155-194](../src/assets/material.cpp#L155-L194)).
- A model whose 50 primitives share one material consumes 50 materials and up to 250 bindless slots. The limits are 256 materials and 1024 slots, so medium-sized scenes fail.

*Fix:* add a per-model cache from material index to `MaterialHandle` and from image index to `TextureHandle` (and later a global texture cache).

**B8 — Missing materials crash or render black.** *Fixed 2026-10-27:* the engine creates `defaultMaterial` (the glTF default material) at startup, and `getMaterial` resolves invalid handles to it instead of throwing. Primitives without a material still prefer their entity's material. The original finding follows.
- `getMaterial` checks only `index >= size()` and throws ([material.cpp:241-247](../src/assets/material.cpp#L241-L247)). An OBJ entity without a material, in a program that never created a material, throws an uncaught `std::runtime_error` from `prepareScene` ([scene.cpp:282](../src/scene/scene.cpp#L282)).
- If other materials do exist, an invalid handle (index 0) returns the zeroed slot 0. A glTF primitive without a material then renders with base color 0 (black) instead of the glTF default material (white, metallic 1, roughness 1).

*Fix:* create a default material at startup and resolve invalid handles to it.

**B9 — `MaterialType::UNLIT` references a missing shader.** *Fixed 2026-10-31:* `gfx::Modeldata` now carries a `MaterialId` that `fragMain` branches on, so `UNLIT` is a path in the uber shader (`Unlit()` in `unlit.slang`). The legacy path uses `basic.slang` for it, which multiplies the first texture by the base color factor and handles a missing texture. glTF materials with `KHR_materials_unlit` import as `UNLIT` and upload only their base color texture. The original finding follows.
`createMaterial(UNLIT)` reads `./shaders/passes/unlit.slang` ([material.cpp:65](../src/assets/material.cpp#L65)), which does not exist. The file read fails and later compilation fails.

**B10 — The render-target path is broken.** *Fixed 2026-11-01:* `endPass` moves the color attachment to `SHADER_READ_ONLY_OPTIMAL` behind a barrier that waits for its color writes, depth attachments are no longer sampled or in the bindless array, and `beginPass` sizes the viewport from the render target. `B1` had already removed the aliasing. In `01_render_graph` the overlay reads the render target through this flow. `transitionImageLayout` now takes its source scope from the old usage instead of assuming render-target writes, so a target rendered again after being sampled waits for those reads, and usages it has no scope for are rejected. Validation does not guard the fix: on SDK 1.4.363, GPU-assisted validation with `VK_LAYER_GPUAV_IMAGE_LAYOUT=1` did not report the old layout either. The original finding follows.
- The attachments for each frame slot alias each other (B1).
- After rendering, the color attachment is never transitioned to `SHADER_READ_ONLY_OPTIMAL`: the barrier is commented out ([engine.cpp:416-423](../src/engine.cpp#L416-L423)). The bindless descriptor promises that layout ([vulkanContext.cpp:898](../src/rhi/vulkan/vulkanContext.cpp#L898)), so `01_render_graph` samples an image that is still in `COLOR_ATTACHMENT_OPTIMAL`. The default validation layers do not report this, because bindless (partially bound, update-after-bind) descriptors are only layout-checked with GPU-assisted validation.
- `beginPass` sets the viewport and scissor from the *window* size, not the render-target size ([engine.cpp:407-408](../src/engine.cpp#L407-L408)).
- The depth attachment of each RT also goes into the bindless array as a combined depth/stencil image.

**B18 — `ResourceDesc` is not zero-initialized.** *Fixed 2026-10-26:* the constructor now zeroes the whole union and `type` has a default initializer. The original finding follows.
- `ResourceDesc() {}` is a user-provided constructor ([resource.h:213](../include/rasm/render/resource.h#L213)), so `ResourceDesc desc{}` does **not** zero the union.
- Fields that a caller doesn't set (`buffer.offset`, `vertexIndexBuffer.*`, and texture fields when you use the buffer variant) are indeterminate. `operator==` and `ResourceDescHash` read them, so dedup (B1) also depends on stack garbage.

*Fix:* zero the storage in the constructor (`std::memset` the union, or give each variant default member initializers). Better, replace the union with `std::variant` or separate desc types (D5).

**B19 — The reconstructed tangent frame inverted the normal-map green channel.** *Fixed 2026-10-27:* `getNormalFromMap` now points the bitangent toward decreasing v (−dP/dv). glTF puts the UV origin at the image's top-left and normal maps store +Y as up in the image, so that is the direction of `cross(N, T) · w` for authored tangents. Before the fix, the derivative path aligned B with +dP/dv, so every normal map without `TANGENT` data was lit with Y flipped. This came to light when `TANGENT` import landed. On a test mesh with standard UVs, mirrored UVs and a mirroring node, and on the authored tangents of `coffee-room`, the two frames now agree (dot > 0.999). Before the fix they disagreed everywhere.

**B20 — Shader dedup keys pointed at freed SPIR-V.** *Fixed 2026-11-01:* `RenderContext::createShader` now keeps its own copy of the SPIR-V in `shaderSources`, and the cache key points at that copy. The bug came from `B1`, which made shader equality compare the code instead of the pointer. `shaderDescCache` still stored the caller's pointer into a temporary blob, so every later lookup that reached `operator==` ran `memcmp` on freed memory. This crashed intermittently with an access violation in any application that compiled the same shader twice, such as one that prepared a second scene. In a debug build, 5 of 30 runs crashed before the fix and 0 of 60 after it.

**B21 — Non-FIFO present modes crash `vkDestroyDevice` on NVIDIA.** *Worked around 2026-11-01; root cause unknown:* both swapchain builders now request `VK_PRESENT_MODE_FIFO_KHR`, so the frame rate is capped at the display's refresh rate. With vk-bootstrap's default of MAILBOX, closing a window that fills the screen raised an access violation inside `nvoglv64.dll` (driver 610.296, RTX 3060) during `vkDestroyDevice`. It depends on the window size, not on the example or on render targets: `00_hello_scene` crashes at 1920x1080 on a 1920x1080 display, and `01_render_graph` does not crash at 720x480. IMMEDIATE crashes too, and so does MAILBOX capped to about 60 fps, so it is not a frame-rate problem. Waiting 500 ms before teardown, destroying the swapchain before the semaphores, skipping the startup swapchain recreation and disabling validation do not help, and validation reports nothing. FIFO gave 0 crashes in 30 runs, against 40–100% per batch with the others. `vkcube` does not crash in any present mode at the same size, so the engine does something it does not, and that difference has not been found. The trigger is NVIDIA's overlay: with it turned off in the NVIDIA App, MAILBOX at 1920x1080 gave 0 crashes in 16 runs. `nvspcap64.dll` (NVIDIA's capture hook) stays loaded either way, but the overlay processes do not run. Keep FIFO while the overlay can be on, because it is on by default for many users, and revisit this before adding a way to turn vsync off.

**B22 — `Transform::rotate` did nothing on a default transform.** *Fixed 2026-11-01:* `Transform::rotation` now defaults to `glm::identity<glm::quat>()`. It used `glm::quat()`, which value-initializes to all zeros, not to identity. A zero quaternion passes for identity in `q * v` and `mat4_cast`, so nothing looked wrong, but any composition stays zero. Every entity or camera that didn't set a rotation was affected: the spin calls in `00_hello_scene` and `02_gltf` were no-ops, and the first trackball drag of such a camera was lost. Those objects now spin.

**B25 — Destroying a texture leaves its bindless slot behind.** *Fixed 2026-11-22 (`D4`):* a texture holds its slot in `TextureTable::slots`, and `RenderContext::destroyTexture` gives the texture and its slot to the release queue ([renderContext.cpp:1222](../src/rhi/renderContext.cpp#L1222)), which frees them once the frame fences and the upload fence pass the frames that may sample them; `updateBindlessDescriptorSet` takes freed slots first ([renderContext.cpp:1436](../src/rhi/renderContext.cpp#L1436)). `Engine::destroyTexture` removes the texture from every material and rewrites their rows first ([texture.cpp:137](../src/assets/texture.cpp#L137)). `bindlessTextureIndexMap` is gone. `examples/17_streaming` pushes 1584 textures through the 1024 slots in 60 frames, with GPU-assisted validation clean. The original finding follows. `RenderContext::destroyTexture` ([renderContext.cpp:1040-1054](../src/rhi/renderContext.cpp#L1040-L1054)) destroys the image and forgets its layout, but does not touch the texture's bindless slot or its entry in `bindlessTextureIndexMap`. A material row that still holds that slot samples a descriptor whose image view is destroyed, which is undefined behaviour and can be a device lost. The engine's own calls are safe: on resize it rewrites the depth texture's slot right away, and `destroyAttachments` erases a render target's map entries, so nothing samples the old slots again (they are lost, not reused). An application that calls `destroyTexture` on a texture a material still uses hits it. Part of the slot lifetime that `D4` asks for. *Confirmed.*

**B33 — Samples after a cut-out's `discard` had undefined derivatives.** *Fixed 2026-11-22:* the Slang session adds the `spvDemoteToHelperInvocation` capability ([shaderCompiler.cpp](../src/renderer/shaderCompiler.cpp), `getTargetDesc`), so every `discard` compiles to `OpDemoteToHelperInvocation`, and the device enables `shaderDemoteToHelperInvocation` (core in Vulkan 1.3). A demoted lane writes nothing but stays in its 2x2 quad as a helper. The original finding follows. Slang compiled `discard` to `OpKill` for profile `spirv_1_4`. The 1-sample MASK `fragMain` ([rasm.slang:350](../shaders/passes/rasm.slang#L350)) discards below the cutoff and then samples the material's other textures with implicit LOD; a killed lane leaves its quad, so those samples' derivatives, and their mip, were undefined at the cut-out's edges. The RTX 3060 drew the same image either way (max diff 0 at 1920x1080 in `sponza` and `alpha_modes`), so it was invisible there. lavapipe (Mesa 25.3.6, 26.2.7, 26.3.0) crashes on it: the golden-image tests `alpha_modes` and `sponza` stopped with an access violation in its JIT code, a null texture handle for a lane while sampling the bindless array (`get_sample_function` in `lp_texture_handle.c`). A kill that never runs did not crash, nor did the same model with alpha-to-coverage (`msaa4`), which has no `discard`. The demote costs nothing measurable: `Scene 1` of `sponza` at 1920x1080 on the RTX 3060, Release, 1.342 ms with kill and 1.336 to 1.346 ms with demote. *Confirmed* by the lavapipe crash and its fix. The crash itself is a Mesa bug: a kill followed by a descriptor-indexed sample should give a wrong mip, not a null handle; the issue text is in the image-tests pull request.

**B35 — A draped road wider than a terrain cell was shredded at its edges.** *Fixed 2026-11-25:* `LineShape::drapeWidth` (metres; C API 1.9 `drape_width`) builds a draped line at its whole width: `pushDrapedLine` ([vector.cpp:375](../src/scene/vector.cpp#L375)) makes its band on the flat grid with `pushLine`, cuts each triangle on the grid (`cutTriangle`) and lifts each corner (`liftOnGrid` on a lattice of 2⁻²⁰ cells), so every piece lies on one terrain triangle. Its `VECTOR_KIND_BAND` vertices are where they are drawn: the shader ([vector.slang:244](../shaders/lib/vector.slang#L244)) only moves a corner out by its smooth edge's pixel, in its own ground's plane, and draws it nearer by as much ([vector.slang:267](../shaders/lib/vector.slang#L267)); it draws the built width whatever the material says, so a new width takes a rebuild. A line or point whose width is in pixels is drawn nearer by its half width in the world (a few pixels' worth), so a road in pixels or a marker on a slope is not cut either (the "Harbour" marker of `26_picking`'s map was half hidden). `examples/24_map_tiles` and `examples/26_picking` drape their roads so, and `26_picking` picks both edges of its road from above (12 checks, which hit the terrain or a point off the ground with only the middle draped); `tests/vectorTests.cpp` checks every piece's middle is on the ground and a straight band's area; image tests `draped`, `draped_msaa4`, `draped_taa`. The original finding follows.
- `addVectorLines` with a `VectorPlacement::drapeTile` cut a line's middle on the tile's grid and lifted it, with each point's up the normal of the triangle under it. The shader then spread the width in that plane (`getVectorVertex`, `VECTOR_GROUND`). A band wider than a cell reaches over the next triangles; where the ground across the road is concave (a valley's floor, the inside of a bend) they rise above the plane, by 0.1 to 0.3 m for the 4 m road on 2 m cells of `examples/26_picking`, against a depth bias of 1/4096 of the distance (2 cm at 80 m). The terrain covered the road in wedges, in the perspective view and in the map from above alike, with the camera still: the user's "shredded road". The 16 m roads on the 8 m cells of `examples/24_map_tiles` showed mostly their casing. The same road 0.8 m wide had no gaps.

**B36 — Labels were cut glyph by glyph by the depth.** *Fixed 2026-11-25:* each label is shown or hidden whole, by its anchor. `placeViewLabels` ([gpuScene.cpp:2013](../src/renderer/gpuScene.cpp#L2013)) gives each slot its anchor's pixel and the depth it must be in front of (its own, moved toward the camera by `LABEL_DEPTH_PIXELS`, 4, pixels' size there); the `Label Depth` compute pass ([gpuScene.cpp:1232](../src/renderer/gpuScene.cpp#L1232), [labelDepth.slang](../shaders/passes/labelDepth.slang)), after the view's last draw pass and before `Transparent`, tests it against the depth at the 3 × 3 pixels around it (each pixel's farthest sample with MSAA), steps a fade per slot kept across frames toward the answer and multiplies the slot's alpha by it. The glyphs are then drawn at the near plane. An `OVERLAY` label is always shown. `examples/26_picking` picks the left half of three names in its map view (they hit the terrain before); image tests `draped` (names on hills, across a post, behind a box) and the changed `labels` goldens, where "Behind the box" is now hidden whole. The original finding follows.
- A glyph corner took the depth of its anchor, or of the ground's plane at the anchor under its pixel when that was nearer (`getGroundPoint`), and each pixel was depth tested. Text is flat on the screen and the world behind it is not: where the ground beside the anchor rises above that plane (a hill), or a post or a box's edge crosses the text, part of the label failed the test. In `examples/26_picking`'s map view, from above, "North Gate" showed as "N…ate", "Old Well" as "Well", "Harbour" as "…ar", with the camera still; drawn as overlays they were whole. While the camera moves the cut moves with it. The same in `examples/27_cad_views` (branch `feat/orthoGrid`): "6.00 m" read "0 m" behind a box.

### Low severity

**B37 — A pick of a point whose chunk is gone keeps `PICK_HIT_FEATURE`.** In `readPicks`, the point branch clears `PICK_HIT_FEATURE` when the mesh's `pointOrder` cannot map the index (the chunk's mesh destroyed while the pick was in flight), but the next line, `hit.flags = group.nearest.flags` ([picking.cpp:699](../src/renderer/picking.cpp#L699)), writes the flags again: the hit says it has a feature, and the feature is 0, so an application selects the chunk's point 0. Fix direction: assign `group.nearest.flags` first, then mask it. *Confirmed* by reading, from the glyph work's review.

**B38 — On lavapipe a scene with no light and no environment crashes in a shader.** *Fixed 2026-11-27:* the light loops of `shadePBR` (`shaders/lib/pbr.slang`) index `SceneData::sceneLightsPtr`, which stayed null in a scene with no light (and in a frame whose light list could not upload). The loops' counts are 0, but lavapipe runs a loop's body once with no lane on, and loads a uniform address there from the first lane anyway: cdb shows `mov rdx,[rdi+110h]` (offset 272, `sceneLightsPtr`) then `movsxd rdx,dword ptr [rdx+rax*4]` with rdx 0. GPU-AV's safe mode with `gpuav_buffer_address_oob` stops it, without a report (the lane is off); `rasm.frag` alone instrumented is enough; a `printf` shows the counts at 0. With the global and local light loops cut out it does not crash, and the global loop alone brings it back. The environment and the shadows have nothing to do with it (a scene with the environment and no light crashes, one with a light and no shadow does not). Now `writeSceneLights` points `sceneLightsPtr` at the light table before it knows whether the scene has lights, so the pointer is never null, and `createGpuLights` writes row 0 (no light) as zeros, so the row read there is 0 too. The same reads went one word past a scene's list when it had global lights only (its local loop of 0): each list now ends with a 0. A real GPU branches over the loop, so the RTX 3060 read nothing and drew nothing wrong. `addShadowPasses` already refused an invalid light ("needs a valid light"), and `buildGraph` adds shadows only for a valid sun. Test `no_light`. The original finding follows. An image test scene built without `addSunsetLight` (`tests/image/imageTests.cpp`: no environment, no light, so `Content::sun` is an invalid handle, which `renderTest` still passes to `addShadowPasses`) makes `rasm_image_tests` exit with a segfault on lavapipe (mesa 26.3.0, `--scenes <name>`, Release and Debug) during its first frame: cdb shows an access violation in code llvmpipe compiled (a JIT address in one of its threads), so some shader reads out of bounds. It stays with every material `SORTED` and only cubes and the ground in the scene (no weighted, additive or glyph draw, no picks), and goes away when the scene gets the sun and the environment. On an RTX 3060 the same run finishes with 0 validation messages, so the read is out of bounds there too but harmless. Steps: copy `buildWeighted`, drop its `addSunsetLight` call, run `python tools/image_tests.py --lavapipe --scenes <it>`. Fix direction: run it under GPU-assisted validation on lavapipe to find the read (the suspects are the shadow passes of an invalid light, and the shaded view's shadow table and environment indices when the scene has neither); `addShadowPasses` should refuse an invalid light. *Confirmed* by running, from the weighted transparency work; the cause is not found yet.

**B11** — *Fixed 2026-10-31:* `submit` builds one wait stage per wait semaphore. The original finding follows. `VulkanContext::submit` passes one `waitStages` entry while `waitSemaphoreCount = waitSemaphores.size()` ([vulkanContext.cpp:1120-1138](../src/rhi/vulkan/vulkanContext.cpp#L1120-L1138)). Waiting on more than one semaphore reads past the array. The bug is latent today, because callers pass 0 or 1 semaphores.

**B12** — *Fixed 2026-10-31:* the SPIR-V options are now a static array. The original finding follows. `ShaderCompiler::getTargetDesc` allocates `new slang::CompilerOptionEntry[1]` and never frees it ([shaderCompiler.cpp:456-458](../src/renderer/shaderCompiler.cpp#L456-L458)).

**B13** — Handle indices are consumed before validation and are never reused. *Fixed 2026-11-22 (`D4`):* every index comes back when its object is destroyed. `loadMesh` still needs its handle before the file is parsed, since it returns at once and parses on a worker; a mesh that fails keeps its index until `destroyMesh` ([mesh.cpp:386](../src/assets/mesh.cpp#L386)) frees it, and a path whose mesh was destroyed loads again as a new mesh.
- `loadMesh` takes a handle before parsing the file ([mesh.cpp:116](../src/assets/mesh.cpp#L116)), so failed loads burn slots. A retry of the same path reuses its handle.
- *Partly fixed 2026-11-22 (`D4`):* every registry hands out indices from a `HandlePool`, so a released index comes back with a new generation; only textures, buffers and render targets can be released so far.
- With `MAX_MESHES = 8` and indices starting at 1, only 7 meshes can be loaded in total. *Fixed 2026-11-22 (`D33`):* `MAX_MESHES` is gone, and `createMesh` takes its handle after the upload ([mesh.cpp:78](../src/assets/mesh.cpp#L78)), so a mesh that does not fit uses no index. Materials still have a cap (`D34`).
- `MAX_LIGHTS = 8` and `MAX_CAMERAS = 8` are global, not per scene. *Lights fixed 2026-11-21:* `MAX_LIGHTS` is gone; `EngineConfig::maxLights` (16384 by default) sets the light table's size, and its rows are indexed by handle, so all `maxLights` handles are usable.

**B14** — *Fixed 2026-10-31:* the declaration and the `#if 0` definition are deleted. The original finding follows. `Engine::loadMaterials` is declared ([engine.h:56](../include/rasm/engine.h#L56)), but its definition is under `#if 0` ([material.cpp:82-104](../src/assets/material.cpp#L82-L104)), so calling it is a link error.

**B15** — *Fixed 2026-10-31:* `LightType::SPOT` is removed from the public enum. *Extended 2026-11-20:* `LightType::SPOT` is back as a real spot light, with the glTF cone (`Light::innerConeAngle`, `outerConeAngle`) in the GPU light and in `shadePBR`, and its own shadow. The original finding follows. `LightType::SPOT` is public ([light.h:15](../include/rasm/light.h#L15)), but the GPU light type has no spot variant. Spot lights are `static_cast` into value 2 and shaded as point lights.

**B16** — *Fixed 2026-10-31:* `prepareScene` returns an empty, uncached `PreparedScene` when there is no geometry, so entities added later still appear. `render2` presents the cleared frame when the prepared scene has no pipeline. *Extended 2026-11-01:* a failed preparation logs the failure, destroys what it created and retries on the next frame, and only a complete result is cached. A mesh without vertices or indices is skipped with a warning. The original finding follows. For an empty scene, `prepareScene` requests zero-sized buffers. Creation fails, the result is not cached, and every frame retries and logs errors. Then `render2` binds an invalid pipeline ([scene.cpp:199-233](../src/scene/scene.cpp#L199-L233)).

**B17** — *Fixed 2026-10-27:* `SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED` triggers recreation. `Window` has `pixelWidth`/`pixelHeight` (the swapchain's desired extent) next to the logical `width`/`height` used for mouse input. Depth textures, viewport, scissor and camera aspect come from the swapchain extent (`Swapchain::width`/`height`). The original finding follows. Resize uses `SDL_EVENT_WINDOW_RESIZED`, which reports logical size ([window.cpp:116-122](../src/platform/window.cpp#L116-L122)). The depth texture and viewport use `mainWindow` size, while the swapchain extent comes from the surface. On scaled or HiDPI displays they can disagree. Use `SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED` / `SDL_GetWindowSizeInPixels`, and size everything from the swapchain extent. *Likely.*

**B23 — The CPU/GPU struct check only runs in debug builds.** *Fixed 2026-11-15:* every build calls `validateRasmStructs` after linking ([shaderCompiler.cpp:902](../src/renderer/shaderCompiler.cpp#L902)). A mismatch logs each wrong size and offset and fails the shader, so the pipeline is not created and the scene is not drawn; it is tried again every frame, like any shader error. Tested in Release with an extra `SceneData` field in `core.slang`. The original finding follows. `validateRasmStructs` is called inside `assert(...)` (shaderCompiler.cpp:396), so with `NDEBUG` the call is compiled out. A Release build with mismatched structs starts normally and the GPU reads shifted data, or hits a device lost when a pointer field moves. Call it unconditionally, log the mismatch and fail the shader or pipeline creation. The check runs once per linked program, so it costs nothing at runtime. *Confirmed.*

**B24 — A camera at rest moved by float noise that depended on the frame time.** *Fixed 2026-11-07:* `easeCamera` snaps the rendered transform to the target once position, rotation and scale are within 1e-6 of it (relative for the position). *Extended 2026-11-25:* the position is a `glm::dvec3` now, so the threshold is an absolute 1e-6 (`ease` in `cameraController.cpp`), which double rounding stays far below anywhere on a planet. The original finding follows. `easeCamera` ([cameraController.cpp:192](../src/scene/cameraController.cpp#L192)) ran `slerp`, `normalize` and `mix` toward the target every frame, even when the camera was already there. With `t` taken from `deltaTime`, the rounding differed from run to run, so frame N of an example without input was not the same on every run. Frustum culling hid it. With occlusion culling, a test that sits right on the edge can flip, which moves a draw between the early and late pass and changes which face wins on equal depth: `03_instances` frame 60 differed in 480 pixels on cube edges in about half the runs. After the fix, 6 full captures out of 6 were identical. *Confirmed.*

**B26 — A glTF primitive without normals gets smooth normals.** `meshImport.cpp` ([meshImport.cpp:282](../src/assets/meshImport.cpp#L282)) averages face normals per vertex when `NORMAL` is missing. The glTF 2.0 spec says a client must compute **flat** normals in that case, so faceted models (low-poly art, CAD exports) look rounded. Flat normals need one vertex per face corner, so unweld the vertices of such primitives before computing them. *Confirmed.*

**B27 — Nothing checks the swapchain format that was really chosen.** The swapchain asks vk-bootstrap for `VK_FORMAT_B8G8R8A8_SRGB` with `VK_COLOR_SPACE_SRGB_NONLINEAR_KHR` ([vulkanSwapchain.cpp:59](../src/rhi/vulkan/vulkanSwapchain.cpp#L59)), and then uses whatever `image_format` comes back. `set_desired_format` is a preference, so on a surface without that format the swapchain can be UNORM. The shaders write linear color and rely on the sRGB format to encode it, so the whole image would come out too dark, with no log line. Log an error or warning when the chosen format is not sRGB. *Likely.*

**B28 — A render graph that fails to compile logs the same error every frame.** When the up-front checks fail or the graph has a cycle, `RenderGraph::compile` leaves `compiled` false ([renderGraph.cpp:402-406](../src/renderer/renderGraph.cpp#L402-L406)), and `execute` calls `compile` again whenever `compiled` is false ([renderGraph.cpp:545-546](../src/renderer/renderGraph.cpp#L545-L546)). The graph cannot change between frames, so it fails the same way and floods the log once per frame. Remember the failure until a pass is added. *Confirmed.*

**B29 — glTF samplers ignore `wrapT` and `minFilter`.** `toSamplerType` ([materialImport.cpp:15-31](../src/assets/materialImport.cpp#L15-L31)) picks the sampler from `wrapS` and `magFilter` alone. A texture that repeats in u but clamps in v, or that asks for nearest minification, is sampled with the wrong mode. The six shared samplers have one wrap mode for both axes, so a fix needs either more samplers or a nearest match with a warning. *Confirmed.*

---

**B30 — A frame that fails partway through its submits cannot put its texture states back.** *Fixed 2026-11-15:* `TextureStates` keeps every change with its command buffer, and a successful submit forgets only the changes of its own command buffers ([renderContext.cpp:1322](../src/rhi/renderContext.cpp#L1322)); `discardRecording` puts the rest back, last first. A history clear is forgotten only when the command buffer it was recorded into goes out. Tested in `tests/textureStatesTests.cpp`. The original finding follows. With async compute a frame is several submits ([engine.cpp:496-541](../src/engine.cpp#L496-L541)). Each successful `RenderContext::submit` forgets the states from before the recording and the recorded history clears ([renderContext.cpp:1334-1335](../src/rhi/renderContext.cpp#L1334-L1335)), including those of batches that are not submitted yet. If a later batch then fails, `discardRecording` has nothing to put back, so the next frame transitions from layouts the GPU never reached, and a history clear in that batch is lost. A submit fails only on device loss or out of memory, so this is rare. Fix by keeping the states per batch and committing each when its batch goes out. *Likely.*

**B31 — `getMaterial` returns a reference into a vector that grows.** `Engine::getMaterial` returns `const Material &` into `registry.materials` ([material.cpp:151](../src/assets/material.cpp#L151)), and `createMaterial` and every glTF load resize that vector. An application that keeps the reference, for example `const Material &m = engine.getMaterial(a); engine.createMaterial(...); use(m);`, reads freed memory. The examples copy the result (`auto values = engine.getMaterial(material)`), so none does today. Return it by value, as `getLight` does. *Confirmed* by reading.

**B32 — A morphed primitive without normals is lit with the normals of its base shape.** A primitive with no `NORMAL` gets smooth normals once, from its base positions ([meshImport.cpp:282](../src/assets/meshImport.cpp#L282)), and its targets then have no `NORMAL` deltas, so the `Skin` pass moves the positions and keeps those normals ([skin.slang](../shaders/passes/skin.slang)). A POSITION-only target that bends the surface out of its plane is drawn bent but lit flat; glTF asks a viewer to compute the normals of the morphed shape. Rebuild the normals from the morphed positions for such primitives (a pass over the triangles after the `Skin` pass), or warn at import. *Confirmed* by reading, from the morph targets review.

**B34 — A font file is trusted.** `buildFontAtlas` ([fontLoad.cpp](../src/assets/fontLoad.cpp)) hands the file's bytes to stb_truetype, which follows the offsets in the font's tables without checking them against the size: it only refuses data whose first tag is no font's (and a buffer under 12 bytes). A truncated or hostile font file can make it read past the buffer (stb_truetype says so itself: no security guarantee). `AssetLoader::loadFont`, `rasm_build_font_atlas` and `rasm_asset_loader_load_font` pass any file on. Fix direction: check the table directory (each table's offset and length within the size) before `stbtt_InitFont`, or decode fonts with FreeType; until then load only fonts the application ships. *Confirmed* by reading, from the labels work.

## 3. Design and architecture

**D1 — The backend abstraction does not scale.** *Fixed 2026-11-02:* `src/rhi/device.h` defines a virtual interface (`Device`, `CommandBuffer`, `Queue`, `Swapchain`, and the `Buffer`, `Texture`, `Sampler`, `Shader`, `Pipeline`, descriptor and `Fence` objects), and `src/rhi/vulkan/` implements it. `RenderContext` has no `switch (backend)` left: it maps handles to `rhi::` objects and keeps the dedup caches and render targets. Fences are timelines, and the swapchain owns its acquire and present semaphores, so no binary semaphore or command pool crosses the interface. `vulkanContext.*` is gone, and the only `Vk*` type outside `src/rhi/` was the `createWindowSurface` hook in `src/platform/`, which `D7` removed (2026-11-24): a window reaches the device as a `NativeWindow`, and `createVulkanSurface` in `src/rhi/vulkan/` makes the surface. The generational pools in the last bullet are left to `D4`, as the development plan schedules them. See [architecture.md §12](architecture.md#12-rhi). The original finding follows. Every `RenderContext` method is a `switch (backend)` with empty DX12/Metal branches (≈1,300 lines, mostly boilerplate). Replace it with an RHI interface:
- a small set of objects (`Device`, `Buffer`, `Texture`, `Sampler`, `Pipeline`, `CommandBuffer`, `Queue`, `Swapchain`, `Fence`/timeline),
- either a virtual interface or a compile-time backend selection,
- a pool per object type with generational handles.

**D2 — The public API leaks its implementation.** *Mostly fixed 2026-11-01:* the header split is done (see §1.1). `createSurfaceVk` became the private `createWindowSurface` in `src/platform/`, so the backend does not depend on SDL (since `D7`, 2026-11-24, the surface comes from a `NativeWindow` in `createVulkanSurface`), `convertToGfxMaterial` is a helper in `gpuScene.cpp`, and the glTF import functions are private. Still open:
- `Engine` keeps a large public surface that mixes the high-level API with lower-level calls such as `addBindlessTexture`, `getCurrentFrameResources`, `createWindow` and `pollEvents`.
- `RenderContext` is a friend of `Engine`: it reads `Engine`'s handle manager and bindless map, and calls `addBindlessTexture` for render targets. (*Fixed 2026-11-24*: `RenderContext` is made from a `RenderContextDesc`, owns the bindless set and fills it for render targets itself, and takes each window's `Window` for its swapchain, so it has no `Engine` or `Renderer` pointer.) (*Fixed 2026-11-07* for `RenderGraph`: `execute(camera)` takes the camera, so it no longer reads the registry.)
- Import and renderer internals are public types: `ObjRaw`, `SubGLTFRaw`, `GLTFRaw` (with its `tinygltf::Model`) and `GltfImportCache` in [mesh.h](../include/rasm/mesh.h). Applications never use them, but `Engine` holds them by value (`std::future<GLTFRaw>` in `PendingMeshLoad`), so `engine.h` needs their full definitions. (The scene-preparation types left `scene.h` on 2026-11-07: the GPU scene state is a private `GpuScene` behind a `unique_ptr`.) Moving them to private headers needs the private-`Impl` approach `RenderContext` uses, which is part of `D3`. (*Fixed 2026-11-24*: they are in the private `src/assets/meshData.h`; the loader's state is the private `AssetLoader::Impl`, so no public header names a tinygltf type.)

**D3 — `Engine` is a god object.** *Fixed 2026-11-24:* `Engine` is built from subsystems with one job each, and an integrator uses only the ones it needs.
- `rasm::Renderer` (`rasm/renderer.h`, `src/renderer/renderer.cpp`): the scene objects, the GPU scene, the frame, the windows' swapchains and the UI. It draws into the application's window (`RendererConfig::nativeWindow`, `addWindow` with `WindowDesc::native`) or offscreen images, opens no window and needs no SDL (`examples/21_renderer`). `Renderer` has no virtual function but its destructor.
- `rasm::AssetLoader(Renderer&, AssetLoaderConfig)` (`rasm/assetLoader.h`, `src/assets/assetLoader.cpp`): the worker pool, the load budget, the path caches and the glTF, OBJ, KTX2 and HDR loads. The renderer finishes its loads at the start of each frame and tells it of destroyed objects through `LoadHooks` (`src/renderer/loadHooks.h`), and keeps its own state of a load's result (`MeshState`, `loadingTextures`), so it never reads the loader. The renderer must outlive the loader; the other order logs an error, drops the loads and makes the loader refuse every call (`tests/rendererConfigTests.cpp`). `examples/19_embedding` uses a Renderer with an AssetLoader.
- `Platform` (`src/platform/platform.h`): SDL, the application's window, or none, given to the `Renderer`.
- `RenderContext` over `rhi::Device`: made from a `RenderContextDesc`, it owns the bindless set and knows no `Renderer` (`D2`).
- `Engine` is a `final` `Renderer` that picks its `Platform` (`EngineConfig::platform`) and owns an `AssetLoader`; it overrides nothing, and its own non-virtual `loadMesh`, `loadGLTF`, `loadTexture`, `loadEnvironment`, `resolveAssetPath` and `getConfig` (the whole `EngineConfig`, `toEngineConfig`) keep its API. `RendererConfig` and `AssetLoaderConfig` are its config's parts (`toRendererConfig`, `toAssetLoaderConfig`), checked field by field both ways.
- Two libraries: `rasm::renderer` links no SDL3, tinygltf, tinyobjloader or libktx; `rasm::rasm` adds the Engine, the SDL platform and the loader. Both are installed and exported, and `find_package(rasm COMPONENTS renderer)` needs only the renderer's dependencies. `examples/21_renderer` links only `rasm::renderer`.
- `Scene` stays part of the `Renderer` by decision: the GPU tables mirror the scene objects row by row, and a separate `Scene` would only add change lists without a use case.

The original finding follows. It owns the window, input, assets, scene registry, cameras, the frame loop and the renderer. Split it into subsystems that `Engine` composes: `Platform`, `AssetManager`, `Scene`, `Renderer`, `rhi::Device`. Then integrators can use only the pieces they need, for example the renderer with their own window and asset pipeline.

**D4 — There is no resource lifetime.** *Extended 2026-11-22 (`P21`):* destroying a mesh, texture or environment while it loads drops its load at once: a queued job never runs, and a running one gives its result up when it ends. *Fixed 2026-11-22:* every object the public API creates can be destroyed: `destroyEntity` ([entity.cpp:68](../src/scene/entity.cpp#L68)), `removeEntityFromScene`, `destroyMesh` ([mesh.cpp:386](../src/assets/mesh.cpp#L386)), `destroyMaterial` ([material.cpp:134](../src/assets/material.cpp#L134)), `destroyLight`, `removeLightFromScene`, `destroyEnvironment` (`D22`), `destroyCamera` and `destroyScene` (refused while a render graph draws a view of them, [scene.cpp:116](../src/scene/scene.cpp#L116)). Pools hand out ranges with `RangeAllocator` (first fit, neighbours joined): the five geometry streams and the geometry table rows ([geometryPool.cpp:84](../src/renderer/geometryPool.cpp#L84)) and the animation pool come back through the release queue after the frames in flight; instance rows ([gpuScene.cpp:772](../src/renderer/gpuScene.cpp#L772)), material and light rows and the animated entity rows and ranges are reused at once, since each frame slot has its own copy and a freed animated row is written stopped. A glTF import's materials and textures belong to its mesh and go with it; users of a destroyed mesh or material fall back, found through user counts so the usual order searches nothing. `examples/17_streaming` streams 795 tiles in 1500 frames through pools sized for about two windows of them, with `getPoolStats` flat, sync and GPU-assisted validation clean, and ASan clean. The material table's size is `EngineConfig::maxMaterials` (`D34`). Remaining waits on the GPU are `D35`; pools are not defragmented. *Partly fixed 2026-11-22:* handles come from generational pools (`HandlePool`, [handle.cpp:7](../src/core/handle.cpp#L7)): a free list of indices, a generation bump on release, and `isAlive`, which every `RenderContext` lookup ([renderContext.cpp:253](../src/rhi/renderContext.cpp#L253)) and every `Engine` public call (`isLive`) checks, so a stale handle logs an error instead of reaching another object. `RenderContext` keeps its objects in vectors indexed by handle (`P4`). Destruction is deferred: `destroyTexture`, `destroyBuffer` (and `resizeBuffer`'s old buffer) and `destroyRenderTargets` release the handle at once and give the free to `rhi::ReleaseQueue`, which `endFrame` tags with the graphics, compute and upload fence values signaled last (`tagReleases`, [renderContext.cpp:1502](../src/rhi/renderContext.cpp#L1502)) and `beginFrame` collects without waiting; bindless slots are reused through it (`B25`), and `destroyRenderTargets` no longer waits for the device. Applications get `Engine::destroyTexture`, `destroyBuffer` and `destroyRenderTarget`; Dear ImGui's texture releases use the same queue. Tests: `tests/handleTests.cpp`, `tests/releaseQueueTests.cpp`; example `17_streaming`. Still open: destroying meshes (with their geometry pool ranges and the materials and textures a glTF import made), materials (with `D34`), entities and removing them from a scene, cameras, lights, scenes and environments (`D22`), and reusing instance rows and animation ranges. The original finding follows.
- Applications cannot destroy anything before shutdown: there is no `destroyMesh`, `destroyMaterial`, `destroyEntity` or `removeEntityFromScene`. The low-level `RenderContext::destroyBuffer` and `RenderContext::destroyTexture` exist, and the engine uses them for buffers that grow, for render-target attachments and for the depth texture on resize, but they free no bindless slot (`B25`).
- Handles are never invalidated (`generation` is always 1, [handle.cpp](../src/core/handle.cpp)), so use-after-free can't be detected.
- Streaming (map tiles, game levels) needs generational handles, deferred destruction tied to frame fences, and free-list reuse of registry slots and bindless slots. The material table needs the same row reuse, and a size from `EngineConfig` (`D34`). The [generational handles](guides/generational-handles.html) and [bindless](guides/bindless.html) guides describe the usual design.

**D5 — `ResourceDesc` is fragile.** *Fixed 2026-11-02:* `ResourceDesc` and `ResourceType` are gone. `rasm/render/resource.h` has one aggregate per resource (`BufferDesc`, `TextureDesc`, `ShaderDesc`, `PipelineDesc`, `RenderTargetDesc`, `BindlessDescriptorSetLayoutDesc`, `DescriptorPoolDesc`), each with a defaulted `operator==`. `ShaderDesc` owns its SPIR-V, so the pointer-pinning `shaderSources` deque in `RenderContext` is gone. The dedup hashes and `HandleHash` combine fields with `hashCombine`. See [architecture.md](architecture.md). The original finding follows.
- It is a hand-maintained tagged union with a `std::string`, plus manual `==`/hash.
- Equality ignores fields that matter: pipeline equality ignores vertex layout, attachment formats and the descriptor layout, so two pipelines that differ only in color format alias each other.
- The hash XORs component hashes, so collisions are common (`a^b == b^a`, `x^x == 0`).
- Prefer distinct `BufferDesc`, `TextureDesc`, `PipelineDesc`, … structs with defaulted `operator==` and a proper hash combine.

**D6 — Scene preparation is all-or-nothing.** *Fixed 2026-11-22 (`D4`):* entities, meshes, materials and lights can be removed and destroyed, and their rows and pool ranges are reused. *Mostly fixed 2026-11-07:* `prepareScene` is gone. Engine-wide GPU tables (instances, materials, geometry) live for the engine's lifetime, and `syncGpuScene` uploads only the rows that changed. Each scene keeps a draw list that is rebuilt when an entity is added, an asset finishes loading, or a cull mode changes. Entities and materials can be added and edited at runtime (`updateMaterial`). Still open: nothing can be removed, since there is no destroy API and the tables are append-only (`D4`). The original finding follows. `prepareScene` is cached forever ([gpuScene.cpp:121-124](../src/renderer/gpuScene.cpp#L121-L124)). Entities, meshes and materials added, removed or edited after the first frame are ignored; only transforms update. A GPU scene needs incremental updates:
- slot allocation inside persistent mega buffers,
- dirty tracking with per-frame upload of the changed ranges,
- material and instance tables separate from geometry.

**D7 — The engine owns the event loop and input.** *Extended 2026-11-24:* more than one window: `Engine::addWindow(WindowDesc)` opens an SDL window, wraps an application's (`NATIVE`) or makes an offscreen one (`HEADLESS`), each with its own swapchain and surface; one submit waits for and presents every window's image; `InputEvent::window` tags each event, closing a window other than the main one is a `WINDOW_CLOSE` event, and only the main window's events reach the UI and the engine's camera (`examples/19_embedding`, `examples/20_views`). Still open: `D38`, `D39`. *Mostly fixed 2026-11-24:* `PlatformType::NATIVE` draws into the application's window: `EngineConfig::nativeWindow` is a `NativeWindow` (`NativeWindowType` `WINDOWS`, `X11`, `XCB`, `WAYLAND` or `METAL`, two `void*`, the first pixel size and the content scale), which `DeviceDesc::window` carries to `createVulkanSurface` (`src/rhi/vulkan/vulkanSurface.cpp`), the only file with window-system types. The SDL platform fills the same struct from SDL's window properties (a Metal view's `CAMetalLayer` on macOS), so every window takes the embedder's path, and SDL no longer loads Vulkan (`windowSurface.h` is gone). All input is a stream of `InputEvent`s (`rasm/input.h`: a key's meaning and its position, mouse, wheel, text, focus): the SDL platform makes them from its events, the application sends them with `Engine::addInputEvent`, and `pollEvents` applies them in `beginFrame` to Dear ImGui (no ImGui platform backend any more, so the `sdl3-binding` feature is dropped) and to `InputState` (`src/platform/input.cpp`), which gives the camera its input. `setWindowSize` and `setWindowContentScale` are the application's resize and display-scale events; the SDL platform reports a display-scale change itself, and the UI rescales its style. Cursor shapes, the clipboard and starting text input go through `Platform` hooks, which SDL fills. Escape quits only with SDL. Example `19_embedding` opens its own SDL3 window, and its `--headless` run uses a hidden window with a scripted drag, click and typing, so `verify-change` checks the native surface, the swapchain and the input path with nothing on screen. Camera controllers are helpers the application drives (2026-11-24): `CameraRig`, `createCameraRig` and `updateCameraRig` (`rasm/cameraController.h`) and `CameraInputState`, `addCameraInputEvent`, `takeCameraInput` with an `InputArea` per view (`rasm/cameraInput.h`) are plain structs and free functions with no `Engine`, which the engine's own path also calls; `CameraController::Type::NONE` keeps `beginFrame` off a camera, and `pollEvents()` (once per frame, callable before `render`), `getInputEvents`, `getCameraInput`, `getUiInputCapture` and `getDeltaTime` give the application the frame's input on every platform (`examples/05_city`, `examples/19_embedding`). Still open: more than one window (plan item "Multiple views and windows"), the IME candidate window's position (`D38`), and SDL video drivers without a native window handle (`D39`). *Partly fixed 2026-11-22:* the window and its events are behind a private `Platform` interface (`src/platform/platform.h`): `sdlPlatform.cpp` opens the SDL3 window and turns its events into `PlatformEvents`, which `Engine::pollEvents` applies, and `headlessPlatform.cpp` has neither. `EngineConfig::platform = PlatformType::HEADLESS` runs the engine with no window and no SDL: the device has no surface, and the frames render into an `OffscreenSwapchain` that `Engine::readFrame` copies back. A headless engine runs the UI with no input (`uiPlatform.cpp` uses no SDL for a window without a handle). Still open: creating the engine from a native window or surface handle (`PlatformType::NATIVE`), input fed by the application, the UI in a window the application owns, and camera controllers as helpers the application drives. The original finding follows.
- `pollEvents` runs inside `beginFrame`. Escape quits. The camera controller is driven internally and the caller must pass a camera.
- Applications never see input events.
- With `EngineConfig::ui` the SDL events also feed Dear ImGui, through ImGui's SDL3 backend in `src/platform/uiPlatform.cpp` only. An application that owns the loop either passes its SDL events on, or feeds ImGui with its own platform backend and tells RASM not to.
- You can't embed RASM in a host window (Qt, editor, map application) or run it headless.

Needed: a platform layer the application can replace, creation from a native surface or window handle, an offscreen/headless mode, and camera controllers as optional helpers driven by the application.

**D8 — Coordinate handedness is achieved by mirroring the world.** *Fixed 2026-11-04:* the world is right-handed Y-up. Import no longer mirrors glTF or OBJ geometry, and the Vulkan backend flips Y with a negative-height viewport in `setViewport`. Front faces are counter-clockwise. Cull mode is dynamic pipeline state (`RenderContext::setCullMode`), so the uber pipeline stays one pipeline. `prepareScene` groups the draws by cull mode, and `drawScene` issues one indirect draw per run of equal modes taken from the current transforms: `NONE` for double-sided materials (glTF `doubleSided`, or `createMaterial(..., doubleSided)`), `BACK` otherwise, and `FRONT` under a mirroring transform. Double-sided back faces are lit with the reversed normal. The original finding follows.
- glTF geometry gets a `scale(1,-1,1)` root ([meshImport.cpp:545](../src/assets/meshImport.cpp#L545)), and OBJ vertices are negated per vertex ([meshImport.cpp:687-689](../src/assets/meshImport.cpp#L687-L689)).
- That mirrors the world: the determinant is negative and the triangle winding flips. Back-face culling is disabled to hide this ([vulkanDevice.cpp:651-652](../src/rhi/vulkan/vulkanDevice.cpp#L651-L652)).
- User-specified positions and directions live in a Y-down world.

Use a right-handed Y-up world (glTF's convention) and do the Vulkan flip with a negative-height viewport (core since 1.1) or in the projection. Then enable culling and honor glTF `doubleSided`.

**D9 — The render graph only sorts.** *Resolved 2026-11-13:* all four bullets below are fixed; the steps follow. *Partly resolved 2026-11-07:* the graph now records barriers from what passes declare. `RenderContext` keeps each texture's state, so `transitionImageLayout` takes only the new usage, and the graph moves the textures a pass reads to `SAMPLED`. For buffers it keeps the last write and the reads since, across frames, and records one `memoryBarrier` per pass only for a read after a write, a write after a read or two writes. Before, it put a barrier on every change between compute and graphics and missed two graphics passes sharing a buffer. `endPass` still moves a render target's color to `SAMPLED` (`B10`), and `endFrame` moves the swapchain image to `PRESENT_SRC`. A pass must declare every buffer it uses; `compile()` fails for a compute pass with no buffer write and for a pass that reads the render target it draws to. A frame that is not submitted puts the texture states back (`RenderContext::discardRecording`). *Extended 2026-11-13:* the swapchain is a declared resource (`PassBuilder::writeSwapchain`), and `compile()` fails for a graphics pass that does not write exactly one target. A render target created with `history` keeps one copy per frame slot, which a pass reads with `readPrevious`; other render targets have one copy that all slots share. *Extended 2026-11-13:* a render target that `PassBuilder::createRenderTarget` makes without history is transient. `compile()` records the passes that use it, and the graph places all of them in shared heaps, so targets whose lifetimes do not overlap share memory (`rhi::packAliased`). `RenderTargetDesc::swapchainScale` sizes a target from the window, and a resize rebuilds or re-places it. *Extended 2026-11-13:* passes that draw to one target load what the pass before drew instead of clearing it (`AttachmentOps`, set by `compile()`), so the third bullet is fixed; the stats overlay moved to a pass of its own in `endFrame`. *Fixed 2026-11-13 (review of the branch):* transient targets get a global `aliasingBarrier` before their first pass, since the `UNKNOWN` image barrier did not order the writes of the target that shared the memory before; a failed placement is retried each frame and draws no passes until it works; the graph frees its transient targets when destroyed (move-only now); placement runs again only when a compile changes the lifetimes; render target descs need a depth format and no gap in `colorFormats`; new history copies are cleared at creation (`RenderContext::clearNewHistory`, from `beginFrame`) instead of by the graph, so `getPreviousRenderTargetTexture` is safe outside a graph too; the stats overlay pass has no depth attachment. *Fixed 2026-11-13:* the fourth bullet. `Engine::render` runs a graph (`Renderer::render`), and the scene is graph passes (`Engine::addScenePasses`: culling, draws, Hi-Z, late culling, late draws) with the view's own camera. Their barriers come from what they declare; the passes that write one resource run in the order they were added, so a buffer or target can be written twice in a frame, and `PassBuilder::readDepth`, `readSwapchainDepth` and `readPrevious(buffer)` cover the Hi-Z's depth read and the visibility flags of the frame before. The original finding follows.
- It does not track resource state, so barriers and layout transitions are left to the passes or missing (B10).
- It has no transient allocation or aliasing.
- Each pass starts its own rendering scope with `CLEAR` ([vulkanCommandBuffer.cpp:266-303](../src/rhi/vulkan/vulkanCommandBuffer.cpp#L266-L303)), so two passes that target the swapchain overwrite each other.
- The camera is hardcoded to `scene.cameras[0]`, and `Engine::render` doesn't use the graph at all.

**D10 — There are two rendering paths.** *Fixed 2026-11-01:* the legacy path is gone, with `render2` renamed to `render`. `01_render_graph` draws through `Engine::drawScene` and `Engine::createPipeline`. The removal also took out what only the legacy path used: `basic.slang`, `MaterialType::BASIC` and `SHADER`, `Material::shader`, `Engine::createShader`, `uploadMesh`, the per-frame shader data buffer, the vertex-input reflection in `ShaderCompiler`, `VertexInputLayout`, `BufferUsage::VERTEX` and `VERTEXINDEX`, the vertex and index fields of the buffer desc, `bindVertexBuffer` and `SAMPLED_DEPTH_STENCIL_ATTACHMENT`. With `drawScene` public, each call has its own `SceneData` slot, fits the camera to the pass's aspect ratio, and refuses a render target with other formats than the scene's pipeline. A frame that never renders to the swapchain clears it in `endFrame`, because it is presented anyway. The original finding follows. `render`/`compileScene` (the legacy per-entity path) and `render2`/`prepareScene` (GPU-driven) coexist, together with `begin/endOffscreenFrame`, which is marked "TODO: delete". Pick the GPU-driven path, port `01_render_graph` to it, and delete the rest.

**D11 — Assets and shaders are located through the working directory** (§1.3). *Fixed 2026-11-01:* see [architecture.md §11](architecture.md#11-conventions-that-cross-files).

**D12 — The shader code is Vulkan-only.**
- `spirv_asm` for `DrawIndex` ([core.slang:315-320](../shaders/lib/core.slang#L315-L320)) is SPIR-V specific.
- The data model relies on raw pointers (`SceneData*`, `VertexFull*`) through buffer device address.
- As far as I know, Slang pointer support is limited to SPIR-V, Metal and CUDA targets: HLSL/DXIL and WGSL have no raw pointers. Verify against the current Slang docs before you design around it.

Before you add D3D12 or WebGPU, put GPU data access behind a binding abstraction, either bindless `StructuredBuffer` indices or explicitly bound storage buffers, and route draw-ID access through a helper that each target implements.

**D13 — Queues and synchronization.** *Mostly fixed 2026-11-22:* there is a transfer queue for the loads' copies (`EngineConfig::transferQueue`, on by default): `VulkanDevice::initialize` takes a queue of the first family that only copies, with copies exact to the texel ([vulkanDevice.cpp:676](../src/rhi/vulkan/vulkanDevice.cpp#L676)), and without one (lavapipe, MoltenVK, most Intel GPUs) the same code puts the loads' copies on the graphics queue. The fills a load makes (`RenderContext::beginLoadUploads` ... `endLoadUploads`, around `Engine::finishReadyLoads`) go to their own `UploadManager` on that queue; the frames' own fills stay on the graphics queue. A load's data is used only once its copies are done (`publishUploadedLoads`: a texture or a mesh counts as loaded then, an environment bakes then), so the frames' submits wait only for values the CPU saw reached ([renderContext.cpp:1910](../src/rhi/renderContext.cpp#L1910)), and its copies wait only for the frames' values already reached. Buffers are shared by every family in use; a texture filled from the ring stays exclusive to the graphics family without a compute queue, is released after its last copy ([vulkanCommandBuffer.cpp:578](../src/rhi/vulkan/vulkanCommandBuffer.cpp#L578)) and acquired at the start of the next graphics submit (`UploadManager::recordAcquires`), and with a compute queue is shared by the three families. The release queue waits for the load uploads' timeline too (`RELEASE_TIMELINES` 4). Upload batches have GPU timers (`FrameStats::uploadGpuMs`). Measured (Release, headless, RTX 3060, median of 5, `tools/load_bench.py`): with the GPU idle (frames of 0.16 ms) the transfer queue changes nothing (Sponza 201 against 199 ms, the burst of `17_streaming` 433 against 421 ms); with a busy GPU (`10_ktx2_textures` at 3840 × 2160 with 8× MSAA and bloom, frames of 4.5 ms) loads end 6 to 11 % sooner (Flight Helmet PNG 195 against 220 ms, Sponza 209 against 223 ms); the steady frame of `05_city` is the same (1.27 against 1.28 ms on the GPU), so sharing every buffer costs nothing there. Still open: uploads are recorded on the main thread (the copy into the staging ring, under `LOAD_BUDGET`); the measurements show no reason yet to move them. *Partly fixed 2026-11-15:* there is an async-compute queue. `QueueType` (public, `rasm/render/resource.h`) has `COMPUTE`, which a GPU with a compute family without graphics gets as its own queue. A `SubmitDesc` waits for other timelines (`FenceWait`), and the render graph adds those waits for its async compute passes (`EngineConfig::asyncCompute`, [architecture.md §9](architecture.md#9-render-graph-low-level-path)). Still open: a transfer queue, and uploads recorded off the main thread. *Fixed 2026-11-15 (review of the branch):* the upload flushes made while recording (full ring, overlap) now wait for the last compute submit too (`UploadManager::waitFor`); a batch whose command buffer can't be made or begun drops the frame instead of recording into a closed batch or the other queue's (`Engine::recordingFailed`); an async compute timer's time is read from its own two queries (`getTimestamps` takes a `firstQuery`), so a compute counter with another origin no longer gives wrong times, and `getTimestamps` no longer overflows; a transient target's first pass waits only for the other queue's passes this frame that used a transient target, not for all its work; command buffers end in `submitBatches`, so only the frame's last compute batch takes the `COMPUTE → HOST` barrier, and the graphics one only without a compute queue; a graphics submit may use all `MAX_SUBMIT_WAITS` waits; `textureWaits` no longer allocates. The original finding follows. There is only one graphics queue: no transfer or async-compute queue. `rhi::QueueType` has only `GRAPHICS`; add the new queue types there, with their queues in each backend and a queue choice in `RenderContext::createCommandBuffer` and `submit`. Frame pacing uses a timeline fence since `D1`, but a `SubmitDesc` can only signal one, not wait on one, which cross-queue work needs. Since `P1`, buffer uploads are batched through a staging ring and submitted on the graphics queue before the frame, but they are still recorded on the main thread.

**D14 — Error handling is inconsistent.** Many `bool` results are ignored (`beginCommandBuffer`, `submit`, `fillBuffer`). Some runtime errors are `assert`s.

**D15 — Hard-coded limits** are spread across headers (see [architecture.md §10](architecture.md#10-compile-time-limits)). Move them into `EngineConfig`, or grow the containers dynamically. Size GPU tables from the config.

**D16 — Profiling.** *Partly resolved:* the frame loop, `prepareScene`, uploads, submit and present now have Tracy zones and a frame mark, with the client in on-demand mode. *Extended 2026-11-07:* the frame, culling and every pass get a GPU timestamp pair, shown in the stats overlay and returned by `Engine::getFrameStats()`. Still open: Tracy is linked publicly, the GPU timers do not reach Tracy, and nothing turns Tracy off (every build listens on TCP 8086 on all interfaces, which a shipped game must not do). The VRAM check in `prepareScene` compared host-visible allocations against the device-local budget until `P1` moved the mega buffers to device-local memory.

**D17 — No tests and no CI.** *Handle-pool tests added 2026-11-22 (`D4`):* `tests/handleTests.cpp` covers `HandlePool` (reuse, generations, stale handles, limits) and `tests/releaseQueueTests.cpp` the release queue. *Image tests added 2026-11-22:* `rasm_image_tests` renders 15 scenes headless and compares them with lavapipe goldens in `tests/golden/lavapipe/`; the Windows CI job runs them on lavapipe through `tools/image_tests.py` (`docs/guides/image-tests.html`). Still open: handle-pool tests (`D4`). *Partly resolved 2026-11-04:* `rasm_tests` also covers glTF import (indices, strips and fans, node transforms and cycles, interleaved, quantized and sparse attributes, skipped primitives). `.github/workflows/ci.yml` builds the Windows and macOS Debug and Release presets on every PR and push to `main`, and runs `ctest`. Still open: handle-pool tests (`D4`) and image tests. *Partly resolved 2026-11-01:* `rasm_tests` covers handles, descriptor equality and hashing, render-graph sorting, transforms and camera math. It found `B22` on its first run. Pure-CPU pieces such as handle pools, desc hashing, glTF import, camera math and render-graph sorting are easy to unit-test. Rendering can be covered with headless golden-image tests once offscreen rendering exists.

**D18 — Culling runs before every other GPU work of the frame.** *Fixed 2026-11-13:* culling is a compute pass of the render graph (`Cull 1`, `Cull 2` of `Engine::addScenePasses`), recorded in the frame's one command buffer in the graph's order, so a pass that writes what culling reads runs first if it declares that write. The cull command buffer and `recordCulling` are gone. *Partly worked around 2026-11-07:* occlusion culling does not need the frame's first pass. Only its early half runs here; `drawScene` pauses its own pass for the Hi-Z build and the late culling (`recordOcclusionCulling`), so they read that pass's depth. Still open: GPU work that writes what the early culling reads, such as GPU-side transforms (`P7`). The original finding follows. `recordCulling` records into its own command buffer, and `endFrame` submits it ahead of the frame's command buffer ([engine.cpp:370-381](../src/engine.cpp#L370-L381)), because `drawScene` records inside a render pass where dispatches are not allowed. Any `RenderGraph::addComputePass` work recorded earlier in the frame therefore runs after culling, not before it. Nothing is wrong today: culling reads only the scene tables, `SceneData` and the draw lists, and no application pass can write them. It becomes a bug once GPU work updates what culling reads, such as GPU-side transforms (`P7`) or Hi-Z occlusion culling, which needs the depth of the frame's first pass. The fix is the graph-driven frame of phase 3: culling becomes a graph pass recorded in order with the others. *Confirmed.*

**D19 — The render graph orders only read-after-write.** *Fixed 2026-11-13:* every resource keeps its writers in the order the passes were added, with an edge from each to the next (write after write); a reader runs after the last writer added before it and before the writer after that one (write after read) ([renderGraph.cpp:190-241](../src/renderer/renderGraph.cpp#L190-L241)). The scene passes rely on it: a view's visible draws, draw counts and depth are written twice in a frame. *Partly fixed 2026-11-13:* passes that draw to the same render target, and passes that draw to the swapchain, now run in the order they were added, and the target's readers follow the last of them ([renderGraph.cpp:109-121](../src/renderer/renderGraph.cpp#L109-L121)). Still open: write after write for textures and buffers, and write after read for every resource. The original finding follows. `RenderGraph::compile` keeps the last pass that writes each texture, render target or buffer, and adds an edge from it to every pass that reads the resource ([renderGraph.cpp:125-157](../src/renderer/renderGraph.cpp#L125-L157)). Two passes that write the same resource are not ordered (write after write), and a pass that writes a resource after another pass read it is not ordered either (write after read). Today each graph writes a resource once, so nothing breaks, but a second writer (for example a pass that draws on top of an earlier target) runs in whatever order Kahn's sort leaves it. Give each write a version, as frame graphs do, and add WAW and WAR edges. See the [render graphs guide](guides/render-graphs.html#in-rasm).

**D20 — A shadow uses one scene view per map.** *Extended 2026-11-28:* `View::shadows` draw each view's shadows from its own camera, so each shadowed view adds its own maps' scene views (`examples/20_views` layout 3 with sun shadows on four perspective views and the TV takes 24 of 32); a `ViewGraph` shadow set shares only the maps' memory between cameras, and a rebuilt graph keeps the shadow scene views, so a list change does not count them twice. *Eased 2026-11-24:* `MAX_SCENE_VIEWS` is 32, so four shadowed views with four cascades each (20 scene views) fit, and a view past the limit is left out with an error that names it (`Engine::render(views, count)` draws the others). The cost per map stays. *Extended 2026-11-20:* spot light shadows take one view and point light shadows one per cube face, so a sun with 4 cascades, a spot light, a point light and the shaded view take 12 of the `MAX_SCENE_VIEWS`, which went from 8 to 16. `Engine::addShadowPasses` adds each cascade, a spot light's map and each face of a point light's cube as its own scene view ([gpuScene.cpp:704-768](../src/renderer/gpuScene.cpp#L704-L768)), with its own visible-draw, visibility and Hi-Z buffers (a cube's faces have no Hi-Z), out of `MAX_SCENE_VIEWS` (16) ([scene.h:19](../include/rasm/scene.h#L19)). A second shadowed camera (split screen, a shadowed picture-in-picture) soon does not fit, and `addShadowPasses` logs an error and adds nothing. Draw all maps of a shadow as one view (one culling pass with a frustum per map, layered or multiview rendering into the cube's faces), turn occlusion culling off for cascades, or raise `MAX_SCENE_VIEWS`. *Confirmed.*

**D21 — 16 GPU timers are too few for a shadowed frame.** *Raised 2026-11-28:* `MAX_GPU_TIMERS` is 256, since view shadows put more than 128 passes in one frame (`examples/20_views`, layout 3 with the second window: about 160; 32 scene views with their post passes stay under 256). *Fixed 2026-11-21:* `MAX_GPU_TIMERS` is 64, the frame and 63 passes, enough for `examples/07_lights` (about 54 timers); the overlay lists them all. Compute passes next to each other on one queue with the same `Pass::timerName` share one timer, so the 11 bloom passes are one line, `Bloom`. The original finding follows.
`MAX_GPU_TIMERS` is 16 ([engine.h:39](../include/rasm/engine.h#L39)), the frame and 15 passes, but every scene view adds up to five timed passes. `examples/06_shadows` has 28 passes and `examples/07_lights` about 50, so the timers after the 15th are not measured ([frameStats.cpp:23](../src/renderer/frameStats.cpp#L23) logs it once) and the stats overlay leaves out the shaded view and the tone map, the passes that matter most. Raise the limit with `MAX_SCENE_VIEWS`, or time a scene view's passes as one timer. *Confirmed* by counting the passes; it was already true for `06_shadows` before spot and point shadows.

**D22 — An environment can't be destroyed.** *Fixed 2026-11-22 (`D4`):* `destroyEnvironment` ([environment.cpp:77](../src/assets/environment.cpp#L77)) clears it from every scene, gives its image, cubes and four bindless slots to the release queue, drops a load or bake that has not finished, and keeps the bake's storage slots until a bake recorded in the same frame is done (`Environments::bakeDestroyed`). The original finding follows. `loadEnvironment` adds an `Environment` to `Environments::environments` for the engine's lifetime ([environmentBake.h:79](../src/renderer/environmentBake.h#L79), [environment.cpp:43](../src/assets/environment.cpp#L43)). Only the decoded image is freed once it is baked ([environmentBake.cpp:170](../src/renderer/environmentBake.cpp#L170)); its cube, specular and irradiance cubes stay, about 17 MiB for a 2k image (a 512 cube with mips, 256 × 6 mips, 32), and so do its four bindless slots. An application that changes the sky (a time of day, a level change) loads a new one each time and keeps the old ones. It needs the destroy APIs and deferred destruction of `D4`: `destroyEnvironment` waits for the frames that read the textures, frees them and their slots, and clears the handle from every scene that uses it. *Confirmed* by reading.

**D23 — Environment light ignores shadows and has little specular occlusion.** `shadePBR` adds the environment light times the material's occlusion only ([pbr.slang:203-205](../shaders/lib/pbr.slang#L203-L205)): the shadow maps darken only the punctual lights, and nothing blocks the environment's light from coming through other objects. In `examples/08_ibl` the ground under the spheres and the helmet is as bright as open ground, and a metal sphere reflects the photo's sky where the ground plane should be. The ambient occlusion texture darkens diffuse and specular alike, which is too much specular occlusion on rough metal and too little on smooth surfaces. Add screen-space ambient occlusion, or occlusion from the sun's cascades for the sky's part, a specular occlusion term from AO and roughness (Lagarde 2014), and later local reflection probes. *Confirmed* by reading and in the example's image.

**D24 — Vulkan functions are linked from `vulkan-1.dll`, not loaded at run time.** *Fixed 2026-11-22:* nothing links the loader. `VulkanDevice::initialize` loads it through volk (`loadVulkan` in [vulkanDevice.cpp](../src/rhi/vulkan/vulkanDevice.cpp)): with `volkInitialize`, with a window or headless; since `D7` (2026-11-24) the surface is made from the window's native handles through that loader (`createVulkanSurface`), so the surface and the instance come from one library and SDL loads no Vulkan. A missing loader, a loader older than 1.3 and a GPU older than Vulkan 1.4 each stop startup with an error that names the version found. A 1.3 loader is enough, since Vulkan 1.4 added only device-level commands: each `VulkanDevice` calls through its own `VolkDeviceTable` from `vkGetDeviceProcAddr`, which skips the trampoline, and `VOLK_NO_DEVICE_PROTOTYPES` leaves no global device function to call by mistake. VMA takes its functions from volk (`vmaImportVulkanFunctionsFromVolk`), and vk-bootstrap volk's `vkGetInstanceProcAddr`. The Vulkan headers come from vcpkg (`vulkan-headers`, volk's version), so the SDK is needed only for the validation layer and the tools. CI checks that no executable imports the loader, runs the macOS tests with no Vulkan installed and the image tests on the runner's own 1.3 loader. The original finding follows. `rasm` links `Vulkan::Vulkan` ([src/CMakeLists.txt](../src/CMakeLists.txt)), so every executable imports each `vk*` function it calls from the loader DLL. Three problems follow:
- On a machine whose loader is older than Vulkan 1.4, an application can't start: Windows stops it with STATUS_ENTRYPOINT_NOT_FOUND (`0xC0000139`) for `vkCopyMemoryToImage`, behind an error dialog, before `main` runs. The engine never gets the chance to say "this needs Vulkan 1.4". Windows loads `vulkan-1.dll` from `System32` before `PATH`, so a newer loader next to the SDK does not help. This is what hung the `windows-latest` CI job until the job installed the SDK's loader into `System32` (2026-11-21).
- Every device-level call goes through the loader's dispatch trampoline. Function pointers from `vkGetDeviceProcAddr` call the driver directly, which costs less per command.
- `rasm_tests` needs no GPU, but it still can't start without a Vulkan loader on the machine.

Load the functions at run time with [volk](https://github.com/zeux/volk) (vcpkg port `volk`): `volkInitialize` at engine start (no loader → a clear error), `volkLoadInstance` and `volkLoadDevice` after creation, and VMA fed from volk (`vmaImportVulkanFunctionsFromVolk`). Then no `vulkan-1.lib` link is needed and the CI loader step can go. *Confirmed* on CI.

**D25 — Cut-out materials thin out in the far mips.** A `MASK` draw discards where alpha < `alphaCutoff` ([rasm.slang:350](../shaders/passes/rasm.slang#L350)), or with MSAA covers samples by the sharpened alpha around it, and the base color texture's mips are box-filtered averages made on the CPU ([mipChain.cpp:56](../src/rhi/mipChain.cpp#L56)). Averaging a leaf's alpha with the clear texels around it lowers it below the cutoff in the small mips, so foliage, fences and chains lose most of their texels at a distance and fade away. Scale each mip's alpha so the share of texels at or above the cutoff stays that of mip 0 (coverage-preserving mips, Castaño 2010), which needs the cutoff when the texture is uploaded, or sharpen alpha in the shader with its derivatives (the MSAA path does that around the cutoff, `getCoverage`, which keeps the edge at the cutoff but not the mips' lost coverage). *Confirmed* by reading; the sample models in `examples/09_gltf_materials` are too near to show it.

**D26 — A rotated texture transform does not turn the normal map's tangent frame.** `fragMain` samples a normal map at its `KHR_texture_transform`ed UV ([rasm.slang:397](../shaders/passes/rasm.slang#L397)), but a mesh with glTF tangents still builds the frame from the authored tangent ([pbr.slang:29](../shaders/lib/pbr.slang#L29)), which follows the untransformed UVs. With a rotation (or a negative scale) the map's x and y then point the wrong way, and the bumps are lit from the wrong side. Without authored tangents the frame comes from the derivatives of the transformed UVs and is right. Turn the tangent-space normal by the inverse of the transform's 2×2 before it is used, as the glTF sample viewer does. *Confirmed* by reading; no sample model in the repository has both.

**D27 — A scene view shared by two graphs is jittered when one of them has TAA.** `addTaaPass` sets `SceneView::jitter` on the view that draws its source ([taa.cpp:140](../src/renderer/taa.cpp#L140)), and graphs built for the same scene, camera, target, face and shadows share one view ([gpuScene.cpp:1312](../src/renderer/gpuScene.cpp#L1312)). A second graph that draws the same view without a TAA pass then gets the jittered projection and the −1 mip bias, so its still image shakes by a fraction of a pixel. Both graphs draw the same target, so it takes an application that builds two graphs for one target and runs one without TAA. Make the jitter part of the view's key, or count the graphs that ask for it. *Likely*, by reading.

**D28 — An entity cannot hang on a node of an animated entity.** The pose lives only on the GPU: the `Animate` pass writes each animated sub-mesh's matrices ([animate.slang](../shaders/passes/animate.slang)), and the CPU never learns where a node is. A game that puts a sword in a hand, or a lamp on a moving arm, has no way to follow the node. The GPU-driven way keeps the CPU cost flat: an entity gets a parent (an animated entity and one of its kept nodes), its instance rows get an `animationRow` like an animated sub-mesh, and the `Animate` pass writes their matrices as parent world × node world × the entity's local matrix, after the parent's nodes in the same group (a second pass, or parents before children in the table). The other option is a CPU-side sampler of the same rules (`animate.slang`'s `sampleChannel` and `getClipTime` in C++) that an application calls for the nodes it needs, which costs CPU per attached entity and per frame. *Design*, logged with the node animation goal.

**D29 — A skinned mesh's LODs are simplified in its bind pose, without its weights.** `buildMeshLods` welds and simplifies a skinned sub-mesh like any other ([meshLod.cpp](../src/assets/meshLod.cpp)): the skin stream only keeps two vertices with different joints or weights from being welded. The collapses look at bind-pose positions alone, so an edge across a joint (an elbow, a knee) can collapse though the joint bends it far, and a coarse level's error, measured in the bind pose, is smaller than what it shows posed. Every level reads the posed vertices, so it is drawn in the right place; only its shape near a bending joint is off. Lock or weight the vertices whose joints differ from their neighbours' (`meshopt_simplifyWithAttributes` with the weights as attributes), or scale the error by the largest stretch of the joints. Morph targets have the same gap: the weld keeps two vertices with different deltas apart and moves the deltas with them (a mesh with more than 13 targets gets no LODs, since `weldVertices` compares at most 16 streams), but the collapses never look at the deltas, so a level can merge vertices that a target moves far apart (a lip line, an eyelid). Add the largest delta per vertex as a simplification attribute. *Design*, logged with the skinning goal.

**D30 — A skinned mesh that plays no clip draws its bind pose.** *Fixed 2026-11-21:* an entity of a skinned mesh takes its animation row when it gets its instance rows (`poseAtRest`), and with no clip the `Animate` pass poses it at its skeleton's rest TRS (a channel row with no channel, after `ALL_ANIMATION_CLIPS`'s), so it is skinned at rest; a file without clips keeps its joints too, and `stopAnimation` on a skinned entity returns it to that pose with no motion that frame. Such an entity is now posed and skinned every frame (`P18`). The original finding follows. The views read a skinned sub-mesh's posed vertices only while its entity plays ([animate.slang](../shaders/passes/animate.slang) writes `InstanceTransform::skinnedVertex` then); otherwise its instance row points at the geometry pool's vertices, the bind pose as the file stores it, placed by the entity alone (the node's matrix is ignored, as glTF asks). A file whose rest pose differs from its bind pose (or that has no clips: `CesiumMan` with no play lies down, Z-up) then shows a different pose before the first play and after `stopAnimation`. Skin a stopped entity once in its rest pose (a play of no clip that the `Animate` pass poses at rest), and keep it skinned until a play. *Design*, logged with the skinning goal.

**D31 — Without a UNORM swapchain view the UI blends in linear light, and its scale is read once.** *Partly fixed 2026-11-24:* (2) is fixed by `D7`: the SDL platform reads the display's scale again on `SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED` and `SDL_EVENT_WINDOW_DISPLAY_CHANGED` (a `NATIVE` application calls `setWindowContentScale`), and `buildUi` scales the current style by the ratio of the new scale to the old (`setUiScale`), so the application's style stays. Still open: (1) and (3). The original finding follows. Two limits of the Dear ImGui integration. (1) The UI pass draws through the swapchain's `B8G8R8A8_UNORM` view only where the device has `VK_KHR_swapchain_mutable_format` ([ui.cpp:170](../src/renderer/ui.cpp#L170)); a headless engine's offscreen images always have an `R8G8B8A8_UNORM` view (`TextureDesc::encodedView`). Elsewhere `ui.slang` decodes ImGui's sRGB colors and the sRGB target blends in linear light, which makes the anti-aliased edges of light text on a dark window brighter (byte 188 instead of 140 for white over 0.10 at half coverage): text looks bolder and window backgrounds lighter than ImGui's design. A UNORM render target the UI draws into, copied or composited onto the swapchain, would give the same look everywhere, at the cost of a full-screen pass. (2) The style and the fonts are scaled by the display's content scale once, at startup ([ui.cpp:188](../src/renderer/ui.cpp#L188), [uiPlatform.cpp:77](../src/platform/uiPlatform.cpp#L77)); a window moved to a display with another scale keeps the first one. Read it again when SDL reports `SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED`, and rescale from the unscaled style. (3) `ui.slang` maps positions by the display size alone, as if `ImDrawData::DisplayPos` were (0, 0), while `getUiScissor` subtracts it. That holds for the main viewport, the only one RASM has; ImGui's multi-viewports or a UI drawn into an offset target (render-to-texture) need the position in the push constants too. *Confirmed.*

**D32 — The Buffers section finds a target by its name, and names repeat.** *Extended 2026-11-24:* with several views (`Engine::render(views, count)`) each view's HDR target has its own name (`scene_hdr`, `scene_hdr_1`, ...), but the bloom levels of every view are named alike (`bloom_down_1`, ...), so only the first view's can be picked. `Inspection::target` is a `RenderTargetDesc::name`, and `updateInspectPass` takes the first entry whose name, kind and attachment match ([inspector.cpp:268](../src/renderer/inspector.cpp#L268)). Names are not unique: every directional light's shadow names its maps `shadow_cascade_0`, `shadow_cascade_1`, ... ([gpuScene.cpp:1089](../src/renderer/gpuScene.cpp#L1089)), so with two shadowed suns the list shows two `shadow_cascade_0 depth` entries and picking the second one shows the first. The same holds for two targets an application names alike. Name the maps after their light (as the spot and point maps are), or let an entry carry its handle and match by it. *Confirmed* by reading.

**D33 — An engine holds at most 7 meshes in its lifetime.** *Fixed 2026-11-22:* `MAX_MESHES` is gone, and an engine creates and loads meshes until its geometry pool is full. A mesh needs one row of the geometry table per sub-mesh (`EngineConfig::geometryPoolSubMeshes`) and ranges of the vertex, index, color, skin and morph pools; `GeometryPool::fits` checks all of them for the whole mesh before anything is created and logs what it needs, what is in use and the `EngineConfig` field to raise ([geometryPool.cpp:82](../src/renderer/geometryPool.cpp#L82)). The animation pool has its own check (`EngineConfig::animationPoolBytes`). `createMesh` takes its handle only after the upload, so a mesh that does not fit uses no index. The golden-image runner uses one engine for its 15 tests, and the goldens did not move. Handle reuse stays with `D4`. The original finding follows. `MAX_MESHES` is 8 ([mesh.h:19](../include/rasm/mesh.h#L19)) and `createMesh` and `loadGLTF` / `loadMesh` refuse a handle index at or above it ([mesh.cpp:70](../src/assets/mesh.cpp#L70), [mesh.cpp:122](../src/assets/mesh.cpp#L122)). Indices start at 1 and are never reused (`B13`, `D4`), and a glTF file is one mesh, so an application can create or load only 7 meshes in an engine's life, failed loads and meshes it no longer uses included. Nothing else is sized by it: the registry is a `std::vector`, and the GPU side lives in the geometry pool and its sub-mesh table (`EngineConfig::geometryPoolSubMeshes`). The golden-image runner needs 3 engines for its 13 models because of it (`tests/image/imageTests.cpp`). Raise the limit or drop it (an `EngineConfig` field like `maxLights`), and reuse handles with `D4`. *Confirmed* by reading and by the runner.

**D34 — An engine creates at most 255 materials in its lifetime.** *Fixed 2026-11-22 (`D4`):* `MAX_MATERIALS` is gone; `EngineConfig::maxMaterials` (4096 by default) sets how many materials are alive at once, the material table has one more row, and a full table logs an error that names the field ([material.cpp:71](../src/assets/material.cpp#L71)). `destroyMaterial` frees the row and the handle index for the next material. The original finding follows. `MAX_MATERIALS` is 256 ([engine.h:47](../include/rasm/engine.h#L47)), and it sizes the material table, one row per handle index ([gpuScene.cpp:442](../src/renderer/gpuScene.cpp#L442)). `createMaterial` and the glTF importer's `loadMaterial` refuse an index at or above it ([material.cpp:74](../src/assets/material.cpp#L74), [material.cpp:168](../src/assets/material.cpp#L168)). Indices start at 1 and are never reused (`B13`, `D4`), and every glTF material is a new one, so a streaming application runs out: Sponza alone has 25. Past the limit a glTF primitive falls back to its entity's material, or the default one, with only a warning, and `createMaterial` returns an invalid handle. Size the table from `EngineConfig` (like `maxLights`) and reuse its rows with `D4`'s destroy APIs. *Confirmed* by reading.

**D35 — Some lifetime paths still wait for the GPU.** *Extended 2026-11-24:* `Engine::resizeRenderTarget` waits for the frames in flight (the last values of both fences) when a size changes, because the new textures take the old ones' bindless slots, which those frames may read; `Engine::render(views, count)` calls it when a view's rect or texture changes size, so dragging an editor's splitter waits each frame of the drag. New slots for the new textures, with the old ones through the release queue (as below), would remove the wait; the material rows that name the slots would then be written again. Deferred destruction (`D4`) frees textures, buffers and render targets without a wait, but three paths still block the CPU: the last graph that lets go of a scene view waits for the frame and compute fences before it frees the view's buffers ([gpuScene.cpp:1440](../src/renderer/gpuScene.cpp#L1440)); placing transient render targets again waits for the device to be idle, because the new textures are written into the old ones' bindless slots at once ([renderContext.cpp:909](../src/rhi/renderContext.cpp#L909)); and growing the animation buffers waits for both fences ([animation.cpp:708](../src/renderer/animation.cpp#L708)). Each happens on a graph rebuild or a new animated entity, not every frame, so a streaming application that only creates and destroys meshes and textures does not hit them, but one that rebuilds graphs or starts many animations stalls a frame each time. Give the view buffers and the old animation buffers to the release queue, and let a re-placed target take new slots and release the old ones through it. *Confirmed* by reading.

**D37 — Skinned and morphed meshes have no meshlets.** `buildMeshlets` skips a sub-mesh with a skin or morph targets ([meshlets.cpp](../src/assets/meshlets.cpp)): its vertices move every frame, so meshlet spheres and normal cones made from the bind pose would cull visible pieces. Such a mesh is culled per draw with the posed sphere of the `Animate` pass, and drawn whole. Meshlets for them need bounds that move: per meshlet and frame from the `Skin` pass's posed vertices (its cost grows with the vertices, like `P18`), or per joint like the posed sphere (cones would then have to widen by the joints' rotation). Like `D29`, a LOD and its meshlets are built in the bind pose. *Confirmed* by reading.

**D38 — The IME window does not follow the text field.** Dear ImGui reports where the text cursor is through `ImGuiPlatformIO::Platform_SetImeDataFn`, and RASM sets no handler, so an input method (Japanese, Chinese, Korean) opens its candidate window where the window system puts it, not under the field being typed in. Typing works; only the candidate window's place is wrong. Fix: a `Platform` hook that takes the rectangle (`SDL_SetTextInputArea` for SDL), set from `updateUiPlatform`, and a way to read it for `NATIVE` applications.

**D39 — The SDL platform needs a native window handle.** Since `D7` the SDL platform makes no surface through SDL: `getNativeWindow` in [sdlPlatform.cpp](../src/platform/sdlPlatform.cpp) reads the Win32, Cocoa, X11 or Wayland handle from SDL's window properties, and the device makes the surface from it. SDL's other video drivers have no such handle, so the engine no longer starts on them; the one that matters is `kmsdrm` (a Linux console with no X11 or Wayland), where `SDL_Vulkan_CreateSurface` used `VK_KHR_display`. The error names the driver. Fix, if a target needs it: a `NativeWindowType` for a display plane (`VK_KHR_display`, picked by the device), or an opt-in fallback that lets SDL make the surface. *Confirmed* by reading.

**D40 — A view texture has no mips.** A view texture (`ViewOutput::target`) is a color target with one mip, drawn every frame by the tone-map pass ([toneMap.cpp](../src/renderer/toneMap.cpp)). A material that samples it on a far or slanted surface (a TV across a room) reads one texel per pixel from a much larger image, so the picture shimmers as the camera moves, as an unmipmapped texture does (`docs/guides/mipmaps-sampling.html`). Build its mips after the tone map (a compute pass that halves level by level, like the bloom chain) when a view texture is sampled smaller than its size. *Confirmed* by reading; the TV of `examples/20_views` is seen near its size, so it does not show there.

**D41 — The C API's last error hears every spdlog user on the thread.** The C layer adds its sink to spdlog's default logger ([cApi.cpp](../src/c/cApi.cpp), `initialize`), and RASM logs through that logger. With the vcpkg `x64-windows` triplet spdlog is a DLL, so the default logger is shared with every module of the process that uses the same spdlog DLL. An error that such a host module logs on a thread becomes that thread's `rasm_get_last_error`, reaches the C API's log callback, and, when it happens during a C call (only through the log callback today), turns that call's result into `RASM_ERROR_FAILED`. Fix direction: RASM logs through a logger of its own (`spdlog::get("rasm")`), and the C layer adds its sink to that one. *Likely.*

**D42 — The environment and the free-fly camera assume the world's +Y is up.** *Fixed 2026-11-25:* `SceneEnvironment::orientation` (a quaternion, identity by default) places the environment in any frame after its `rotation` around +Y, through `SceneData::environmentOrientation` and `toEnvironment`; `CameraController::FreeFly::up` (zero or +Y: as before) makes the free-fly controller yaw around it. Both are in the C API 1.2 (`rasm_scene_environment::orientation`, `rasm_camera_controller::free_fly_up`), and `examples/23_large_world` uses both. The original finding follows. A map engine on a globe places a scene in a local frame whose up is the ellipsoid's normal (`examples/23_large_world`: east, up and south at Paris, 48° from +Y). `SceneEnvironment::rotation` turns the environment only around +Y ([scene.h:26](../include/rasm/scene.h#L26)), so its sky and image-based light are tilted there, and the example draws without an environment; the free-fly controller yaws around world +Y ([cameraController.cpp:78](../src/scene/cameraController.cpp#L78)), so it rolls the horizon in such a frame. Fix: a full rotation (a quaternion) for the environment, and an up vector for the free-fly controller. *Confirmed* by reading, from the large-world work.

**D43 — A scene has one drawn set of tiles, whatever views draw it.** A `TileStreamer` adds the drawn tiles' entities to its scene ([tileStreamer.cpp](../src/scene/tileStreamer.cpp), `show`), and every view of the scene draws that one set; a tile's screen error is the largest over the views (`getTileScreenError`, [tileResidency.cpp](../src/scene/tileResidency.cpp)). A main view and a map of the same scene therefore share one cut: the map draws the main view's fine tiles near the camera, which is right but costs it triangles it does not need, and two views far apart (split screen over two cities) both draw the union of their cuts. Two scenes with a streamer each give each view its own cut, but load a tile both need twice. A per-view cut needs the entity's visibility per scene view (a view mask in `InstanceData`, culled in `countMain`) instead of scene membership, and the stand-in rule per view. *Confirmed* by reading.

**D44 — Terrain tiles bend by a parabola, so whole-globe roots do not fit.** A terrain tile is flat in its own frame and bends down by d² / 2R (`TerrainMaterial::sphereRadius`, [terrain.slang](../shaders/lib/terrain.slang), `getTerrainVertex`), which is d⁴ / 8R³ off the sphere: 5 cm at 100 km, 50 m at 1000 km, and nothing like a sphere for the roots of a globe's quadtree (a hemisphere each). An application with a whole-globe tree must start its terrain a few levels down, or draw the roots some other way. Fix direction: a grid placed on the ellipsoid (positions from latitude and longitude per vertex, in the tile's render-space frame, as `quantized-mesh` tiles carry them), or a cubic term. *Confirmed* by reading, from the terrain work.

**D45 — A see-through line blends twice where its pieces overlap.** A line is a quad per segment plus its joins and caps ([vector.cpp](../src/scene/vector.cpp)), and on the inner side of a turn the two quads overlap, as a join's fan overlaps its quads. The pieces are blended one after another (premultiplied alpha, [rasm.slang](../shaders/passes/rasm.slang)), so a line whose `VectorMaterial::color` has an alpha under 1 is darker where they overlap: at every joint, and along its inner side. An opaque line shows nothing (only the one-pixel smooth edge, where both pieces are partly covered). Fix direction: build the inner side of a join from shared vertices, as a miter on the inner side (Mapbox's way), or draw a see-through layer into a stencil first so each pixel is blended once. *Confirmed* by reading, from the vector work.

**D46 — Text is laid out without shaping.** `addVectorLabels` ([vector.cpp](../src/scene/vector.cpp)) maps each decoded codepoint to one glyph of the atlas (`findGlyph`) and moves the pen by its advance and the kerning pairs stb_truetype reads (`kern` table, GPOS pair adjustment): enough for Latin, Greek and Cyrillic. Scripts whose glyphs depend on their neighbours (Arabic joining forms, Indic conjuncts and reordering), right-to-left and bidirectional text, combining marks placed on their base, and ligatures are drawn wrong or as separate letters; the atlas also holds only the codepoints asked for (ASCII and Latin-1 by default), and a codepoint it lacks is drawn as the fallback `?`. Fix direction: shape with HarfBuzz into glyph ids and positions, keep glyph ids (not codepoints) in `FontAtlas`, and build the atlas from the glyphs a tile's text uses. *Confirmed* by reading, from the labels work.

**D47 — Label placement does not know depth.** *Partly fixed 2026-11-25 (`B36`):* the GPU now shows or hides each label whole, from its anchor against the depth (the `Label Depth` pass), so a label half behind an object no longer shows half. Still open: placement on the CPU runs before that answer and does not read it back, so a hidden label still takes its room and can push a visible label out. The pass's per-slot fade is the visibility the fix direction asks for: reading it back two frames later into `placeViewLabels` (a host-readable copy per frame slot, like `readPicks`) would close this. The original finding follows. `placeViewLabels` ([gpuScene.cpp](../src/renderer/gpuScene.cpp)) places labels on the CPU from their anchors and boxes only, and the GPU hides a placed label per pixel by the depth of its anchor (`getVectorVertex`). So a label whose anchor is behind a hill or a building still takes its room and can push a visible label out, and a label half behind an object shows its other half. Fix direction: test each anchor against the view's Hi-Z of the frame before (a few texels, on the CPU from a small readback, or on the GPU in a compute pass that writes the label slots' visibility before the draws) and treat a hidden anchor as not in view, so it fades out and frees its room. *Confirmed* by reading, from the labels work. Picking (2026-11-25) does not give this for free: a pick is a rect asked for on demand, while placement needs the depth at every label anchor in every view and frame. The probe pass of the fix direction is the same small idea as a pick, though: a compute pass after the view's draws that tests each placed anchor against the depth (or the Hi-Z) and writes a visibility per label slot to a host-readable buffer of the frame slot, read two frames later by `placeViewLabels` like a pick (`readPicks`), with the slot's label stamps to drop a slot that changed owner.

**D48 — A pick covers at most 256 × 256 pixels.** `Renderer::pick` ([picking.cpp](../src/renderer/picking.cpp)) refuses a rect over `MAX_PICK_SIZE` on a side: each pixel costs 32 bytes in the slot's targets and the host copy, and box selection over most of a 4K view would need about 250 MiB. A box that large is another query: either every draw whose bounds meet the box's frustum, visible or not (the pick's own cull, `countMain` with the rect's planes, read back as a list of instance rows instead of drawn), or the ID pass sampled with a stride (a viewport scaled down, so one pick pixel stands for k × k view pixels and a feature thinner than k pixels can be missed). Today an application can tile a big box into picks of 256 × 256 over several frames. *Confirmed* by design, from the picking work.

**D49 — An orthographic zoom maps the pointer through the camera's stored box.** `updateCameraRig(rig, projection, input)` ([cameraController.cpp](../src/scene/cameraController.cpp), `zoomOrthographic`) turns `CameraInput::pointer` into a point of the box from the projection's own `left`, `right`, `bottom` and `top`, but a view draws the box fitted to its own aspect (`getProjectionMatrix(camera, aspect)` keeps the width and sets the height). When the stored box has another aspect than the view (a camera whose box was never fitted, a window that changed shape, or one camera drawn in views of different shapes), the pointer's offset is off by the ratio of the two aspects, so the point under the pointer drifts while zooming, and a pan moves at the wrong speed; a perspective pan reads the stored `Perspective::aspect` the same way. The engine fits every camera to the main window when it changes size (`updateCameraAspectRatio`), which is right for a camera that fills it and wrong for one in a view of another shape, such as `22_c_api`'s square map. `27_cad_views` fits each view's box to the view's pixels before its rig runs, so it stays exact. Fix direction: give the rig the view's aspect (a field of `CameraInput`, filled by `takeCameraInput` from the area), and fit the box to it before the zoom. *Confirmed* by reading, from the orthographic controls work.

**D50 — Point clouds cast no shadow, and debug views draw them as they are.** The cull pass leaves a point cloud chunk out of a depth-only view (`cull.slang`, the point run with `VIEW_DEPTH_ONLY`), and `drawSceneView` skips the point run there, so points throw no shadow on the meshes under them; and the point run keeps its own pipeline in a debug view (`drawSceneView`), so `DebugView::OVERDRAW`, `LODS` and the others show points shaded. A LiDAR cloud is usually unlit, so neither was needed for PR 2 of the visualization item. Fix direction: a depth-only variant of `points.slang`'s `vertMain` with an empty fragment stage for shadow maps, and `RASM_DEBUG_VIEW` variants of its fragment stage (the prefix count as the LOD color). *Confirmed* by reading, from the point cloud work.

**D51 — A point cloud octree is built in CPU memory, from every point at once.** `buildPointCloudOctree` ([pointCloudOctree.cpp](../src/scene/pointCloudOctree.cpp)) sorts all the points and keeps the octree's copy (24 B a point, 28 with colors) beside the loaded file's (`PointCloudData`, 24 B a point and more), and `AssetLoader::loadPointCloud` reads the whole file. A cloud streams to the GPU under a budget (PR 3 of the visualization item), but it must fit in RAM twice while it is built, and once after. Fix direction: Potree's out-of-core build (count points per cell in a first pass over the file, write each cell's points to its own file, build each cell's subtree alone, then the top levels from their samples), and a node store on disk that the streamer reads a node at a time. *Confirmed* by reading, from the point cloud streaming work.

**D52 — Glyphs cast no shadow, and debug views draw them shaded.** A glyph chunk rides in the point run, which a depth-only view leaves out (`cull.slang` with `VIEW_DEPTH_ONLY`), and only a shaded view culls glyphs one by one (`prepareGlyphCull` in [glyphCull.cpp](../src/renderer/glyphCull.cpp)): arrows over a ground throw no shadow on it, while a mesh beside them does (the `glyphs` image test shows both). In a debug view `drawViewGlyphs` draws them with the shaded `glyphPipeline`, so `DebugView::OVERDRAW`, `LODS` and the others show glyphs shaded. Fix direction: a glyph buffer per depth-only view (the cull as for a shaded view, from the shadow view's frustum and the camera's LOD), and `rasm.slang`'s glyph vertex stage in `shadow.slang` with `RASM_GLYPHS`; a `RASM_DEBUG_VIEW` glyph pipeline (the LOD the cull picked as the LOD color). *Confirmed* by reading, from the glyph work.

**D53 — A draped band takes no per-point values.** `addVectorLines` gives each point's value to the vertices it makes, and a draped line's cut points the value between their segment's ends, but a draped band (`LineShape::drapeWidth` > 0, `pushDrapedLine` in [vector.cpp](../src/scene/vector.cpp)) is built on a flat copy of the line and clipped into new pieces, whose vertices are white: a band with scalars or colors draws the colormap's or the material's white. Fix direction: carry the value through `pushLine`'s flat band (a `GroundPoint::value` per flat point) and interpolate it at the clipped corners as `cutTriangle` cuts them. *Confirmed* by reading, from the data lines work.

**D54 — Point clouds cannot be drawn see-through.** A `POINTS` material is opaque by design (`PointMaterial::color` "points are opaque, alpha 0 hides them"): `getBlendMethod` ([gpuScene.cpp](../src/renderer/gpuScene.cpp)) keeps a `POINTS` material `SORTED` and the point run in the opaque runs, and the compute path for small points ([pointRaster.slang](../shaders/passes/pointRaster.slang)) keeps only the nearest point of each pixel with a 64-bit atomic max, which no blending can follow. So a dense scan cannot be shown see-through (X-ray, density) as the weighted and additive methods show meshes and glyphs (`docs/guides/weighted-oit.html`). Fix direction: an opacity in `PointMaterial`; a `POINTS` material with `AlphaMode::BLEND` sent to the triangles path (no compute raster), in a weighted or additive point run drawn by a `points.slang` pipeline with `RASM_WEIGHTED` or `RASM_ADDITIVE` into the view's weighted target, as glyphs are; its range and pick as the weighted glyphs'. *Confirmed* by reading, from the weighted blended transparency work (the follow-up of its plan item).

**D55 — An export's bloom does not scale with its pixel scale.** `ExportDesc::pixelScale` multiplies every size given in pixels (lines, text, points, the grid, label cells) and the LOD error, so a 4x export at scale 4 looks like the screen, sharper. The bloom keeps its reach in output pixels: its 6 levels (`BLOOM_LEVELS`) reach about 375 pixels whatever the image's size, so at scale 4 the glow is 4 times tighter than on screen (`docs/guides/tiled-export.html#scale`). Fix direction: add log2(scale) levels to an export's bloom chain, and grow `EXPORT_BLOOM_GUARD` with them (the guard band then costs s times more pixels a tile), or compute the bloom once from a lower-resolution render of the whole image and sample it in every tile. *Confirmed* by design.

**D56 — An export runs only in the frames of `Renderer::render`, one sample a frame.** Its passes live in the view graph (`ViewGraph::build` adds them after the views), so an application that runs its own `RenderGraph` must call `render(nullptr, 0)` between its frames, and each frame draws one sample of one tile: a 16K export with 16 samples and 2048-pixel tiles takes about 1 100 frames. Fix direction: an `addExportPasses` for an application's graph, and several samples a frame (one scene view per sample, or the samples of one tile in one frame with their own `SceneData` slots) when the application asks for a faster export. The C API's `rasm_render_graph_execute` (1.17) is such a graph: a C program calls `rasm_render_views(renderer, NULL, 0)` between its frames for an export. *Confirmed* by design.

**D57 — A C tile streamer must be destroyed before its renderer.** `rasm_tile_streamer` holds a `TileStreamer` that uses its `Renderer` ([cTiles.cpp](../src/c/cTiles.cpp)), and `rasm_tile_streamer_destroy` after `rasm_renderer_destroy` or `rasm_engine_destroy` reads freed memory. A binding whose garbage collector frees objects in any order (Python, C#) can break the rule without knowing. Since 1.17 a `rasm_render_graph` does not have the problem: `rasm_renderer` lists its graphs and its destructor detaches them, so a later call fails with an error and destroy only frees the C object. Fix direction: the same list for tile streamers (and any later C object that holds a renderer): `~rasm_renderer` destroys each streamer's `TileStreamer` and marks it detached. *Confirmed* by reading.

**D58 — An export draws no view shadows.** `Renderer::exportView(view, desc)` takes a `View`, but `addExportPasses` ([export.cpp](../src/renderer/export.cpp)) adds only the scene passes of its copy of the camera, with no `addShadowPasses`, so `View::shadows` (since C API 1.18) are dropped and the still is unshadowed while the same view on screen has shadows. A tile's cascades must be fitted to the whole image's frustum, not to the tile's, or the tiles' shadows do not meet at their seams; the shadow views would also need the export's frame (`ExportFrame`) for their LODs. Fix direction: in `addExportPasses`, add each of the view's shadows with the export camera before its scene passes, fitted to the full image (the `prepareSceneView` path already uses `exportFrame->imageWidth` and `imageHeight` for the reader), and draw them once per tile sample. *Confirmed* by reading, from the view shadows work (`docs/development_plan.md`, the rest of the C++ API in C, PR 2).

**D59 — RASM never makes its own ImGui context current.** `createUi` ([ui.cpp](../src/renderer/ui.cpp)) calls `ImGui::CreateContext`, which makes the new context current only when none is, and `createUi`, `pollEvents` (`processUiEvent`), `buildUi` and `destroyUi` then work on whatever context is current. With two renderers with the UI on in one process (two `rasm_renderer`s in C, or a `Renderer` and an `Engine`), or an application that made an ImGui context of its own first, the second renderer sets up and builds the first one's context: its own keeps `imgui.ini` and no `RendererHasTextures`, and both call `NewFrame` on one context. Since C API 1.19 a binding shares the context (`rasm_get_imgui_context`), which makes several contexts more likely. Fix direction: `ImGui::SetCurrentContext(ui->context)` at the start of each of those functions, restoring the previous context after, and `D31` (3) for one context per window. *Confirmed* by reading, from the C UI work (`docs/development_plan.md`, the rest of the C++ API in C, PR 3).

**D36 — A 16-bit image loads as 8 bits.** stb_image gives 8 bits per channel: `loadTexture` decodes with `stbi_load` ([textureLoad.cpp:36](../src/assets/textureLoad.cpp#L36)), and a glTF's PNG with `stbi_load_from_memory` in its image job, which logs one info line for a 16-bit image ([meshImport.cpp:545](../src/assets/meshImport.cpp#L545)). Before `P14` such a glTF image was refused. Data that needs the precision loses it: a height map shows steps, and a 16-bit normal map bands on smooth curves. Decode with `stbi_load_16` and keep `R16G16B16A16_UNORM` (or BC5 / BC6H through KTX2) for data slots. *Confirmed* by reading.


---

## 4. Performance

**P1 — Every buffer is host-visible and mapped.** *Fixed 2026-11-04:* only buffers with `BufferDesc::hostVisible` (the per-frame model and scene data) are forced into host-visible memory. Other buffers are device-local, use `ALLOW_TRANSFER_INSTEAD` so they stay mapped where device-local memory is host-visible (except a `BufferDesc::staged` buffer on a discrete GPU, `P35`), and are otherwise filled through `rhi::UploadManager`: a staging ring with batched copies and timeline-fence completion ([architecture.md §12](architecture.md#12-rhi)). The original finding follows. (`HOST_ACCESS_SEQUENTIAL_WRITE | MAPPED`, [vulkanContext.cpp:205-208](../src/rhi/vulkan/vulkanContext.cpp#L205-L208)). On discrete GPUs without ReBAR, the mega vertex and index buffers end up in system RAM and every vertex fetch crosses PCIe. Static data should go to device-local memory through staging (or `ALLOW_TRANSFER_INSTEAD`). Keep host-visible memory for per-frame data only.

**P2 — Texture path.** *Fixed 2026-11-22:* host image copy is optional and used only where it costs the GPU nothing, mips are made on the worker, a model's texture copies spread over frames, and sampled textures are sub-allocated (`P22`) ([architecture.md §5](architecture.md#5-materials-and-textures), the guide `docs/guides/texture-uploads.html`). The `hostImageCopy` feature is enabled only when present ([vulkanDevice.cpp:588](../src/rhi/vulkan/vulkanDevice.cpp#L588)); a format is copied on the host only with `HOST_IMAGE_TRANSFER`, `optimalDeviceAccess`, `SHADER_READ_ONLY_OPTIMAL` among the copy layouts and a device-local memory type that a copied image may use too (`getHostCopyMemoryTypes`, [vulkanUtils.cpp:188](../src/rhi/vulkan/vulkanUtils.cpp#L188)), and its images are allocated only from those types, with no host-access flags. On the RTX 3060 the driver allows `HOST_TRANSFER` images only in host-visible types; host-copied into the BAR type, the GPU stalled 50 to 185 ms while a model's textures loaded, so host copy is off there and every texture comes through the staging ring; lavapipe copies 13 formats on the host. PNG and JPEG mips are made on the worker (`buildTextureLevels`, [mipChain.cpp:89](../src/rhi/mipChain.cpp#L89)), sRGB in linear light with alpha weighting, data as stored, glTF normal maps renormalized (the `sponza` golden moved for it). A glTF's textures are filled one at a time under `LOAD_BUDGET` (`PendingTextureLoad::levels`), and `isLoaded(mesh)` waits for them. `examples/10_ktx2_textures --measure` (Release, headless, RTX 3060), longest frame while loading: Flight Helmet PNG 206 → 10 ms, Sponza 280 → 6 ms, Flight Helmet KTX2 28 → 5 ms; whole load 0.92 → 1.00 s and 0.97 → 1.06 s, since the mips now follow the decode on the model's one worker (`P14`, fixed since: 191 and 200 ms). `VRAMStats::vramAllocated` counts the bytes in VMA's blocks. The original findings follow.
- Sampled images are created with `HOST_ACCESS_*` allocation flags for host image copy ([vulkanDevice.cpp:633-637](../src/rhi/vulkan/vulkanDevice.cpp#L633-L637)), which can push them into host-visible memory.
- Each image gets a dedicated allocation, and an image's (PNG, JPEG) mips are generated on the CPU on the main thread: 200 ms for the Flight Helmet's 15 PNG textures in a Release build. KTX2 files bring their mips.
- *Fixed 2026-11-02 (`D1`), 2026-11-04:* bindless textures share a fixed set of six samplers (`SamplerType`), picked per slot; glTF textures map their sampler onto it. Originally each texture created its own `VkSampler` and called `vkGetPhysicalDeviceProperties`. Drivers often cap samplers at about 4000, so use a handful of shared samplers.
- Host image copy also requires the `hostImageCopy` feature, which narrows hardware support. *Partly fixed 2026-11-21:* `HOST_IMAGE_TRANSFER` is checked per format (`VulkanDevice::queryFormatSupport`), and a format without it, or every format with `EngineConfig::hostImageCopy` false, is filled through the staging ring (`UploadManager::uploadTexture`). Still open: the device still requires the `hostImageCopy` feature, so a GPU without it can't start, though the staging path would serve it. The original finding: it also needs `HOST_IMAGE_TRANSFER` support per format, which nothing checked, so a driver that offers it for RGBA8 only failed every environment's `R16G16B16A16_SFLOAT` image.
- *Fixed 2026-11-21:* GPU-compressed textures. KTX2 files (`loadTexture`, glTF `KHR_texture_basisu`) are transcoded on the worker to BC7/BC5/BC4, ASTC or ETC2, whichever the device samples, with RGBA8 as the fallback, and keep the file's mips ([architecture.md §6](architecture.md#6-asset-import)). The Flight Helmet takes 68.6 MiB of video memory instead of 272.6 MiB as PNG. Images (PNG, JPEG) still become RGBA8 with mips made on the main thread.

**P3 — No instancing.** *Fixed 2026-11-07:* geometry is uploaded once per mesh into the geometry pool (since `P6`, 2026-11-04), and each draw now names an instance row (transform, geometry index, material index) through `DrawInfo::firstInstance`. Materials live once in the material table instead of being copied into every draw's `Modeldata`. Several instances of one sub-mesh are still separate draws, not one draw with `instanceCount > 1`. The original finding follows. Each entity copies its mesh into the mega buffer. `00_hello_scene` uploads the bunny three times ([gpuScene.cpp:134-157](../src/renderer/gpuScene.cpp#L134-L157)). Separate *geometry* (uploaded once per mesh) from *instances* (transform + material + mesh-range index).

**P4 — Per-call overhead in `RenderContext`.** *Fixed 2026-11-22 (`D4`):* each object type is a table of a `HandlePool` and a vector of `rhi::` pointers indexed by handle, so a lookup is a generation compare and an array access, with no hash; a texture's bindless slot is stored beside it, so `getBindlessTextureIndex` (called per pass) is no hash either. *Partly fixed 2026-11-02 (`D1`):* the tables hold pointers to `rhi::` objects, so a lookup copies nothing and device addresses are stored on `rhi::Buffer`. Every call still hashes its handles, until the index-based pools of `D4`. The original finding follows. Every call hashes a handle and **copies** the backend struct, including a `ResourceDesc` with a `std::string` (e.g. `fillBuffer`, [renderContext.cpp:675](../src/rhi/renderContext.cpp#L675); `getBufferDeviceAddress`, [renderContext.cpp:750](../src/rhi/renderContext.cpp#L750)). Use index-based pools, return references, and cache device addresses.

**P5 — Large by-value copies in the scene code.**
- *Fixed:* scene preparation no longer copies meshes (`processMesh` is gone), and `drawScene` copies nothing. Since 2026-11-07 the draw list is built from the GPU scene tables (`D6`).
- *Fixed 2026-11-04:* `getMeshByteSize` copied a whole `Mesh`; it now sums the sub-mesh ranges by reference.
- *Fixed 2026-11-07:* `RenderGraph::execute` copied `Scene`, which held 1,040 handles ([renderGraph.cpp:148](../src/renderer/renderGraph.cpp#L148)). It now reads only the camera handle; `Scene::entities` became a vector of up to 65,536 handles, which would have made the copy far worse.

**P6 — CPU memory retention.** *Fixed 2026-11-04:* meshes live in an engine-wide geometry pool (one vertex and one index buffer), uploaded when their load finishes, and keep only their pool ranges. The CPU vertex and index arrays, the `tinygltf::Model` and the `stbi` pixels are freed right after upload. Files are read and decoded on worker threads (`std::async`), and the main thread uploads the results at the start of a frame. A scene is prepared once all its assets are loaded. *Partly fixed 2026-11-01:* `GLTFRaw` no longer kept a copy of the `tinygltf::Model`. The original finding: CPU vertex and index arrays and the `stbi` pixel data for every `loadTexture` stayed resident for the engine's lifetime.

**P7 — Per-frame CPU work grows with draw count.** *Partly fixed 2026-11-07:* `updateTransform` rewrites only that entity's instance rows, and `syncGpuScene` uploads only the dirty row ranges of each frame slot. `drawScene` no longer loops over draws: it issues the cull-mode runs stored with the draw list. In `03_instances`, CPU frame time is the same with 1k and 10k static cubes. Still open: GPU-side transforms, and the draw-list rebuild. Only the scenes that hold a changed entity rebuild, and an entity triggers it once, when it becomes drawable, not once per finished texture. The rebuild itself is still O(entities in the scene) when the scene changes. The original finding follows. `updateUniforms` recomputes and uploads every model and normal matrix every frame, with no dirty tracking. That is fine now, but it becomes the bottleneck at 10⁴–10⁵ instances. Plan for dirty ranges and, later, GPU-side transform computation.

**P8 — Shader and pipeline creation.** *Fixed 2026-11-22:* `EngineConfig::cacheDir` ("cache" beside the executable, else the user's local cache folder; "" for none) holds a SPIR-V cache and a `VkPipelineCache`. A shader's entry, `shaders/<key>.shader`, is found by a 128-bit FNV-1a key of every input (the Slang build tag, the target and every compiler option, every file of `shaders/lib`, the source with its defines, the module name and entry point) and holds the struct layouts too, which `validateRasmStructs` checks on every hit; the folder is kept under 256 MiB. The pipeline cache, one file per GPU, is checked (vendor, device, driver version, UUID, Vulkan's own header, checksum) before use, merged with what another run saved and written through a temporary file and a rename. Every pipeline shares the bindless set layout's pipeline layout, with one push-constant range for every stage, and `RenderContext::pushConstants` lost its stage. `09_gltf_materials` (Release, headless): 2.43 s to the first frame without caches, 1.02 s warm. The vertex and fragment shaders of a pipeline are still compiled from two modules (`P23`). The original finding follows. Shaders are compiled from source on every launch. There is no `VkPipelineCache` and no SPIR-V cache. A pipeline layout is created per pipeline even though all pipelines share the same set layout and push-constant range.

**P9 — Shader detail.** *Partly fixed 2026-11-21:* the lights are read through `SceneData::lightsPtr`, one at a time in `shadePBR`'s loops, and `PBRInfo` holds no lights. `fragMain` still copies the material into `PBRInfo`. The original finding follows. `fragMain` copies all 8 lights and the material into a `PBRInfo` local ([rasm.slang:127-158](../shaders/passes/rasm.slang#L127-L158)). Read through the pointer, or pass indices, to keep register pressure down.

**P10 — The upload staging ring may be placed in video memory.** *Fixed 2026-11-22:* a staging buffer has `BufferUsage::TRANSFER`, which has no device-address bit ([vulkanDevice.cpp:276](../src/rhi/vulkan/vulkanDevice.cpp#L276)), so the rings go to system memory, unless all of video memory is host-visible (resizable BAR, or memory shared with the CPU, `VulkanDevice::wholeVramMapped`): there they ask for video memory ([vulkanDevice.cpp:757](../src/rhi/vulkan/vulkanDevice.cpp#L757)), since the GPU then copies within video memory and no small BAR heap is used up. Measured on the RTX 3060 with resizable BAR: the rings in system memory made the copies take 2.6 times as long on the GPU (the `17_streaming` burst 80 against 30 ms) and the burst load 486 to 507 ms against 432 to 441 ms. The original finding follows. Every buffer gets `VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT` ([vulkanDevice.cpp:277](../src/rhi/vulkan/vulkanDevice.cpp#L277)), and VMA counts any usage other than transfer as GPU access. With `VMA_MEMORY_USAGE_AUTO` and `HOST_ACCESS_SEQUENTIAL_WRITE`, `hostVisible` buffers, including the 64 MiB staging ring, then prefer device-local host-visible memory (ReBAR) over system RAM. That wastes the small BAR heap on systems without full ReBAR, and a staging buffer gains nothing from being in video memory. Leave the device-address bit off buffers that shaders never read through a pointer, starting with the staging ring. *Likely.*

**P11 — Async compute does not pay off for the scene passes yet.** *Extended 2026-11-22 (`D13`):* the loads' copies now run on the transfer queue where there is one, so only the frames' own fills are flushed before a compute submit; a texture filled from the ring is shared by the graphics, compute and transfer families when there is a compute queue, and the other images by the first two, still with no ownership transfers between them. With `EngineConfig::asyncCompute` the culling and Hi-Z passes run on the compute queue ([gpuScene.cpp:909-985](../src/renderer/gpuScene.cpp#L909-L985)), but the scene passes form a chain (cull, draw, Hi-Z, cull, draw), so each step waits for the other queue, and only the first cull of a frame can run next to the previous frame's last draw. Measured on `05_city` (RTX 3060, Release, present mode switched to IMMEDIATE for the test, two runs each): 1.68 / 1.69 ms per frame without, 1.71 / 1.72 ms with, so the handoffs cost a little more than the overlap saves. Uploads also stop the overlap: a frame with pending copies flushes them on the graphics queue before its first compute submit ([renderContext.cpp:1947](../src/rhi/renderContext.cpp#L1947)), and the compute queue waits for them while `copyBuffers` waits for all earlier graphics work ([uploadManager.cpp:209](../src/rhi/uploadManager.cpp#L209)). And with a compute queue every buffer and image is shared by both families (`VK_SHARING_MODE_CONCURRENT`, [vulkanDevice.cpp:470](../src/rhi/vulkan/vulkanDevice.cpp#L470)), which some GPUs compress less. So the option is off by default. It should pay off once a frame has graphics work that does not depend on culling (shadow maps, several views); measure again then. Ownership transfers for the images only compute reads would avoid the concurrent sharing. *Confirmed* (the measurement).

**P12 — Every fragment reads every shadow, even where its light adds nothing.** *Fixed 2026-11-21:* `shadePBR` shades each shadowed light first without its shadow and calls `sampleShadow` only when that light adds something to the pixel ([pbr.slang:213](../shaders/lib/pbr.slang#L213)); the texture indices still come from `SceneData`, so they stay uniform. The original finding follows. `fragMain` samples the shadow of each light before shading ([rasm.slang:335](../shaders/passes/rasm.slang#L335)), and `shadePBR` multiplies it in only afterwards. In `examples/07_lights` a fragment outside the spot light's cone, past the lantern's `range` or facing away from a light still runs the spot map's 4 gathers, the cube's 4 gathers and the cascade loop, then multiplies the results by 0. Sample a light's shadow inside the light loop of `shadePBR`, only when its attenuation, cone and n·l are above 0 (the texture indices stay uniform: they come from `SceneData`). *Confirmed* by reading; not measured.

**P13 — Every shaded view has a Transparent pass, also without see-through draws.** `addSceneViewPasses` adds the `Transparent` pass to each shaded view because the graph is fixed and the scene may gain `BLEND` materials later ([gpuScene.cpp:1225](../src/renderer/gpuScene.cpp#L1225)). In a scene without them the pass still begins and ends rendering, and the draw pass before it must store its depth for it. On a desktop GPU that is noise (0.001 ms for the pass in `05_city`, RTX 3060), but a tiled GPU loads and stores color and depth for it. Skip the attachments when the view has no blend run (the graph would need a pass that can be empty), or draw the blend run at the end of the last draw pass instead, which loses its GPU timer. *Confirmed* by reading; measured on desktop only.

**P14 — A glTF's KTX2 images are transcoded one after another on one thread, and its PNG and JPEG images get their mips the same way.** *Fixed 2026-11-22 (with `P21`):* the import job only parses the file and plans the images: tinygltf keeps every image's file bytes (`loadImage`), and each image a material reads becomes a child job on the worker pool that decodes it once (or transcodes it once per format) and makes the levels of each slot that reads it (`runImageWork`, [meshImport.cpp:714](../src/assets/meshImport.cpp#L714)); each sub-mesh's LODs are a child job too. No job waits: the last child to end runs `finishImageWork` (a failed KTX2 transcode falls back to the PNG or JPEG source there) and finishes the load ([mesh.cpp:79](../src/assets/mesh.cpp#L79)). Each job reads only its own image and writes only its own levels, so the result is the same in any order. `examples/10_ktx2_textures --measure` (Release, headless, RTX 3060, 24 hardware threads, median of 3): Flight Helmet KTX2 535 → 110 ms, Flight Helmet PNG 931 → 191 ms, Sponza 1052 → 200 ms. The longest frame while a model loads stays about the same, but Sponza's grows a little (`P25`). The original finding follows. Since `P2`, `buildImageLevels` makes each image's mips after the import on the same worker, one image after another: 223 ms for the PNG Flight Helmet's 15 images and 300 ms for Sponza's 69 (Release), and the whole loads went from 0.92 to 1.00 s and from 0.97 to 1.06 s. The fix is the same for both, and belongs with `P21`: a job per image (transcode or mips) on a bounded worker pool, with the import job waiting for its image jobs without holding a worker the pool needs. The mesh load's single worker transcodes every `KHR_texture_basisu` image in turn after the import ([meshImport.cpp:421](../src/assets/meshImport.cpp#L421)), while the other cores wait. The Flight Helmet's 15 textures (12 at 2048²) take most of its 540 ms load in `10_ktx2_textures` (Release, RTX 3060), so the load time grows with the texture count. Transcode the images on several workers (a job per image, once the engine has a thread pool, `P6`), or let Basis transcode a level on several threads. *Confirmed* by reading; the share of the load is estimated, not profiled.

**P15 — Far light clusters are big, so short-range lights crowd them.** A shaded view has 16 × 9 tiles at any resolution and slices that grow with depth ([lightClusters.slang:9](../shaders/lib/lightClusters.slang#L9)), so a far cluster covers much more of the world than a near one. In `examples/11_many_lights --bench --lights 16384` (lights of 0.9 m range, 1920x1080, RTX 3060) the clusters near the horizon fill up: 10 light and cluster pairs are dropped, and their pixels loop over up to `MAX_CLUSTER_LIGHTS` lights that mostly do not reach them. The draw passes take 10.8 ms, against 4.5 ms with 4096 lights of 1.75 m that cover the ground as densely; the example's marker cube per light adds to that, not measured apart. Shrink each cluster to the depths its pixels hold (needs the depth of a pre-pass), cut far tiles finer, or bin lights by depth (z-binning, Drobot 2017). *Confirmed* by measurement.

**P16 — One workgroup prepares every light of a view.** `lightsMain` runs as a single group of 256 threads over all of a view's local lights ([lightClusters.slang:50](../shaders/passes/lightClusters.slang#L50)), so it finds the slices' depth range with workgroup atomics and needs no clearing pass, but its time grows with the light count and the rest of the GPU waits for it. At the default `EngineConfig::maxLights` (16384) each thread prepares 64 lights in a row; the whole `Light Clusters` timer is 0.69 ms there (`examples/11_many_lights --bench --lights 16384`, RTX 3060), and a larger `maxLights` makes it longer. Dispatch a group per 256 lights and reduce the depth range with buffer atomics (cleared by the previous step, or by a fill), keeping the order of the lists. *Confirmed* by reading; not measured apart.

**P17 — A glTF mesh that several nodes use is uploaded once per node.** `traverseNodes` calls `extractGLTFRaws` for every node with a mesh ([meshImport.cpp:366](../src/assets/meshImport.cpp#L366)), so each use becomes its own sub-meshes, with its own copy of the vertices, indices and LODs in the geometry pool. A scene that places one tree mesh on 200 nodes stores the tree 200 times. Extract each glTF mesh once, and give each node's sub-meshes the same `MeshGeometry` with their own transform; the geometry table already allows rows that share geometry. *Confirmed* by reading.

**P18 — The Animate pass poses every playing entity in every frame, and the Skin pass skins it.** `recordAnimation` dispatches one group per row of the animated entity table ([animation.cpp](../src/renderer/animation.cpp)), and `recordSkinning` one group per row and 64 of its skinned vertices, also for an entity whose clip stands still (`speed` 0, or a clip that does not loop and has ended), and for one that no view sees. Its time grows with the playing entities, their nodes and their skinned vertices (numbers in `docs/development_plan.md`, phase 4). Skip an entity whose clip time and matrix are the same as in the frame two before (its slot still holds the result), and one that no view drew in the frame before (the views' visibility flags), keeping its previous transform and its previous skinned vertices for motion (the Skin pass then copies them, or the two slots swap per entity). Since `D30` is fixed, a skinned entity that plays nothing is posed at rest and skinned every frame too, until this is done; so is a morphed one, whose weights stand still, and a group of the Skin pass lists its targets again each frame. A graph that draws two scenes poses all playing entities, also those of other scenes, and two graphs in one frame pose them twice. *Confirmed* by reading.

**P19 — The Skin dispatch is sized by every animated row and the largest skinned mesh.** `recordSkinning` dispatches `entityRows` × ceil(`maxSkinnedVertices` / 64) groups ([animation.cpp](../src/renderer/animation.cpp)), so rows of rigid-only or stopped entities and every row past its own mesh's vertices launch groups that read the row and return, and each group walks its mesh's sub-meshes to find its own ([skin.slang](../shaders/passes/skin.slang)). 10000 entities with rigid clips beside one 50k-vertex character launch about 7.8 million groups to skin 50k vertices. Dispatch over a compact list of (skinned row, 64 vertices) jobs that the CPU appends at an entity's first play, with the sub-mesh in the job. Since morph targets, every posed sub-mesh starts on a multiple of 64 among its entity's skinned vertices (`alignToSkinGroup`, [animation.cpp:391](../src/renderer/animation.cpp#L391)), so a group holds one sub-mesh's weights; a skinned mesh of many small sub-meshes pays for the padding: 30 sub-meshes of 20 vertices take 1920 vertex slots instead of 600 per entity (128 B each, both slots) and three times the groups. The job list would remove the padding too. *Confirmed* by reading, from the skinning review; the padding from the morph targets review.

**P20 — A clip's morph weights take about five times the animation pool they need.** `readWeightSamplers` gives each target its own sampler with its own copy of the key times ([animationImport.cpp:93](../src/assets/animationImport.cpp#L93)), and `buildAnimationPoolData` stores each scalar weight as a 16-byte value with 3 unused floats ([animation.cpp:268](../src/renderer/animation.cpp#L268)). A 52-target face with a 60 s clip at 30 keys per second takes about 1.9 MB instead of 0.4 MB, so a few such clips fill the default 16 MiB `EngineConfig::animationPoolBytes`, and the next mesh fails to load. Share the key times of one weights channel and pack its values per key (all targets in a row), with a sampler kind that the `Animate` pass reads with a stride. *Confirmed* by reading, from the morph targets review.

**P21 — Every load starts its own thread, and nothing bounds how many run at once.** *Fixed 2026-11-22:* loads run on one `WorkerPool` ([workerPool.cpp:150](../src/core/workerPool.cpp#L150)) of `EngineConfig::loadThreads` threads (0: the hardware threads minus one), with two FIFO queues: the child jobs of a running load first, then the loads. A load starts only when its bytes fit `EngineConfig::loadMemoryBudget` (512 MiB) next to what started loads and results waiting for upload hold, or when nothing is held ([workerPool.cpp:181](../src/core/workerPool.cpp#L181)); its bytes are estimated from the header (a mesh: its file size until it is parsed, then its geometry and image files, with its decoded images as a next step that waits for the budget too) and set to the real size when it ends, and the main thread gives them back once it has used the result (a glTF texture's levels when that texture is filled). A waiting load waits as a path in the queue, not as pixels. Each load has a `LoadTicket`: `destroyMesh`, `destroyTexture` and `destroyEnvironment` drop its pending entry and the ticket (`dropLoad`, [workerPool.cpp:85](../src/core/workerPool.cpp#L85)), so a queued job is skipped and a running one gives its result up; `~Engine` drops every load and joins the workers. `waitForLoads` finishes what is ready before it waits for the next load, so a load behind the budget always starts. `Engine::getLoadStats`, a Loads line in the RASM window; tests in `tests/workerPoolTests.cpp`. `examples/17_streaming --burst` (300 Sponza images in one frame, 75 of them destroyed a frame later; Release, headless, RTX 3060, median of 3): peak private memory 3519 → 2964 MiB with at most 512 MiB decoded at once, the longest frame 37.2 → 22.2 ms, all loaded in 501 → 453 ms. On Windows `std::async` went through the MSVC thread pool, so the process had 44 threads at most, not 300 (libc++ on macOS starts one per call); now 23 workers and 39 threads in all. The original finding follows. `loadMesh`, `loadTexture` and `loadEnvironment` each call `std::async(std::launch::async, ...)` ([mesh.cpp:155](../src/assets/mesh.cpp#L155), [texture.cpp:135](../src/assets/texture.cpp#L135), [environment.cpp:63](../src/assets/environment.cpp#L63)), and the result (a whole decoded glTF with its buffers, or a decoded image) stays in memory until `finishLoads` uploads it, under its per-frame budget. An application that asks for 300 map tiles in one frame starts 300 threads, and its peak memory is the size of all 300 decoded files. Before `D33` the mesh cap kept mesh imports at 7 for an engine's life; textures never had a cap. Run the imports on a small pool of workers (the hardware thread count) with a queue, and keep the decoded results that wait for upload under a byte budget. The same pool should run a glTF's per-image work as jobs of their own (`P14`: KTX2 transcodes, and since `P2` the mips of PNG and JPEG images), so an import job must wait for its image jobs without blocking the workers they need. *Confirmed* by reading, from the `D33` review.

**P22 — Freeing a texture costs a dedicated allocation's free, and a frame frees all it may.** *Fixed 2026-11-22 (`P2`):* sampled textures are sub-allocated from VMA's blocks; attachments and storage textures keep a dedicated allocation ([vulkanDevice.cpp:746](../src/rhi/vulkan/vulkanDevice.cpp#L746)). In `17_streaming` (Release, headless, RTX 3060) `collectReleases` takes 0.020 ms per frame on average and 0.15 ms at most (Tracy), against 0.61 and 1.42 ms before, and the longest frame after the first second went from 9.4 to 1.2 ms, so the release queue needs no time budget. The original finding follows. Every texture has a dedicated allocation (`VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT`, [vulkanDevice.cpp:740](../src/rhi/vulkan/vulkanDevice.cpp#L740)), so `destroyTexture` is a `vkFreeMemory`. In `17_streaming` (Release, RTX 3060) the release queue itself costs 0.035 ms per frame that has something to free, but the texture frees inside it take 0.16 ms each on average and up to 13 ms for the fox's texture, and `collectReleases` runs every free that is due in one frame, so destroying a mesh with big textures makes one long frame. Suballocate sampled textures (with `P2`), or give `collectReleases` a time budget and leave the rest for the next frame. *Confirmed* by measurement.

**P23 — A graphics pipeline's source is compiled twice.** `Renderer::createGraphicsPipeline` calls `compileFromString` once for `vertMain` and once for `fragMain`, with the module names `<name>.vert.slang` and `<name>.frag.slang`, so Slang loads, parses and checks the same source (`rasm.slang` with `pbr.slang` and the rest of `lib/`) twice before it links each stage ([renderer.cpp:598-599](../src/renderer/renderer.cpp#L598-L599)). It costs only when the shader cache (`P8`) misses, but then Slang takes 1389 ms of the 1449 ms `09_gltf_materials` spends making pipelines (Release), and the second load's share of it is not measured yet. Load the module once and link both entry points from it, or ask Slang for both stages' code from one composite. *Confirmed* by reading and measurement, from the `P8` work. *Partly fixed 2026-11-26 (`P31`):* a Slang context keeps each module it loaded, named by the source's hash, and a shader worker compiles the queued shaders of one source together, so the stages of a pipeline and the entry points of a file parse it once (`24_map_tiles` cold: 8.3 → 5.0 s of compile time on 8 threads); each stage is still linked and generated on its own, and two workers that take shaders of one source each parse it.

**P24 — A load's steps on the main thread are never split.** *Partly fixed 2026-11-22:* a load's texture is filled in parts of `TEXTURE_FILL_PART` (4 MiB) with `LOAD_BUDGET` checked between them (`RenderContext::fillTexturePart`, `TextureFillProgress`), the ones begun first, and a part stops where the staging ring is full instead of waiting for the GPU; the texture counts as loaded once its last part is on the GPU. The longest frame while the PNG Flight Helmet loads went from 9.2 to 5.0 ms, and the `17_streaming` burst's from 25.8 to 18 to 21 ms, the first frame's pipelines (Release, headless, RTX 3060). Still open: a model's geometry and materials are made in one step, `finishMeshLoad` ([mesh.cpp:272](../src/assets/mesh.cpp#L272)), which is now the longest frame while Sponza loads (7.0 to 7.7 ms, 6.2 ms of it there, Tracy). The original finding follows. `finishReadyLoads` checks `LOAD_BUDGET` only between steps ([engine.cpp:320](../src/engine.cpp#L320)), and two steps can be long. `finishMeshLoad` ([mesh.cpp:272](../src/assets/mesh.cpp#L272)) copies a model's whole geometry into the pool and creates all its materials and textures in one go: 5.6 ms for Sponza (Release, RTX 3060), more for a bigger model. And one texture's fill copies every level in one go: 1.6 ms on average and up to 5.2 ms for a 2048² RGBA8 texture with its mips through the staging ring (the PNG Flight Helmet, Tracy), so about 16 times that for an 8192² one. Since `P2` a model's textures are separate steps, so these are the long frames left while loading. Split a texture's fill by mip level (or rows) across frames, keeping the texture unsampled until its last part, and append a model's sub-meshes to the pool a few per frame. *Confirmed* by measurement, from the `P2` work.

**P25 — The load workers compete with the main thread for the CPU.** `AssetLoaderConfig::loadThreads` (`EngineConfig::loadThreads`) defaults to the hardware threads minus one ([assetLoader.cpp:30](../src/assets/assetLoader.cpp#L30)), and the workers run at the same OS priority as the main thread. While a model's image jobs fill every worker, the driver's threads and the workers share the cores with the main thread, so its frames take longer: in `examples/10_ktx2_textures --measure --model Sponza.gltf` (Release, headless, RTX 3060, 23 workers) the longest frame while loading is 7 to 10 ms and sometimes 16 ms, against 6.5 ms with one `std::async` task per load. Run the workers at a lower priority (`SetThreadPriority`, `pthread_setschedparam` or a QoS class on macOS), or leave one more hardware thread free by default. *Confirmed* by measurement, from the `P21` work.

**P26 — A finished load's decoded data is freed on the main thread.** *Fixed 2026-11-23:* `AssetLoader::Impl::freeOnWorker` ([assetLoader.cpp:201](../src/assets/assetLoader.cpp#L201)) hands the last reference of a finished load's result (`MeshLoadJob`, `TextureLoadJob`, a glTF texture's levels, `EnvironmentLoadJob`) to a child job of the worker pool, which frees it and only then gives its bytes back to the load budget, so the budget does not count a result as gone while it is still in memory (`dropLoad` returns a finished load's bytes for that, also when it finished just as it was dropped); `dropPendingLoad` does the same for a finished load that is dropped, and a pool that is stopping frees on the caller. Measured (Release, headless, RTX 3060, 23 workers, `tools/load_bench.py`, median of 5): the main thread spent 70.5 ms in `new` and `delete` during the 300-image burst of `17_streaming` and 3.5 ms after; `beginFrame`'s self time in a burst frame fell from 1.1 to 0.05 ms, and the `LOAD_BUDGET` copies more in that time instead, so the burst loads in 335 ms instead of 413, Sponza in 176 ms instead of 184. Still open: a glTF image that several textures share counts its bytes with the first of them (`GltfImportCache::movedBytes`), which gives them back when it is filled while the others still hold the levels, so for a while the budget counts less than what is in memory. The original finding follows. After a texture is filled, `finishReadyLoads` destroyed its `PendingTextureLoad`, which freed the decoded levels on the main thread: a block of several MiB comes from the operating system, and its free gives the pages back (0.15 to 0.3 ms each, 1.2 ms per burst frame). `finishMeshLoad` freed the mesh's CPU geometry the same way (1 ms in one Sponza frame).

**P28 — Meshlet culling on the vertex-pulling path costs more than it saves with LODs.** *Partly fixed 2026-11-23:* the mesh-shader path (`MeshletPath::MESH_SHADERS`, `VK_EXT_mesh_shader`) culls the same chunks in a task shader inside the draw pass (`taskMain` in `shaders/lib/meshletTask.slang`), with no meshlet passes, no meshlet draw list and no budget. Measured the same way (off / vertex pulling / mesh shaders, 600 frames after 120): `18_meshlets` 1.97 / 2.18 / 1.99 ms; `--no-shadows` 0.58 / 0.61 / 0.54; `--lod-error 0` 5.81 / 5.59 / 5.15 (13.1 M triangles, vertex pulling 15.9 M as it hits its budget); `--lod-error 0 --no-shadows` 1.71 / 1.17 / 1.19; `--async-compute` 1.96 / 2.22 / 1.97; `05_city` 1.91 / 1.92 / 1.93. So the default is now `MeshletPath::AUTO`: mesh shaders where the GPU has them (about 1% more with LODs, up to 30% less on dense meshes), off elsewhere (MoltenVK). What stays open is the vertex-pulling path's cost, below. The original finding follows. With `MeshletPath::VERTEX_PULLING` every culling phase of every view that draws meshlets adds two indirect dispatches and two barriers (`recordMeshletCulling`, [gpuScene.cpp](../src/renderer/gpuScene.cpp)), and `writeMain` writes chunks. In `examples/18_meshlets --bench` (Release, headless, 1920x1080, RTX 3060, the camera and 4 cascades) that is 0.24 ms for 21k meshlets drawn and 10k culled, while the 1M triangles it drops cost little: the frame goes from 1.96 to 2.22 ms. Only where LODs leave many triangles does it win (every mesh at LOD 0: 1.69 → 1.19 ms without shadows, 5.79 → 5.59 ms with them). So `EngineConfig::meshletPath` is `OFF` by default. A task shader that culls the same chunks inside the draw (the mesh-shader path) has no extra passes and no meshlet draw list; on the vertex-pulling path, async compute (`EngineConfig::asyncCompute`: 2.08 → 2.16 ms) and fewer views with meshlets help. *Confirmed* by measurement.

**P31 — A pipeline first used during the run compiles its shader on the main thread.** *Fixed 2026-11-26 (perf/pipelineWarmup):* `Renderer::warmPipelines` ([pipelineWarmup.cpp](../src/renderer/pipelineWarmup.cpp)) queues every shader a frame can need at startup, in the order the frames ask for them, and `createSceneView` queues a new kind of target's (TAA, MSAA) first; shader workers (`RendererConfig::shaderThreads`, default half the hardware threads, at most 8), each with its own Slang global session, read them from the disk cache or compile them, a source's queued shaders on one module. A pipeline then takes its SPIR-V from memory, waits for the one shader a worker still compiles, or takes a queued one off the queue and compiles it itself; the debug views do not wait (`pending`) and draw shaded until their shaders are ready. Release, RTX 3060, i7-13700KF, medians of 3 interleaved runs against main, cold (`--no-cache`): the longest frame after the first goes from 448 to 70 ms in `24_map_tiles` (no hitch when the first animated landmark arrives), 869 → 53 ms in `20_views`, 774 → 140 ms in `27_cad_views`, 1668 → 243 ms in `29_point_streaming`, 1390 → 549 ms in `02_gltf`, and `26_picking`'s 51 frames over twice the median (its first picks) to none; the first frame takes 765 → 298 ms (24), 1467 → 443 ms (`05_city`), 2366 → 584 ms (27), 3715 → 741 ms (26). The engine's start before the first frame takes 40 to 100 ms more cold (the workers start beside it; 29's own octree builders share the CPU with them, so its first frame comes 0.19 s later, and its 1.65 s compile hitch is gone), and the peak working set rises by about 100 MB a shader thread (24: 503 → 1380 MB) for about 1 s, then falls below main's (460 against 501 MB after 2.5 s). Warm runs make no Slang session: startup, longest frame, GPU and CPU frame times and memory are the same as main's within run-to-run noise (+10 MB). What is left: a cold run's frames in its first second still wait while the scene asks for shaders sooner than the workers finish them (02: one frame of 0.55 s when its models arrive 0.2 s in), and `createPipeline`'s driver compile stays on the main thread (under 1 ms a pipeline with the driver's cache). Before: A pipeline is made the first time a frame needs it (`createComputePipeline`, `createScenePipeline` in [gpuScene.cpp](../src/renderer/gpuScene.cpp)), and with the shader cache cold (the first run after a shader changed, or `--no-cache`), `ShaderCompiler::compileFromString` runs Slang there, on the main thread, inside the frame. In `examples/24_map_tiles` (Release, RTX 3060) the first animated glTF landmark arriving around frame 400 starts the Animate and Skin passes: Tracy shows `compileWithSlang` 92 ms and 119 ms in two frames (frames of 96 and 123 ms), and the same frames take 1.8 ms once the cache holds the shaders. A scene's first blended draw, such as its first vector layer, does the same for the blend pipeline. Nothing outside RASM shows in those frames. Fix direction: compile a pipeline on a worker (the loader's pool, or a thread of the renderer) and draw without it until it is ready, as a mesh that still loads is not drawn; or compile the engine's own pipelines at startup. *Confirmed* by measurement (`tracy-profile`, three captures of 1500 frames). Labels (2026-11-25) add no pipeline: they draw with the `VECTOR` material's blend pipeline. Picking (2026-11-25) adds three: the pick pipelines of `rasm.slang` with `RASM_PICK` (opaque, `MASK`, `BLEND`), made on the first pick, so the first click after a cold start can take as long as a first blended draw. A fix stays bigger than that work: pipelines are made inside the frame's pass recording (`createScenePipeline` for each view, target sample count and debug view), and compiling them on a worker means a pending state per pipeline that every pass checks and skips, or a list of the engine's variants built at startup for formats and sample counts not known until the first frame. The reference grid (2026-11-25) adds one: `grid.slang`'s pipeline, made by `drawGrid` the first frame a view draws a grid (per target format and sample count).

**P32 — Small points cost 1.07 ns each by triangles.** *Fixed 2026-11-25 (PR 2b of the visualization item):* chunks of points of 2 pixels or less that are dense on screen go to a compute rasterizer (`shaders/passes/pointRaster.slang`, `src/renderer/pointRaster.cpp`): 0.081 ns per point of 1 pixel and 0.28 ns per point of 2 pixels against 0.86 and 1.14 by triangles, plus a clear and a resolve per pixel of the chunks' rect; every point of 20 M (33.5 M drawn) in 3.31 ms instead of 30.5 ms. Bigger points and GPUs without `shaderBufferInt64Atomics` keep the triangles. The original finding follows. The point run draws one triangle a point (`shaders/passes/points.slang`): on an RTX 3060, 1.07 ns per drawn point, half of it vertex work and triangle setup, nearly the same for 1 and 2 pixel points; LOD by prefix keeps a screen's worth (3.6 M points at 1920 × 1080 in two views) at 3.8 ms, and 10 to 20 M points a frame cost 11 to 21 ms. Fix direction: plan item "Point clouds and instanced glyphs", PR 2b: a compute rasterizer (64-bit atomics of depth and color, Schütz et al. 2021) for chunks whose points are about 2 pixels or less, chosen per chunk by the cull pass, with the triangle path for the rest and as the fallback without `shaderBufferInt64Atomics`. *Confirmed* by measurement (`28_point_cloud --bench`).

**P33 — Adaptive points near the camera leave the compute path.** *Fixed 2026-11-26 (perf/pointRasterSizes), partly:* the compute path now cuts each point to the triangles' shape (`getPointShape`; a disc tested per pixel, a SPHERE point's depth per pixel from `getSphereDepth`) and takes bigger points where that was measured cheaper: at the LOD's density a frame of points of one size costs the same on both paths at about 7 pixels in a perspective view and 5 in an orthographic one (RTX 3060, `28_point_cloud --size N` against `--triangles`), so a chunk goes to compute in a perspective view when its points are 6 pixels or less at its centre and 8 at its nearest point (`POINT_RASTER_MAX_SIZE`, `POINT_RASTER_MAX_NEAR`), in an orthographic one at 4 (`POINT_RASTER_MAX_ORTHO`), under MSAA at 2 as before; its density test counts a point of s pixels as (s / 2)² of 2. `28_point_cloud --adaptive`: 3.60 → 2.01 ms GPU frame (fixed size: 1.62); `29_point_streaming`: 5.88 → 5.06 ms (fixed size: 3.30). Open: under MSAA the compute path keeps 2 pixels, as it would turn bigger points' sample-covered edges into whole pixels, so `28 --adaptive --swap-aa` stays at 3.88 ms; 29 stays above its fixed-size cost, as its adaptive points grow to 32 pixels on the coarse nodes the budget leaves, which go to the triangles; and a thread writes a point's pixels one after another, which a group sharing out the pixels of mixed sizes would speed up (tried: 0.4 ms faster in `29 --swap-aa`, 11 % slower for points of one size (2 pixels)). Was: A chunk takes the compute rasterizer only when its points are `POINT_RASTER_MAX_SIZE` (2) pixels or less at its nearest point (`isRasterChunk`), and an adaptive point near the camera grows past that (`getPointDiameter`), so the near chunks go back to the triangles: `28_point_cloud --adaptive` takes 3.6 ms of GPU frame against 1.6 with fixed points (RTX 3060, Release, 1920 × 1080), and `29_point_streaming` 5.8 ms against 3.3. Fix direction: let the compute path write squares of 3 to 4 pixels (9 to 16 pixel writes a point, still under the triangle's cost per point), with the hole fill kept for 1 and 2. *Confirmed* by measurement, from the point cloud streaming work.

**P34 — A view's point raster buffer was made again at each new chunk count.** *Fixed 2026-11-25 (PR 3 of the visualization item):* `preparePointRaster` grew the buffer (a batch list sized to the point run, then 8 B a pixel of the view) to exactly the run's need, so a streamed cloud, whose run gains a few chunks at a time, made a new buffer at each new count and freed the old one, which stalled frames for 40 to 90 ms (`waitForFence`, `collectReleases`). The batches now grow to twice what they held (`SceneView::pointBatchCapacity`): `29_point_streaming`'s longest frame went from 89 ms to 7.6 ms (Release, 1920 × 1080). *The hitches left fixed 2026-11-26 (perf/pointRasterSizes):* 29's cut and streamer update still reached 3 to 6 ms by wall clock (average 0.35 ms; `TileStreamer::update` at most 0.9 ms in Tracy). The main thread's cycle count (`QueryThreadCycleTime`) showed it ran 0.2 to 0.5 ms of those updates and waited the rest inside `notify_all`: on Windows the builder thread it woke, at the same priority and with its wake boost, took the main thread's core for a whole build (2 to 4 ms). The example's builders now run at `THREAD_PRIORITY_BELOW_NORMAL`: the update's maximum went from 6.07 to 0.74 ms (average 0.36 → 0.20) and the longest frame from 8.6 to 7.0 ms (medians of 4 runs, Release, 1920 × 1080); Tracy's slow frames lost their 3 to 5 ms outside any zone (slowest now 7.6 ms, with a 2.9 ms `vkQueueSubmit` that main shows too). *RASM's workers fixed 2026-11-26 (perf/pipelineWarmup):* every `WorkerPool` thread (the loads, glTF images, mesh builds and the shader workers of `P31`) calls the public `lowerThreadPriority` ([threadPriority.cpp](../src/core/threadPriority.cpp)): Windows `THREAD_PRIORITY_BELOW_NORMAL`, Linux nice + 5, macOS the default QoS class at relative priority -5 (the same cores; utility QoS could move them to efficiency cores, which was not measured); example 29's builders use it too. In 29 the update's maximum is 0.30 to 0.36 ms with it and 1.4 to 2.5 ms without (4 runs each); disabling the wake boost at normal priority (`SetThreadPriorityBoost`) gave the same. Loads stay as fast within noise: `17_streaming --burst` 384 → 380 ms (its longest frame 24 → 27 ms, within its 21 to 30 ms spread), `02_gltf --wait-for-loads` 696 → 683 ms, `10_ktx2_textures` 107 → 113 ms (15 runs: about 5 ms of it the lower priority, also with the wake boost off instead).

**P35 — The first frames wait for Windows to clear the geometry pools (first filed as "An environment is baked on the GPU in one frame").** *Fixed 2026-11-26 (perf/firstFrameStall):* the buffers the CPU fills once, the geometry pools and the animation pool, are `BufferDesc::staged`; on a discrete GPU such a buffer asks VMA for no host access, so it is device-local only, not mapped, and filled through the staging ring ([vulkanDevice.cpp](../src/rhi/vulkan/vulkanDevice.cpp), `VulkanDevice::createBuffer`). The scene tables, rewritten each frame, stay mapped. The cause was not the bake. GPU timers put the whole `venice_sunset_2k` bake (cube 512) at about 1.0 ms (cube from the image 0.12, cube mips 0.07, specular mips 0.02/0.44/0.13/0.07/0.06/0.05, irradiance 0.06; the BRDF LUT 0.14 once per renderer), and the long frame comes before the environment exists. It is frame 2's `waitForFence` for frame 0, in every example whose frame 0 is short (00, 02, 04, 24, 29: 21 to 55 ms on 2026-11-26, 92 to 148 ms in the first measurement), with validation off and with every layer disabled (`VK_LOADER_LAYERS_DISABLE=~all~`: 53 ms in 02); the only implicit layers here are NVIDIA's `VK_LAYER_NV_optimus` and `VK_LAYER_NV_present`. Windows clears new video memory before the device's next submit runs, and RASM made about 580 MiB at startup in resizable-BAR memory (device-local and host-visible): the two 64 MiB staging rings, the geometry pools (about 280 MiB) and VMA blocks. An empty submit right after `GeometryPool::create` waited 58 ms. A standalone Vulkan program: 576 MiB, then an empty submit, completes after 110 ms in host-visible video memory and 13 ms in device-local-only memory, and after nothing 200 ms later. Release, RTX 3060, headless: frame 2 of 00/02/24 33/34/21 ms → 0.4 ms; frame 0 of 02 13 → 2 ms and of 24 23 → 9 ms; load times (05, 09, 12, 18, 28) and steady frame times (05, 12, 13, 17, 18, 20, 24, 25, 26, 28, 29) unchanged. Measured on Windows only; on another OS the staged pools take the staging path that a discrete GPU without resizable BAR already takes. Still open: the other buffers come out of host-visible VMA blocks where all of video memory is host-visible, and a new 64 or 128 MiB block is cleared like a big buffer; `29_point_streaming` keeps a 14 ms frame 2 that is not a clear (the same with every buffer unmapped). The original finding follows. On warm runs of `24_map_tiles` (main and perf/pipelineWarmup alike, Release, RTX 3060) frame 2 takes 90 to 113 ms: `waitForFence`, while the GPU bakes `venice_sunset_2k` (the cube, its mips, the specular and irradiance maps, `recordEnvironmentBakes` in [environmentBake.cpp](../src/renderer/environmentBake.cpp)) in the frame after `setEnvironmentImage`. A `loadEnvironment` at runtime hits the same spike. Fix direction: spread the bake over frames, or run it on the async compute queue, and keep the scene lit by the previous or a neutral environment until it is done. *Confirmed* by measurement (Tracy, the frame's self time is `waitForFence`).

**P29 — Debug builds allocate in steady frames.** `rasm_image_tests` built with `x64-debug` reports 4 to 5 heap allocations of 16 bytes per steady frame (`local_shadows`, `skinning`, on `main` too), where the Release build has none (`P27`). They are likely the debug iterators' proxy objects of the Microsoft STL (`_ITERATOR_DEBUG_LEVEL` 2), made when a container is created or moved. Only the Release numbers matter for `P27`; finding the site would let Debug runs check it too. *Confirmed* by measurement.

**P27 — Steady frames allocate on the heap.** *Fixed 2026-11-23:* every example's steady frame makes no heap allocation on the main thread, and `rasm_image_tests` fails a test whose steady frames do (`tests/image/allocationCounter.cpp`, Windows only). Measured with a counting `operator new` (Release, frames 500 to 1500): `05_city` made 24 allocations and 259 KB per frame, `11_many_lights` 18, `07_lights` 6, the others 0 to 7. The sites: `syncGpuScene` moved `movedEntities` into `settlingEntities`, so the list grew again from empty every frame (now a swap, [gpuScene.cpp:505](../src/renderer/gpuScene.cpp#L505)); `drawCullingSection` built its "LOD draws" line in a `std::string` (now a stack buffer); `RenderContext::getTextureDesc` returned a copy with its name string, which `beginPass` and `getUiTexture` called every frame (it returns a `const TextureDesc&` now); `prepareSceneView` built a debug view's defines string every frame (now only while a pipeline is missing). The time was small (5.4 µs of a 1.36 ms frame in `05_city`), so the frame times did not change. A per-frame arena and pool allocators for the registries were not built: nothing in a steady frame needs them. Still allocating, on purpose: Dear ImGui when it bakes a new glyph or grows its buffers, and creating or destroying objects (about 7 allocations a frame of `RangeAllocator` free lists while `17_streaming` streams, a few µs).

**P30 — `createMesh` builds a large mesh's meshlets on the main thread.** *Fixed 2026-11-25:* `buildMesh` ([mesh.cpp](../src/assets/mesh.cpp)) checks a mesh's data and builds its LODs and meshlets (`MeshBuildOptions`) on any thread, with no renderer, and `Renderer::createMesh(MeshBuild&&)` only uploads it; the vector builders end in `buildVectorMesh`, so `25_vector_map` and `24_map_tiles` build their tiles' meshes on their server threads (C API 1.5: `rasm_build_mesh`, `rasm_create_mesh_from_build`). The original finding follows. `Renderer::createMesh` ([mesh.cpp](../src/assets/mesh.cpp)) calls `buildMeshlets` (and `buildMeshLods` with `RendererConfig::meshLods`) before it writes the pool, on the calling thread, for every sub-mesh of 1024 triangles or more. An application that makes its own tiles, as a map engine does from height maps or vector tiles, pays it in the frame: a 33 × 33 height grid with its skirt (2560 triangles) took about 1 ms of the main thread in `examples/24_map_tiles` (Release, RTX 3060), so 4 tiles a frame made 5.6 ms frames, and the example uses a 17 × 17 grid (768 triangles) to stay under the threshold. Let an application build the meshlets on its own thread (a `buildMeshlets`-like step on plain arrays, then a `createMesh` that takes them), or let `createMesh` hand the work to the loader's worker pool and return a `LOADING` mesh. *Confirmed* by measurement, from the tile streaming work. Terrain no longer meets it (2026-11-25): every terrain tile shares one grid of `getTerrainMesh`, built once, so a tile is only its heights and image; `24_map_tiles` draws 32 × 32 cells a tile. It stays open for other meshes an application makes per tile (vector tiles, buildings).

**P36 — Weighted see-through draws break the last draw pass in two.** `drawWeighted` ([weightedBlend.cpp](../src/renderer/weightedBlend.cpp)) ends the view's last draw pass's rendering, draws into the view's weighted target with the scene depth, and begins the scene target's rendering again with everything loaded. On a desktop GPU that costs nothing measurable; a tiled GPU stores the pass's color and depth to memory and loads them back. It happens only in a frame with weighted draws. Fix direction: draw the weighted surfaces in a pass of their own between the last draw pass and `Transparent`, which needs the graph to let a pass draw into one target with another target's depth (read-only), and to skip a pass with nothing to draw (as `P13` asks). *Confirmed* by reading, from the weighted blended transparency work.

---

## 5. Code health

- **C1 — Naming inconsistencies.** *Fixed 2026-11-01:* these names are gone, along with the rest of the snake_case in `vulkanContext.cpp` and its `_init_*` and `_to_*` free functions. `gfx::VertexFormat` and `gfx::LightType` are now `enum class` with UPPER_SNAKE values on both the C++ and Slang sides. The fields in `rasm/profiler.h` and the remaining odd locals followed, and a `readability-identifier-naming` run of clang-tidy over every source file now reports nothing but `supportedMeshExtensions` and `supportedTextureExtensions`, which are runtime sets and rightly camelCase. The exceptions are listed in the [coding style](coding_style.md#2-naming). The original finding follows. `registery`, `metallicRoughtness`, `compiledShader`, the snake_case `VulkanContext` members, PascalCase GPU enums, and `RenderGraph::CreateTexture` beside `PassBuilder::createTexture`.
- **C2 — Formatting.** *Fixed 2026-11-01:* the repo has a `.clang-format` and all C++ files follow it. It sets no column limit, because a limit collapsed hand-placed line breaks and changed about 500 extra lines. The original finding follows. `scene.cpp` uses 2-space indentation while everything else uses 4, and there is no `.clang-format` in the repo.
- **C3 — Dead or placeholder code.**
  - *Fixed 2026-11-04:* `setUniform` (a no-op) was removed with the backend-neutral device interface (`D1`).
  - *Fixed 2026-11-04:* the glTF branch of `getMeshByteSize` (every mesh is now a list of sub-meshes).
  - *Fixed 2026-11-07:* `VertexFormat` (it was written but never read).
  - *Fixed 2026-11-07:* `compile-shaders.bat` compiles every pass shader with its real entry points and the session's flags, as an offline compile check.
  - `gfx::VertexPosOnly` and its Slang mirror, `MAX_DESCRIPTOR_TYPES`.
- **C4 — Duplication.**
  - `readFile` and `loadFileToString`.
  - *Fixed 2026-11-07:* the model-matrix composition appeared twice, in `prepareScene` and `updateUniforms`. It is now `Transform::toMatrix()`.
  - The glTF index-reading loop appears twice.
- **C5 — Copies instead of references.** `auto mesh = registry.meshes[...]`, `auto entity = ...`, `auto _scene = ...`.
- **C6 — An unused check.** *Resolved:* `validateRasmStructs` was never called because its sizes did not match. It asked `ProgramLayout::getTypeLayout` for the layout, and no `LayoutRules` value selects the layout of data behind a pointer, so it reported std140/std430 padding (`Modeldata` 240 bytes instead of 188). It now walks `pc` -> `scene` -> the pointer fields, which agrees with the `Offset` decorations in the SPIR-V, and asserts sizes and field offsets after linking any shader that uses `SceneData`.
- **C7 — A misplaced define.** *Resolved in the folder-layout change:* the ineffective `VMA_VULKAN_VERSION` define (it came after `vk_mem_alloc.h` was already included) was dropped. VMA's default, derived from the Vulkan headers, is the same 1004000 for every translation unit. If you ever need to pin it, set it in CMake.
- **C8 — Header-level objects.** *Fixed 2026-11-07:* the sets moved into the unnamed namespaces of `mesh.cpp` and `texture.cpp`, the only files that use them. The original finding follows. `const static std::unordered_set<std::string>` lives in `types.h`, which makes one copy per translation unit and runs static initializers. Make it `inline constexpr` arrays or move it into the `.cpp`.
- **C9 — A fragile material layout.** `Material::params` is a flat `float[]` indexed by hand-maintained `PbrParam` offsets, and `name` is a `const char*`. Use a typed `PbrMaterialParams` struct instead.
- **C10 — Single-header implementations are spread out.** *Resolved in the folder-layout change:* all `*_IMPLEMENTATION` defines now live in [src/thirdparty_impl.cpp](../src/thirdparty_impl.cpp).
- **C11 — The struct check compares layout, not types.** `validateStruct` checks each struct's size and field offsets ([shaderCompiler.cpp:187-222](../src/renderer/shaderCompiler.cpp#L187-L222)). A `uint32_t` on one side and a `float` on the other, or two swapped fields of the same size, pass and the shader reads garbage. Compare the field's scalar type and element count from the reflection (`getType()->getScalarType()`, `getElementCount()`) against the C++ side in the same table.
- **C12 — The push-constant size is written in three places and never checked.** *Fixed 2026-11-04:* `gfx::PushConstants` mirrors the Slang struct and is in `validateRasmStructs`. Every pipeline layout's range is `PUSH_CONSTANTS_SIZE` (16, `include/rasm/types.h`), a `static_assert` ties `sizeof(gfx::PushConstants)` to it, `drawScene` pushes `sizeof(pushConstants)`, and `RenderContext::pushConstants` rejects a push past the range. The shared layout of `P8` is done (2026-11-22). The original finding follows. `PushConstants` in [core.slang:295-300](../shaders/lib/core.slang#L295-L300) is one pointer, the pipeline layout's range is `sizeof(VkDeviceAddress)` ([vulkanDevice.cpp:548-550](../src/rhi/vulkan/vulkanDevice.cpp#L548-L550)), and `drawScene` pushes `sizeof(uint64_t)` ([gpuScene.cpp:2166](../src/renderer/gpuScene.cpp#L2166)). `validateRasmStructs` reads through `pc` but does not check its size. Mirror `PushConstants` in `uberMaterialTypes.h`, use its `sizeof` in both places, and add it to the check. The shared pipeline layout planned in `P8` is the natural home for the range.

- **C13 — A device feature is required but has no effect.** Device creation requires `descriptorBindingVariableDescriptorCount` ([vulkanDevice.cpp:193](../src/rhi/vulkan/vulkanDevice.cpp#L193)), and `allocateDescriptorSet` passes a variable count, but the bindless binding does not set `VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT` ([vulkanDevice.cpp:1170-1173](../src/rhi/vulkan/vulkanDevice.cpp#L1170-L1173)), so the count is ignored and the set always has its fixed size. Requiring the feature only narrows the GPUs RASM starts on. Drop the requirement and the allocate info, or set the flag and use it.
- **C14 — `FrameStats::cpuFrameMs` is frame time, not CPU time.** It is set from `frameTime` ([frameStats.cpp:143](../src/renderer/frameStats.cpp#L143)), the time from one frame to the next (measured even under `EngineConfig::fixedDeltaTime`). With FIFO present (`B21`) that is the refresh interval, whatever the CPU did. The overlay labels it "Frame", which is right; the field name is not. Rename it, or measure the CPU's own work from `beginFrame` to the submit.
- **C15 — The stats overlay makes image checks depend on timing.** *Fixed 2026-11-22:* the stats overlay and the RASM window renew their numbers every 0.25 s of frame time, the sum of the engine's `deltaTime` ([statsOverlay.cpp:153](../src/renderer/statsOverlay.cpp#L153), [engineUi.cpp:135](../src/renderer/engineUi.cpp#L135)), and `EngineConfig::fixedDeltaTime` makes that step fixed: the examples' `--fixed-step` sets it to 1/60 s, so the numbers renew every 15 frames and the same frame's counts show at frame N in every run. Only the timings in them (ms, fps, VRAM) still differ between runs. The original finding follows. The overlay's text is rebuilt every 250 ms of wall-clock time ([statsOverlay.cpp:21](../src/renderer/statsOverlay.cpp#L21), [statsOverlay.cpp:146](../src/renderer/statsOverlay.cpp#L146)), so the frame whose numbers show at frame N depends on how fast the frames before it ran. `03_instances` and `05_city` show it, and `verify-change` reports a DIFF in its top-left corner whenever start-up gets faster or slower: on the spot and point shadow branch, slower shader compiles moved the shown frame past one more spawned row of `03_instances` (draws 7856 / 10.2K became 7956 / 10.3K) with the scene's pixels unchanged. Rebuild the text every N frames under `--fixed-step`, or hide the overlay in verification runs. With `EngineConfig::ui`, which every example sets, the RASM window renews its numbers every 250 ms the same way (`STATS_REFRESH` in [engineUi.cpp](../src/renderer/engineUi.cpp)), so `03_instances`, `05_city` and `10_ktx2_textures` (which show the stats from the start) and `15_debug_ui` have it too. *Confirmed.*
- **C16 — Verify images depend on how far the asynchronous loads got.** *Fixed 2026-11-22:* every example that loads takes `--wait-for-loads` (`examples/exampleArgs.h`) and then calls `Engine::waitForLoads` before its first frame, and `verify-change` passes it with `--fixed-step`. The original finding follows. `verify-change` screenshots frame N, but an example that does not wait for its loads draws a mesh only from the frame its load (and its textures) finished, which depends on wall-clock time, not on N. Under the gfxreconstruct capture, `02_gltf` on `main` (cc790ed) spends about 7 s (Release) to 9 s (Debug) in its first 4 frames and has the coffee room loaded by frame 4; on the node animation branch those frames are fast, the room loads at frame 18 to 22 (Release, 0.95 s) or 167 to 240 (Debug, 2.4 to 3.8 s), so frame 60 shows the room on one and not on the other. The import itself takes the same time on both (183 to 186 ms in Release without capture). Fix with the headless/golden-image item: the examples (or the verify script, through a flag) wait until every load is done (`isLoaded` of each mesh and texture, or `waitForLoads`) before they count frames. *Confirmed* by measurement.
- **C17 — The `--bench` averages of `12_animation` count one frame too many.** It adds the GPU timers of frames 300 to 600, 301 frames, and divides by 300 ([main.cpp](../examples/12_animation/main.cpp)), so every printed time is about 0.3% high. `13_skinning` sums frames 300 to 599. Stop at frame 599 there too. *Confirmed*, from the skinning review.

- **C18 — A copied runtime DLL goes stale when only the library changes.** `rasm_copy_runtime_dlls` copies a program's DLLs next to it in a `POST_BUILD` step ([RasmRuntimeDlls.cmake:6](../cmake/RasmRuntimeDlls.cmake#L6)), which runs only when the program links again. A change inside `rasm_c` that keeps its exports leaves the import library the same, so Ninja does not link `22_c_api` again, and it runs with the old `rasm_cd.dll` beside it: after a GPU struct change it failed the struct check with the old sizes. CI builds from scratch, so it does not show there. Fix: copy with a custom command that depends on the DLLs (`$<TARGET_RUNTIME_DLLS>` as a dependency), or set the examples' output folder to the libraries'. *Confirmed*.
- **C19 — `29_point_streaming`'s frame 60 is not the same from run to run.** With `--fixed-step --wait-for-loads` (what `verify-change` runs), the Debug build's frame 60 comes out in one of two images: 5 % of the pixels of the left view (the edges of the point splats) differ by up to 103, and runs fall in either group (main's code: 3 of 6 runs; seen 2026-11-26 while checking `P35`). The right view and the other examples are exact. Likely cause: the octree's streamed nodes arrive by time, not by frame, so `waitForLoads` before the first frame does not fix which nodes are loaded at frame 60. Fix direction: in a `--wait-for-loads` run, wait for the streamed nodes too, or make the image test take a frame after streaming settles. *Likely.*

---

## 6. What is already good

These are worth keeping as the engine evolves:
- **Modern Vulkan baseline:** dynamic rendering, synchronization2, per-image render-finished semaphores (the correct modern pattern), VMA with budget tracking, vk-bootstrap.
- **A GPU-driven core:** one pipeline and a few indirect draws per scene, vertex pulling, bindless textures, and BDA through a single 16-byte push constant.
- **A careful CPU/GPU layout contract:** scalar layout with `static_assert`s and comments explaining the failure mode.
- **Correct color handling:** sRGB versus linear texture formats, sRGB-aware mip generation, and linear shading with sRGB output.
- **A solid PBR core:** a Filament-style BRDF, UV-derivative tangent frames that handle mirrored UVs, and per-texture UV sets.
- **A thoughtful camera:** frame-rate-independent easing, and a trackball that eases along the orbit sphere.
- **A clean layering intent:** handles everywhere and a single creation descriptor. The ideas are right; the implementation needs to catch up (D1, D5).
