comparison semiconginev2/rendering/renderer.nim @ 1234:841e12f33c47

add: text & font rendering, not tested yet
author sam <sam@basx.dev>
date Sat, 20 Jul 2024 00:03:57 +0700
parents 70f6c1cfe005
children 176383220123
comparison
equal deleted inserted replaced
1233:1cf698973dca 1234:841e12f33c47
329 proc AssignBuffers*[T](renderdata: var RenderData, data: var T, uploadData = true) = 329 proc AssignBuffers*[T](renderdata: var RenderData, data: var T, uploadData = true) =
330 for name, value in fieldPairs(data): 330 for name, value in fieldPairs(data):
331 331
332 when typeof(value) is GPUData: 332 when typeof(value) is GPUData:
333 AssignGPUData(renderdata, value) 333 AssignGPUData(renderdata, value)
334
335 elif typeof(value) is DescriptorSet:
336 AssignBuffers(renderdata, value.data, uploadData = uploadData)
337
334 elif typeof(value) is array: 338 elif typeof(value) is array:
335 when elementType(value) is GPUValue: 339 when elementType(value) is GPUValue:
336 for v in value.mitems: 340 for v in value.mitems:
337 AssignGPUData(renderdata, v) 341 AssignGPUData(renderdata, v)
338 342
453 proc createVulkanImage(renderData: var RenderData, image: var Image) = 457 proc createVulkanImage(renderData: var RenderData, image: var Image) =
454 assert image.vk == VkImage(0), "Image has already been created" 458 assert image.vk == VkImage(0), "Image has already been created"
455 var usage = @[VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_USAGE_SAMPLED_BIT] 459 var usage = @[VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_USAGE_SAMPLED_BIT]
456 if image.isRenderTarget: 460 if image.isRenderTarget:
457 usage.add VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT 461 usage.add VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
458 let format = GetVkFormat(elementType(image.data) is TVec1[uint8], usage = usage) 462 let format = GetVkFormat(grayscale = elementType(image.data) is Gray, usage = usage)
459 463
460 image.vk = svkCreate2DImage(image.width, image.height, format, usage, image.samples) 464 image.vk = svkCreate2DImage(image.width, image.height, format, usage, image.samples)
461 renderData.images.add image.vk 465 renderData.images.add image.vk
462 image.sampler = createSampler(magFilter = image.interpolation, minFilter = image.interpolation) 466 image.sampler = createSampler(magFilter = image.interpolation, minFilter = image.interpolation)
463 renderData.samplers.add image.sampler 467 renderData.samplers.add image.sampler