diff --git a/src/grabs.Graphics.Vulkan/VkDevice.cs b/src/grabs.Graphics.Vulkan/VkDevice.cs index 4983c31..9fefb76 100644 --- a/src/grabs.Graphics.Vulkan/VkDevice.cs +++ b/src/grabs.Graphics.Vulkan/VkDevice.cs @@ -149,6 +149,9 @@ public override ShaderModule CreateShaderModule(ShaderStage stage, byte[] spirv, public override Framebuffer CreateFramebuffer(in ReadOnlySpan colorTextures, Texture depthTexture = null) { + if (colorTextures[0] is VkSwapchainTexture swapchainTexture) + return new VkSwapchainFramebuffer(swapchainTexture); + throw new NotImplementedException(); } diff --git a/src/grabs.Graphics.Vulkan/VkSwapchainFramebuffer.cs b/src/grabs.Graphics.Vulkan/VkSwapchainFramebuffer.cs new file mode 100644 index 0000000..ff9d5f8 --- /dev/null +++ b/src/grabs.Graphics.Vulkan/VkSwapchainFramebuffer.cs @@ -0,0 +1,19 @@ +using System; +using Silk.NET.Vulkan; + +namespace grabs.Graphics.Vulkan; + +public class VkSwapchainFramebuffer : Framebuffer +{ + public ImageView[] Views; + + public VkSwapchainFramebuffer(VkSwapchainTexture texture) + { + Views = texture.Views; + } + + public override void Dispose() + { + + } +} \ No newline at end of file diff --git a/src/grabs.Graphics.Vulkan/VkSwapchainTexture.cs b/src/grabs.Graphics.Vulkan/VkSwapchainTexture.cs index a91a952..6a8ee19 100644 --- a/src/grabs.Graphics.Vulkan/VkSwapchainTexture.cs +++ b/src/grabs.Graphics.Vulkan/VkSwapchainTexture.cs @@ -56,7 +56,7 @@ public VkSwapchainTexture(Vk vk, VulkanDevice device, in ReadOnlySpan ima public override void Dispose() { - for (int i = 0; i < Images.Length; i++) + for (int i = 0; i < Views.Length; i++) _vk.DestroyImageView(_device, Views[i], null); // Cannot destroy the actual images themselves as they are owned by the swapchain. diff --git a/tests/grabs.Tests/Program.cs b/tests/grabs.Tests/Program.cs index 58a7534..4284617 100644 --- a/tests/grabs.Tests/Program.cs +++ b/tests/grabs.Tests/Program.cs @@ -10,6 +10,7 @@ using Silk.NET.Vulkan; using Device = grabs.Graphics.Device; using Event = Silk.NET.SDL.Event; +using Framebuffer = grabs.Graphics.Framebuffer; using Instance = grabs.Graphics.Instance; using Surface = grabs.Graphics.Surface; using Texture = grabs.Graphics.Texture; @@ -124,6 +125,7 @@ device.CreateSwapchain(new SwapchainDescription(width, height, bufferCount: 4, presentMode: PresentMode.VerticalSync)); Texture swapchainTexture = swapchain.GetSwapchainTexture(); + Framebuffer swapchainFramebuffer = device.CreateFramebuffer(swapchainTexture); CommandList commandList = device.CreateCommandList(); @@ -153,6 +155,7 @@ } commandList.Dispose(); + swapchainFramebuffer.Dispose(); swapchainTexture.Dispose(); swapchain.Dispose(); device.Dispose();