Skip to content

Commit afa6297

Browse files
authored
fix: vulkan memory type. (#195)
1 parent 15e073c commit afa6297

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/nn/nn-vulkan.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,26 @@ NnVulkanBuffer::NnVulkanBuffer(NnVulkanContext *context, const vk::DeviceSize bu
130130

131131
uint32_t memoryTypeIndex = MEMORY_TYPE_INDEX_NOT_FOUND;
132132
if (fastAccess) {
133-
memoryTypeIndex = findMemoryTypeIndex(&context->physicalDevice, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eDeviceLocal);
133+
memoryTypeIndex = findMemoryTypeIndex(
134+
&context->physicalDevice,
135+
vk::MemoryPropertyFlagBits::eHostVisible |
136+
vk::MemoryPropertyFlagBits::eHostCoherent |
137+
vk::MemoryPropertyFlagBits::eHostCached
138+
);
139+
if (memoryTypeIndex == MEMORY_TYPE_INDEX_NOT_FOUND)
140+
memoryTypeIndex = findMemoryTypeIndex(
141+
&context->physicalDevice,
142+
vk::MemoryPropertyFlagBits::eHostVisible |
143+
vk::MemoryPropertyFlagBits::eHostCoherent
144+
);
134145
if (memoryTypeIndex != MEMORY_TYPE_INDEX_NOT_FOUND)
135146
isHostVisible = true;
136147
}
137148
if (!isHostVisible) {
138-
memoryTypeIndex = findMemoryTypeIndex(&context->physicalDevice, vk::MemoryPropertyFlagBits::eDeviceLocal);
149+
memoryTypeIndex = findMemoryTypeIndex(
150+
&context->physicalDevice,
151+
vk::MemoryPropertyFlagBits::eDeviceLocal
152+
);
139153
if (memoryTypeIndex == MEMORY_TYPE_INDEX_NOT_FOUND)
140154
throw std::runtime_error("Cannot find host visible memory type");
141155
}

0 commit comments

Comments
 (0)