Skip to content

Skip unchanged meshes when building G-buffer command buffers - #223

Merged
BenjaFriend merged 2 commits into
mainfrom
feature/dirty-command-buffers
Oct 29, 2026
Merged

BenjaFriend merged 2 commits into
mainfrom
feature/dirty-command-buffers

Conversation

@BenjaFriend

Copy link
Copy Markdown
Member

Fixes #135.

What changed

  • Transform dirty flag. SetPos, SetRotation, and SetScale set it. CalculateWorldMatrix clears it. A transform loaded from a level stays dirty. The editor calls MarkDirty() after it writes fields directly.
  • Shared camera UBO. Projection and view moved out of the per-mesh UBO into one camera UBO (binding 5 in mrt.vert, .spv rebuilt). A camera move no longer dirties every mesh.
  • Dirty-only UBO uploads. A mesh UBO is written only when its transform is dirty, or when the mesh is new or replaced.
  • Cached offscreen command buffers. They are recorded again only when the draw list changes: MeshRenderer/Transform construct, destroy, or replace, or a swapchain resize.
  • Editor model/material changes go through registry.replace(), so the renderer writes the new textures to the descriptor set. Before, a material change did not update the textures.

Testing

  • ctest: 101/101 pass, including new FlingTests/Engine/TransformTests.cpp. Comment-style check passes.
  • Sandbox on an RTX 3090 with VK_LAYER_KHRONOS_validation: Level_1 and the Sandbox lighting test with about 750 entities, rotating and moving objects, and a sphere spawned at runtime. 0 validation messages, and rendering is correct.

Follow-ups (not in this PR)

  • The UBO pass still checks every mesh's dirty flag. It is cheap, but a dirty list kept by registry signals would remove that loop. All transform writes would then have to go through the registry.
  • The engine's EnableValidationLayers=true config fails to create the instance on this machine ("layers requested but not available"). I tested with VK_INSTANCE_LAYERS instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E5zLKAKV1AEmphy4e2YToX

BenjaFriend and others added 2 commits October 25, 2026 09:48
Fixes #135. The offscreen subpass used to walk every mesh each frame to
write its UBO and record its draw call again.

- Transform has a dirty flag. The setters set it, and CalculateWorldMatrix
  clears it. A mesh UBO is written only when its transform is dirty, or
  when the mesh is new or replaced.
- The camera projection and view moved out of the per-mesh UBO into one
  shared camera UBO (binding 5 in mrt.vert). A camera move no longer
  dirties every mesh.
- The offscreen command buffers are recorded again only when the draw
  list changes: a MeshRenderer or Transform is added, removed, or
  replaced, or the swapchain is resized.
- The editor calls registry.replace() after a model or material change,
  so the renderer records again and writes the new textures to the
  descriptor set. Before, a material change did not update the textures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5zLKAKV1AEmphy4e2YToX
- Take main's removal of the committed .spv files. CMake now compiles
  the shaders, so the edited mrt.vert builds at build time.
- Use entt::hashed_string::to_value("Default") for every entt::tag in
  OffscreenSubpass.cpp, which matches main's fix for MSVC 2026 C7658.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenjaFriend
BenjaFriend merged commit 49c8a1a into main Oct 29, 2026
12 checks passed
@BenjaFriend
BenjaFriend deleted the feature/dirty-command-buffers branch October 29, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce the amount of iteration when buliding command buffers

1 participant