Surface & Swapchain Management #21
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Vulkan Surface & Swapchain Management
Overview
This pull request introduces Vulkan surface and swapchain management system in
Cyfra. This should be a good base for any future improvements to the rendering pipeline.Features
Surface Abstraction
SurfaceencapsulatesVkSurfaceKHR, managing its lifecycle via GLFW.SurfaceCapabilities
SurfaceFactory
SurfaceManager
SwapChainManager
VkImageViewobjects.Image View Handling
Unit Tests
SurfaceTest.scalaSurfaceCapabilitiesTest.scalaSurfaceFactoryTest.scalaSurfaceManagerTest.scalaTechnical Details
Architecture
Layered Design
Surface— raw Vulkan handle and lifecycleSurfaceCapabilities— figures out what the surface supportsSurfaceFactory— builds surfaces based on the platformSurfaceManagerandSwapChainManager— manage everything over timeDesign Patterns
Using(MemoryStack)to keep memory under control.Memory & Error Management
close()to clean up.VulkanAssertionErroron Vulkan API failures.Testing
Unit Test Coverage:
SurfaceTest: Validates surface creation, destruction, and presentation support.SurfaceCapabilitiesTest: Tests querying of formats, presentation modes, image counts, extents, and optimal selection logic.SurfaceFactoryTest: Ensures platform-specific extensions are handled correctly and surfaces are created successfully.SurfaceManagerTest: Verifies multi-surface management, event handling (resize/close), and lifecycle operations.Potential Issues & Limitations
SurfaceFactoryensures early detection.SurfaceManageris not thread-safe — needs external locks.Future Improvements