feat/depth-buffer-dynamic-viewport-resize #72

Merged
akadmin merged 3 commits from feat/depth-buffer-dynamic-viewport-resize into main 2026-05-09 23:29:25 +00:00
Owner

closes #15

closes #15
The offscreen framebuffer (color + D16_UNORM depth) was fixed at 1280×720
and never recreated when the window resized. Now `viewport::show` returns
the egui panel's available size, `UiPresenter::run_editor_frame` converts
it to physical pixels and returns `Option<[u32; 2]>`, and `RenderLayer`
calls `Scene::resize` + re-registers the egui texture whenever the panel
size changes.

- Extract `needs_resize` guard as a testable pure function in renderer.rs
- Remove `#[allow(dead_code)]` from `Scene::resize`
- Add 4 unit tests for the resize guard conditions (131 tests total, all pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A "Depth" toggle button appears in the top-right corner of the viewport
canvas. When active, the scene is rendered using a second Vulkan graphics
pipeline whose fragment shader outputs gl_FragCoord.z as grayscale
(near = white, far = dark, power-remapped for contrast). The shaded
pipeline is otherwise unchanged.

Changes:
- src/shaders/depth_fragment.glsl: new fragment shader for depth pass
- renderer.rs: RenderMode enum, depth_pipeline field, depth_fs shader
  module, render_offscreen now takes RenderMode
- viewport.rs: SelectableLabel toggle button overlaid in top-right corner
- ui_presenter.rs: threads depth_view through immediate_ui via Cell<bool>
- render.rs: depth_view field on RenderLayer, passes RenderMode to
  render_offscreen and &mut depth_view to run_editor_frame

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: two bugs in depth-view toggle
All checks were successful
CI / build (pull_request) Successful in 3m10s
a4ff2ecab4
1. Crash on activation (pool_sizes empty): the SPIR-V compiler optimises
   out the unused `tex` sampler from depth_fragment.glsl, leaving set 0
   empty in the depth pipeline layout. Creating a DescriptorSet for an
   empty layout panics. Fix: skip texture load, DS creation, and set-0
   binding entirely when mode == Depth.

2. "This texture no longer exists" + cascading re-registers: the
   unregister/re-register of the offscreen texture fired in the same
   frame that draw_on_image still needed the old texture ID. Fix: store
   the new viewport size as pending_viewport_resize and apply it at the
   start of the NEXT on_update, after draw_on_image has completed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
akadmin deleted branch feat/depth-buffer-dynamic-viewport-resize 2026-05-09 23:29:26 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
akadmin/NemesisEngine!72
No description provided.