# HG changeset patch # User Sam # Date 1682604789 -25200 # Node ID 91e6b2935934d79e98823dd229cdc90964c42433 # Parent a54a7fe284302ca5fe33827382f2a0b5b4746445 fix: more improvment for memory selection diff -r a54a7fe28430 -r 91e6b2935934 src/semicongine/vulkan/buffer.nim --- 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) diff -r a54a7fe28430 -r 91e6b2935934 src/semicongine/vulkan/memory.nim --- 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