Mercurial > games > semicongine
changeset 154:de04cf5c2558
fix: more improvment for memory selection
author | Sam <sam@basx.dev> |
---|---|
date | Thu, 27 Apr 2023 21:13:09 +0700 |
parents | c6f6757e8126 |
children | 321d3de6c78c |
files | src/semicongine/vulkan/buffer.nim src/semicongine/vulkan/memory.nim |
diffstat | 2 files changed, 3 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/semicongine/vulkan/buffer.nim Thu Apr 27 20:55:02 2023 +0700 +++ b/src/semicongine/vulkan/buffer.nim Thu Apr 27 21:13:09 2023 +0700 @@ -39,9 +39,11 @@ if preferVRAM and buffer.device.hasMemoryWith(flags & @[VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT]): flags.add VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - if autoFlush and buffer.device.hasMemoryWith(flags & @[VK_MEMORY_PROPERTY_HOST_COHERENT_BIT]): + if requiresMapping and autoFlush and buffer.device.hasMemoryWith(flags & @[VK_MEMORY_PROPERTY_HOST_COHERENT_BIT]): flags.add VK_MEMORY_PROPERTY_HOST_COHERENT_BIT + assert buffer.device.hasMemoryWith(flags) + buffer.memoryAllocated = true debug "Allocating memory for buffer: ", buffer.size, " bytes ", flags buffer.memory = buffer.device.allocate(buffer.size, flags)
--- a/src/semicongine/vulkan/memory.nim Thu Apr 27 20:55:02 2023 +0700 +++ b/src/semicongine/vulkan/memory.nim Thu Apr 27 21:13:09 2023 +0700 @@ -100,18 +100,6 @@ ppData=addr(result.data) ) -#[ -proc allocate*(device: Device, size: uint64, useVRAM: bool, mappable: bool, autoFlush: bool): DeviceMemory = - var flags: seq[VkMemoryPropertyFlagBits] - if useVRAM: - flags.add VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - if mappable: - flags.add VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - if autoFlush: - flags.add VK_MEMORY_PROPERTY_HOST_COHERENT_BIT - device.allocate(size=size, flags=flags) -]# - # flush host -> device proc flush*(memory: DeviceMemory, offset=0'u64, size=0'u64) = assert memory.device.vk.valid