1 module sbylib.wrapper.vulkan.renderpass; 2 3 import erupted; 4 import sbylib.wrapper.vulkan.device; 5 import sbylib.wrapper.vulkan.enums; 6 import sbylib.wrapper.vulkan.util; 7 8 class RenderPass { 9 static struct AttachmentDescription { 10 @vkProp() { 11 VkAttachmentDescriptionFlags flags; 12 VkFormat format; 13 SampleCount samples; 14 AttachmentLoadOp loadOp; 15 AttachmentStoreOp storeOp; 16 AttachmentLoadOp stencilLoadOp; 17 AttachmentStoreOp stencilStoreOp; 18 ImageLayout initialLayout; 19 ImageLayout finalLayout; 20 } 21 22 const mixin VkTo!(VkAttachmentDescription); 23 } 24 25 static struct SubpassDescription { 26 27 static struct AttachmentReference { 28 @vkProp() { 29 uint attachment; 30 ImageLayout layout; 31 } 32 33 const mixin VkTo!(VkAttachmentReference); 34 } 35 36 @vkProp() { 37 immutable VkSubpassDescriptionFlags flags; 38 immutable PipelineBindPoint pipelineBindPoint; 39 } 40 41 @vkProp("pInputAttachments", "inputAttachmentCount") { 42 const AttachmentReference[] inputAttachments; 43 } 44 45 @vkProp("pColorAttachments", "colorAttachmentCount") { 46 const AttachmentReference[] colorAttachments; 47 } 48 49 @vkProp("pResolveAttachments") { 50 const AttachmentReference[] resolveAttachments; 51 } 52 53 @vkProp("pDepthStencilAttachment") { 54 const AttachmentReference[] depthStencilAttachments; 55 } 56 57 @vkProp("pPreserveAttachments", "preserveAttachmentCount") { 58 const uint[] preserveAttachments; 59 } 60 61 invariant(resolveAttachments is null || resolveAttachments.length == colorAttachments 62 .length); 63 64 const mixin VkTo!(VkSubpassDescription); 65 } 66 67 static struct CreateInfo { 68 @vkProp() { 69 immutable VkRenderPassCreateFlags flags; 70 } 71 72 @vkProp("pAttachments", "attachmentCount") { 73 const AttachmentDescription[] attachments; 74 } 75 76 @vkProp("pSubpasses", "subpassCount") { 77 const SubpassDescription[] subpasses; 78 } 79 80 @vkProp("pDependencies", "dependencyCount") { 81 const VkSubpassDependency[] dependencies; 82 } 83 84 const mixin VkTo!(VkRenderPassCreateInfo); 85 } 86 87 private Device device; 88 private VkRenderPass renderPass; 89 90 mixin ImplNameSetter!(device, renderPass, DebugReportObjectType.RenderPass); 91 92 this(Device device, CreateInfo _info) { 93 import std.exception : enforce; 94 95 this.device = device; 96 97 auto info = _info.vkTo(); 98 99 enforceVK(vkCreateRenderPass(device.device, &info, null, &renderPass)); 100 enforce(renderPass != VK_NULL_HANDLE); 101 } 102 103 ~this() { 104 vkDestroyRenderPass(device.device, renderPass, null); 105 } 106 107 mixin VkTo!(VkRenderPass); 108 }