namespace Brutal.VulkanApi.Abstractions; /// /// Structure to hold frame resources for the Renderer /// public class FrameResources(Device inDevice) : IDisposable { /// Index of this frame public int FrameIndex = 0; /// Framebuffer for this frame public VkFramebuffer Framebuffer = default; /// Image for the swapchain public VkImage ColorImage = default; /// Whether this frame owns the color image public bool OwnsColorImage = false; /// Bound memory for the SwapchainImage public VkDeviceMemory ColorImageMemory = default; /// Image view for the swapchain public VkImageView ColorImageView = default; /// Image for the depth buffer public VkImage DepthImage = default; /// Bound memory for the DepthImage public VkDeviceMemory DepthImageMemory = default; /// Image view for the depth buffer public VkImageView DepthImageView = default; /// Image for the multisampled image public VkImage MultisampledImage = default; /// Bound memory for the MultisampledImage public VkDeviceMemory MultisampledImageMemory = default; /// Image view for the multisampled image public VkImageView MultisampledImageView = default; public required VkAllocator? Allocator; public void Dispose() { inDevice.DestroyImageView(ColorImageView, Allocator); inDevice.DestroyImageView(DepthImageView, Allocator); inDevice.DestroyImageView(MultisampledImageView, Allocator); if (OwnsColorImage) { inDevice.DestroyImage(ColorImage, Allocator); inDevice.FreeMemory(ColorImageMemory, Allocator); } inDevice.DestroyImage(DepthImage, Allocator); inDevice.DestroyImage(MultisampledImage, Allocator); inDevice.FreeMemory(DepthImageMemory, Allocator); inDevice.FreeMemory(MultisampledImageMemory, Allocator); inDevice.DestroyFramebuffer(Framebuffer, Allocator); } }