Mercurial > games > semicongine
comparison 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 |
comparison
equal
deleted
inserted
replaced
1228:4e465583ea32 | 1229:5dcb503ef0c0 |
---|---|
442 var usage = @[VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_USAGE_SAMPLED_BIT] | 442 var usage = @[VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_USAGE_SAMPLED_BIT] |
443 if image.isRenderTarget: | 443 if image.isRenderTarget: |
444 usage.add VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | 444 usage.add VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
445 let format = GetVkFormat(elementType(image.data) is TVec1[uint8], usage = usage) | 445 let format = GetVkFormat(elementType(image.data) is TVec1[uint8], usage = usage) |
446 | 446 |
447 image.vk = svkCreate2DImage(image.width, image.height, format, usage) | 447 image.vk = svkCreate2DImage(image.width, image.height, format, usage, image.samples) |
448 renderData.images.add image.vk | 448 renderData.images.add image.vk |
449 image.sampler = createSampler(magFilter = image.interpolation, minFilter = image.interpolation) | 449 image.sampler = createSampler(magFilter = image.interpolation, minFilter = image.interpolation) |
450 renderData.samplers.add image.sampler | 450 renderData.samplers.add image.sampler |
451 | 451 |
452 let memoryRequirements = image.vk.svkGetImageMemoryRequirements() | 452 let memoryRequirements = image.vk.svkGetImageMemoryRequirements() |
483 image.imageview = svkCreate2DImageView(image.vk, format) | 483 image.imageview = svkCreate2DImageView(image.vk, format) |
484 renderData.imageViews.add image.imageview | 484 renderData.imageViews.add image.imageview |
485 | 485 |
486 # data transfer and layout transition | 486 # data transfer and layout transition |
487 TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) | 487 TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) |
488 WithStagingBuffer( | 488 if image.data.len > 0: |
489 (image.vk, image.width, image.height), | 489 WithStagingBuffer( |
490 memoryRequirements.size, | 490 (image.vk, image.width, image.height), |
491 stagingPtr | 491 memoryRequirements.size, |
492 ): | 492 stagingPtr |
493 copyMem(stagingPtr, image.data.ToCPointer, image.size) | 493 ): |
494 copyMem(stagingPtr, image.data.ToCPointer, image.size) | |
494 TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) | 495 TransitionImageLayout(image.vk, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) |
495 | 496 |
496 | 497 |
497 proc UploadImages*(renderdata: var RenderData, descriptorSet: var DescriptorSet) = | 498 proc UploadImages*(renderdata: var RenderData, descriptorSet: var DescriptorSet) = |
498 for name, value in fieldPairs(descriptorSet.data): | 499 for name, value in fieldPairs(descriptorSet.data): |