private void createFramebuffers(VkContext context) { this.wrapper.Framebuffers = new Vk.Framebuffer[this.wrapper.ImageCapacity]; for (uint i = 0; i < this.wrapper.ImageCapacity; i++) { Vk.ImageView[] attachments = new Vk.ImageView[] { this.wrapper.ImageViews[i], this.wrapper.DepthImageView }; var framebufferInfo = new Vk.FramebufferCreateInfo(); framebufferInfo.RenderPass = this.wrapper.RenderPass; framebufferInfo.AttachmentCount = 2; framebufferInfo.Attachments = attachments; framebufferInfo.Width = this.wrapper.Extent.Width; framebufferInfo.Height = this.wrapper.Extent.Height; framebufferInfo.Layers = 1; try { this.wrapper.Framebuffers[i] = context.Device.CreateFramebuffer(framebufferInfo); } catch (Vk.ResultException result) { throw new VkException($"An error occurred while creating framebuffer {i}.", result); } } }
private void createImageViews(VkContext context) { var imageViews = new Vk.ImageView[this.wrapper.ImageCapacity]; for (int i = 0; i < this.wrapper.ImageCapacity; i++) { Vk.ImageViewCreateInfo createInfo = new Vk.ImageViewCreateInfo(); createInfo.Image = this.wrapper.Images[i]; createInfo.ViewType = Vk.ImageViewType.View2D; createInfo.Format = this.wrapper.Format; Vk.ComponentMapping componentMapping = new Vk.ComponentMapping(); componentMapping.R = Vk.ComponentSwizzle.Identity; componentMapping.G = Vk.ComponentSwizzle.Identity; componentMapping.B = Vk.ComponentSwizzle.Identity; componentMapping.A = Vk.ComponentSwizzle.Identity; createInfo.Components = componentMapping; Vk.ImageSubresourceRange subresourceRange = new Vk.ImageSubresourceRange(); subresourceRange.AspectMask = Vk.ImageAspectFlags.Color; subresourceRange.BaseMipLevel = 0; subresourceRange.LevelCount = 1; subresourceRange.BaseArrayLayer = 0; subresourceRange.LayerCount = 1; createInfo.SubresourceRange = subresourceRange; try { imageViews[i] = context.Device.CreateImageView(createInfo); } catch (Vk.ResultException result) { throw new VkException($"An error occurred while creating image view {i}.", result); } } this.wrapper.ImageViews = imageViews; }