Mercurial > games > semicongine
diff semiconginev2/rendering/renderer.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 | 4e465583ea32 |
children | 70f6c1cfe005 |
line wrap: on
line diff
--- a/semiconginev2/rendering/renderer.nim Thu Jul 18 16:33:24 2024 +0700 +++ b/semiconginev2/rendering/renderer.nim Thu Jul 18 21:32:41 2024 +0700 @@ -444,7 +444,7 @@ usage.add VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT let format = GetVkFormat(elementType(image.data) is TVec1[uint8], usage = usage) - image.vk = svkCreate2DImage(image.width, image.height, format, usage) + image.vk = svkCreate2DImage(image.width, image.height, format, usage, image.samples) renderData.images.add image.vk image.sampler = createSampler(magFilter = image.interpolation, minFilter = image.interpolation) renderData.samplers.add image.sampler @@ -485,12 +485,13 @@ # data transfer and layout transition TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) - WithStagingBuffer( - (image.vk, image.width, image.height), - memoryRequirements.size, - stagingPtr - ): - copyMem(stagingPtr, image.data.ToCPointer, image.size) + if image.data.len > 0: + WithStagingBuffer( + (image.vk, image.width, image.height), + memoryRequirements.size, + stagingPtr + ): + copyMem(stagingPtr, image.data.ToCPointer, image.size) TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)