From b1d1890c88c14529c145fb9ef20b1046233e4f50 Mon Sep 17 00:00:00 2001 From: Maciej Jesionowski Date: Tue, 10 Jan 2017 13:15:45 +0100 Subject: [PATCH] Use deAlign64 in api.buffer and sparse_resources Change-Id: I087d99db106555a806c6864e67c9af12fb5c67b2 --- external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp | 13 +++---------- .../sparse_resources/vktSparseResourcesBufferTests.cpp | 8 +------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp index 8ccd621..c34b9fd 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiBufferTests.cpp @@ -199,13 +199,6 @@ private: BufferCaseParameters m_testCase; }; -inline VkDeviceSize alignDeviceSize (VkDeviceSize val, VkDeviceSize align) -{ - DE_ASSERT(deIsPowerOfTwo64(align)); - DE_ASSERT(val + align >= val); // crash on overflow - return (val + align - 1) & ~(align - 1); -} - tcu::TestStatus BufferTestInstance::bufferCreateAndAllocTest (VkDeviceSize size) { const VkPhysicalDevice vkPhysicalDevice = getPhysicalDevice(); @@ -243,7 +236,7 @@ tcu::TestStatus BufferTestInstance::bufferCreateAndAllocTest (VkDeviceSize size) const deUint32 heapTypeIndex = (deUint32)deCtz32(memReqs.memoryTypeBits); const VkMemoryType memoryType = memoryProperties.memoryTypes[heapTypeIndex]; const VkMemoryHeap memoryHeap = memoryProperties.memoryHeaps[memoryType.heapIndex]; - const VkDeviceSize maxBufferSize = alignDeviceSize(memoryHeap.size >> 1, memReqs.alignment); + const VkDeviceSize maxBufferSize = deAlign64(memoryHeap.size >> 1, memReqs.alignment); const deUint32 shrinkBits = 4; // number of bits to shift when reducing the size with each iteration size = std::min(size, maxBufferSize); @@ -261,7 +254,7 @@ tcu::TestStatus BufferTestInstance::bufferCreateAndAllocTest (VkDeviceSize size) if (result != VK_SUCCESS) { - size = alignDeviceSize(size >> shrinkBits, memReqs.alignment); + size = deAlign64(size >> shrinkBits, memReqs.alignment); if (size == 0 || bufferParams.size == memReqs.alignment) return tcu::TestStatus::fail("Buffer creation failed! (" + de::toString(getResultName(result)) + ")"); @@ -298,7 +291,7 @@ tcu::TestStatus BufferTestInstance::bufferCreateAndAllocTest (VkDeviceSize size) if (result != VK_SUCCESS) { - size = alignDeviceSize(size >> shrinkBits, memReqs.alignment); + size = deAlign64(size >> shrinkBits, memReqs.alignment); if (size == 0 || memReqs.size == memReqs.alignment) return tcu::TestStatus::fail("Unable to allocate " + de::toString(memReqs.size) + " bytes of memory"); diff --git a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp index f1ae906..dfbc81d 100644 --- a/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp +++ b/external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp @@ -202,12 +202,6 @@ inline VkMemoryRequirements requirementsWithSize (VkMemoryRequirements requireme return requirements; } -inline VkDeviceSize alignSize (const VkDeviceSize val, const VkDeviceSize align) -{ - DE_ASSERT(deIsPowerOfTwo64(align)); - return (val + align - 1) & ~(align - 1); -} - MovePtr SparseAllocationBuilder::build (const DeviceInterface& vk, const VkDevice device, Allocator& allocator, @@ -220,7 +214,7 @@ MovePtr SparseAllocationBuilder::build (const DeviceInterface& referenceCreateInfo.size = sizeof(deUint32); const Unique refBuffer (createBuffer(vk, device, &referenceCreateInfo)); const VkMemoryRequirements memoryRequirements = getBufferMemoryRequirements(vk, device, *refBuffer); - const VkDeviceSize chunkSize = std::max(memoryRequirements.alignment, alignSize(minChunkSize, memoryRequirements.alignment)); + const VkDeviceSize chunkSize = std::max(memoryRequirements.alignment, static_cast(deAlign64(minChunkSize, memoryRequirements.alignment))); for (std::vector::const_iterator numChunksIter = m_chunksPerAllocation.begin(); numChunksIter != m_chunksPerAllocation.end(); ++numChunksIter) { -- 2.7.4