Modernized Vulkan Pipeline and Persistent LOD System - #223
Conversation
…218) * feat: enable and stabilize LOD system (#216) * feat: enable and stabilize LOD system - Exposed lod_enabled toggle in settings and presets. - Updated presets to enable LOD on HIGH/ULTRA. - Optimized LOD performance by moving cleanup to throttled update. - Fixed LOD-to-chunk transition masking in shader. - Added unit tests for LOD settings application. * refactor: apply SOLID principles and performance documentation to LOD system - Introduced ILODConfig interface to decouple settings from LOD logic (Dependency Inversion). - Extracted mask radius calculation into a pure function in ILODConfig for better testability (Single Responsibility). - Documented the 4-frame throttle rationale in LODManager. - Fixed a bug where redundant LOD chunks were being re-queued immediately after being unloaded. - Added end-to-end unit test for covered chunk cleanup. * fix: resolve build errors and correctly use ILODConfig interface - Fixed type error in World.zig where LODManager was used as a function instead of a type. - Updated all remaining direct radii accesses to use ILODConfig.getRadii() in WorldStreamer and WorldRenderer. - Verified fixes with successful 'zig build test'. * fix: remove redundant LOD cleanup from render path - Removed redundant 'unloadLODWhereChunksLoaded' call from 'LODRenderer.render', fixing the double-call bug. - Decoupled 'calculateMaskRadius' by adding it to the 'ILODConfig' vtable. - Synchronized code with previous comments to ensure the throttled cleanup is now correctly localized to the update loop. * Phase 2: Render Pipeline Modernization - Offscreen HDR Buffer & Post-Process Pass (#217) * Phase 2: Render Pipeline Modernization - Offscreen HDR Buffer & Post-Process Pass * Phase 2: Add synchronization barriers and improve resource lifecycle safety * Phase 2: Add descriptor null-guards and configurable tone mapper selection * Phase 2: Fix Vulkan offscreen HDR rendering and post-process pass initialization Detailed changes: - Decoupled main rendering pass from swapchain using an offscreen HDR buffer. - Fixed initialization order to ensure HDR resources and main render pass are created before pipelines. - Implemented dedicated post-process framebuffers for swapchain presentation. - Added a fallback post-process pass for UI-only frames to ensure correct image layout transition. - Fixed missing SSAO blur render pass creation. - Added shadow 'regular' sampler and bound it to descriptor set binding 4. - Added nullification of Vulkan handles after destruction to prevent validation errors. - Improved swapchain recreation logic with pipeline rebuild tracking. - Added debug logging for render pass and swapchain lifecycle. * Implement FXAA, Bloom, and Velocity Buffer for Phase 3 * Phase 3 Fixes: Address review comments (memory leaks, hardcoded constants) * feat: modularize FXAA and Bloom systems, add velocity buffer, and improve memory safety * fix: add missing shadow sampler creation in createShadowResources * fix: add missing G-Pass image/framebuffer creation and fix Bloom push constant stage flags - Add G-Pass normal, velocity, and depth image creation that was lost during refactoring - Create G-Pass framebuffer with all 3 attachments (normal, velocity, depth) - Fix Bloom push constants to use VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT matching the pipeline layout definition Fixes integration test failures with NULL VkImage and push constant validation errors. * fix: resolve push constant and render pass ordering issues in Vulkan backend * feat: add comprehensive branching strategy, PR templates, and contributing guidelines - Add dev branch with branch protection (0 reviews, strict mode, linear history) - Add 4 PR templates: feature, bug, hotfix, ci - Add CONTRIBUTING.md with full workflow documentation - Update build.yml to trigger on main and dev - Add hotfix keywords to issue-labeler.json - Add universal PR template as fallback Resolves: Branching strategy and workflow improvements * refactor: move FXAA/Bloom resource creation to systems, fix leaks * fix: correct bloom descriptor binding count to fix validation error
* feat: enable and stabilize LOD system (#216) * feat: enable and stabilize LOD system - Exposed lod_enabled toggle in settings and presets. - Updated presets to enable LOD on HIGH/ULTRA. - Optimized LOD performance by moving cleanup to throttled update. - Fixed LOD-to-chunk transition masking in shader. - Added unit tests for LOD settings application. * refactor: apply SOLID principles and performance documentation to LOD system - Introduced ILODConfig interface to decouple settings from LOD logic (Dependency Inversion). - Extracted mask radius calculation into a pure function in ILODConfig for better testability (Single Responsibility). - Documented the 4-frame throttle rationale in LODManager. - Fixed a bug where redundant LOD chunks were being re-queued immediately after being unloaded. - Added end-to-end unit test for covered chunk cleanup. * fix: resolve build errors and correctly use ILODConfig interface - Fixed type error in World.zig where LODManager was used as a function instead of a type. - Updated all remaining direct radii accesses to use ILODConfig.getRadii() in WorldStreamer and WorldRenderer. - Verified fixes with successful 'zig build test'. * fix: remove redundant LOD cleanup from render path - Removed redundant 'unloadLODWhereChunksLoaded' call from 'LODRenderer.render', fixing the double-call bug. - Decoupled 'calculateMaskRadius' by adding it to the 'ILODConfig' vtable. - Synchronized code with previous comments to ensure the throttled cleanup is now correctly localized to the update loop. * Phase 4: Implement GPU Profiling, Timing Overlay, and Preset Rebalancing * fix: keep UI visible after post-processing and stabilize LOD threading
- fix(lod): implemented availability-based LOD transitions to eliminate horizon gaps - fix(vulkan): resolved clear value and descriptor layout validation errors in Medium+ presets - fix(lighting): boosted sky/cloud radiance to match PBR terrain and reduced fog gloom - fix(ui): restored and thickened block selection outline in HDR pass - fix(shadows): corrected Reverse-Z depth bias to eliminate acne on near blocks - feat(hud): added LOD count to debug overlay
…xtures (#222) * feat: implement visual polish including dithered LOD transitions, improved AO, and grid-free textures - Implement screen-space dithered crossfading for LOD transitions - Add distance-aware voxel AO to eliminate dark rectangular artifacts on distant terrain - Disable texture atlas mipmapping to remove visible block boundary grid lines - Enhance block selection outline thickness and expansion for better visibility - Pass mask_radius from vertex to fragment shader for precise transition control * fix: add missing bayerDither4x4 function and clean up magic numbers in terrain shader - Implement missing bayerDither4x4 function in fragment shader - Add missing vMaskRadius input declaration to fragment shader - Extract LOD_TRANSITION_WIDTH and AO_FADE_DISTANCE to constants - Remove trailing whitespace in UV calculation - Fix shader compilation error introduced in previous commit * fix: restore missing shadows and fix broken lighting logic in terrain shader - Rewrite terrain fragment shader lighting logic to fix broken brackets and scope issues - Ensure totalShadow is applied to all lighting branches (Legacy, PBR, and non-PBR) - Clean up variable naming to avoid shadowing uniform block names - Maintain previous visual polish fixes (LOD dithering, distance-aware AO, and grid-free textures) * fix(graphics): Restore and optimize shadows, add debug view - Fixed shadow rendering by correcting reverse-Z bias direction in shadow_system.zig - Improved shadow visibility by masking ambient occlusion (reduced ambient by 80% in shadow) - Optimized shadow resolution defaults (High: 4096->2048) for better performance (~12ms frame time) - Added 'G' key toggle for Red/Green shadow debug view - Fixed input/settings synchronization on app startup to ensure correct RHI state - Fixed shadow acne by increasing depth bias slope factor * chore: remove temporary test output files
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemExecutive SummaryThis PR implements a comprehensive Persistent LOD System with 4 levels of detail and modernizes the graphics pipeline with HDR, tonemapping, post-processing (Bloom, FXAA), and visual polish features. The implementation is well-architected using Zig's interface patterns and demonstrates solid engineering practices. Issue Requirements Verification
Code Quality AssessmentStrengths:
Issues Identified:
SOLID Principles Assessment
Recommendations
Final VerdictApprove with minor fixes recommended. The implementation is well-structured, thread-safe, and meets all issue requirements. The identified issues are low-to-medium severity and don't block merging. |
* Refactor: Relocate drawDebugShadowMap to Debug Overlay System * Refactor: Address code review comments for Debug Overlay refactor * Fix: Shadow sampler initialization order and safety in destroyTexture * Polish: Add InvalidImageView error and doc comments for Debug Overlay * Docs: Add documentation for registerExternalTexture and DebugShadowOverlay * Test: Add unit test for ResourceManager.registerExternalTexture validation
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements Verification
Previous Review FeedbackThe existing review from SOLID Principles Assessment
Code Quality Issues
Recommendations
Final VerdictApprove with minor fixes recommended. The implementation is well-structured, thread-safe, and meets all issue requirements. The identified issues are low-to-medium severity and don't block merging. The existing review's concerns should be addressed before merge. |
* refactor: relocate computeSSAO to dedicated SSAOSystem - Introduced ISSAOContext in rhi.zig to follow interface segregation. - Created SSAOSystem in vulkan/ssao_system.zig to encapsulate SSAO resources and logic. - Updated Vulkan backend to integrate the new system and implement ISSAOContext. - Refactored RenderGraph and mocks to use the new segregated interface. - Closes #225 * refactor(ssao): improve SSAOSystem implementation based on PR feedback - Extracted initialization phases into helper functions (SRP). - Fixed misnamed command_pool parameter type. - Added error handling for vkMapMemory. - Improved shader module cleanup using defer and errdefer. - Standardized error handling style for Vulkan calls. * refactor(ssao): final polish of SSAOSystem implementation - Extracted kernel and noise constants. - Standardized shader path constants. - Improved parameter naming and error checking. - Added unit test for SSAO parameter defaults. - Verified all 181 tests pass. * fix(integration): resolve compilation errors and apply final polish - Fixed Mat4.inverse() call in render_graph.zig. - Removed stray ssao_kernel_ubo references in rhi_vulkan.zig. - Fixed VulkanDevice mutability in SSAOSystem.init. - Applied all code quality improvements from PR review. * fix(rhi): resolve compilation and logic errors in SSAO refactor - Implemented registerNativeTexture in ResourceManager to support externally managed images. - Fixed double-free in ResourceManager.deinit by checking for memory ownership. - Fixed TextureFormat usage (.red instead of .r8_unorm). - Fixed stray SSAO resource references in rhi_vulkan.zig. - Restored main descriptor set updates for SSAO map in rhi_vulkan.zig. - Added missing initial layout transitions for SSAO images. * refactor(graphics): final polish and standardization of post-process systems - Introduced shader_registry.zig to centralize and de-duplicate shader paths. - Removed redundant vkQueueWaitIdle in SSAOSystem texture initialization. - Added internal unit tests for SSAOSystem (noise and kernel generation). - Merged latest dev changes and resolved vtable conflicts. - Standardized error handling and resource cleanup across SSAO, Bloom, and FXAA systems. * fix(ssao): restore queue wait before freeing upload command buffer Restored 'vkQueueWaitIdle' in SSAOSystem.initNoiseTexture to ensure the upload command buffer is no longer in use by the GPU before it is freed. This fixes a validation error and potential segmentation fault during initialization.
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements Verification
Previous Review FeedbackThe existing review from
Code Quality Issues
SOLID Principles Assessment
Recommendations
Final VerdictApprove with minor fixes recommended. The implementation is well-structured, thread-safe, and meets all issue requirements. The identified issues are low-to-medium severity and don't block merging. The existing review's concerns should be addressed before merge. |
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements VerificationAll referenced issues (#201, #211-#214, #221) are fully implemented as verified in previous reviews. Previous Review Feedback
SOLID Principles Assessment
Code Quality Issues
Recommendations
Final VerdictApprove with minor fixes recommended. Implementation is well-structured and meets all issue requirements. Medium-severity memory safety issues should be addressed before merge. |
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements Verification
Previous Review Feedback
SOLID Principles Assessment
Code Quality Issues
Recommendations
Final VerdictApprove with minor fixes recommended. The implementation is well-structured, thread-safe, and meets all issue requirements. The identified issues are low-to-medium severity and don't block merging. The existing review's concerns should be addressed before merge. |
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements VerificationAll referenced issues are fully implemented:
Previous Review Feedback Status
Code Quality Issues
SOLID Principles Assessment
Recommendations
Final VerdictApprove with minor fixes recommended. The implementation is well-structured, thread-safe, and meets all issue requirements. The medium-severity memory safety issues in |
Code Review: Modernized Vulkan Pipeline and Persistent LOD SystemIssue Requirements VerificationAll referenced issues are fully implemented and verified:
Previous Review Feedback
SOLID Principles Assessment
Code Quality Issues
Final VerdictApprove with minor fixes recommended. Implementation is well-structured, thread-safe, and meets all issue requirements. The medium-severity memory safety issues in |







This PR merges the
devbranch intomain, delivering a complete modernization of the Vulkan rendering pipeline and the implementation of the Persistent LOD System as outlined in section #201.Summary of Changes
1. Persistent LOD System (Issues #201, #211-#214)
2. Modernized Graphics Pipeline
RenderGraph.deinitsequences for Bloom and FXAA systems to prevent potential double-frees and improved initialization safety.3. Visual Polish & Integration (Issue #221)
4. Performance & Presets
Verification
Closes #201
Closes #211
Closes #212
Closes #213
Closes #214
Closes #221