Mercurial > games > semicongine
diff semiconginev2/rendering/vulkan_wrappers.nim @ 1229:5dcb503ef0c0
did: refactor renderpass a bit, enable depth buffering and msaa on offscreen-rendering
author | sam <sam@basx.dev> |
---|---|
date | Thu, 18 Jul 2024 21:32:41 +0700 |
parents | 56781cc0fc7c |
children | 69489a678141 |
line wrap: on
line diff
--- a/semiconginev2/rendering/vulkan_wrappers.nim Thu Jul 18 16:33:24 2024 +0700 +++ b/semiconginev2/rendering/vulkan_wrappers.nim Thu Jul 18 21:32:41 2024 +0700 @@ -49,10 +49,6 @@ addr(result), ) -proc DefaultSurfaceFormat(): VkFormat = - # EVERY windows driver and almost every linux driver should support this - VK_FORMAT_B8G8R8A8_SRGB - func size(format: VkFormat): uint64 = const formatSize = [ VK_FORMAT_B8G8R8A8_SRGB.int: 4'u64, @@ -140,7 +136,7 @@ ) checkVkResult vkCreateImage(vulkan.device, addr imageInfo, nil, addr(result)) -proc svkCreate2DImageView(image: VkImage, format: VkFormat): VkImageView = +proc svkCreate2DImageView*(image: VkImage, format: VkFormat, aspect = VK_IMAGE_ASPECT_COLOR_BIT): VkImageView = var createInfo = VkImageViewCreateInfo( sType: VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, image: image, @@ -153,7 +149,7 @@ a: VK_COMPONENT_SWIZZLE_IDENTITY, ), subresourceRange: VkImageSubresourceRange( - aspectMask: VkImageAspectFlags(VK_IMAGE_ASPECT_COLOR_BIT), + aspectMask: toBits [aspect], baseMipLevel: 0, levelCount: 1, baseArrayLayer: 0, @@ -229,6 +225,7 @@ proc svkCreateRenderPass( attachments: openArray[VkAttachmentDescription], colorAttachments: openArray[VkAttachmentReference], + depthAttachments: openArray[VkAttachmentReference], resolveAttachments: openArray[VkAttachmentReference], dependencies: openArray[VkSubpassDependency], ): VkRenderPass = @@ -241,7 +238,7 @@ colorAttachmentCount: colorAttachments.len.uint32, pColorAttachments: colorAttachments.ToCPointer, pResolveAttachments: resolveAttachments.ToCPointer, - pDepthStencilAttachment: nil, + pDepthStencilAttachment: depthAttachments.ToCPointer, preserveAttachmentCount: 0, pPreserveAttachments: nil, )