From 087fe4c19682453f5eea898523194d3932a2175f Mon Sep 17 00:00:00 2001 From: niki Date: Fri, 14 Oct 2022 14:29:19 +0200 Subject: [PATCH] vulkan: improve negated bit syntax --- src/modules/graphics/vulkan/Buffer.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/modules/graphics/vulkan/Buffer.cpp b/src/modules/graphics/vulkan/Buffer.cpp index 255cf649e..f0e0b1f73 100644 --- a/src/modules/graphics/vulkan/Buffer.cpp +++ b/src/modules/graphics/vulkan/Buffer.cpp @@ -220,7 +220,7 @@ bool Buffer::fill(size_t offset, size_t size, const void *data) VkMemoryPropertyFlags memoryProperties; vmaGetAllocationMemoryProperties(allocator, fillAllocation, &memoryProperties); - if (!(memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + if (~memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) vmaFlushAllocation(allocator, fillAllocation, 0, size); VkBufferCopy bufferCopy{}; @@ -239,12 +239,7 @@ bool Buffer::fill(size_t offset, size_t size, const void *data) void Buffer::unmap(size_t usedoffset, size_t usedsize) { - if (dataUsage == BUFFERDATAUSAGE_READBACK) - { - if (!coherent) - vmaFlushAllocation(allocator, allocation, usedoffset, usedsize); - } - else + if (dataUsage != BUFFERDATAUSAGE_READBACK) { VkBufferCopy bufferCopy{}; bufferCopy.srcOffset = usedoffset - mappedRange.getOffset(); @@ -253,7 +248,7 @@ void Buffer::unmap(size_t usedoffset, size_t usedsize) VkMemoryPropertyFlags memoryProperties; vmaGetAllocationMemoryProperties(allocator, stagingAllocation, &memoryProperties); - if (!(memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + if (~memoryProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) vmaFlushAllocation(allocator, stagingAllocation, bufferCopy.srcOffset, usedsize); vkCmdCopyBuffer(vgfx->getCommandBufferForDataTransfer(), stagingBuffer, buffer, 1, &bufferCopy);