Account for noncoherent atom size in renderpass memory flush
authorChris Forbes <chrisforbes@google.com>
Fri, 18 May 2018 20:49:26 +0000 (13:49 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 24 May 2018 12:29:03 +0000 (08:29 -0400)
Change-Id: Ibffb14fcdbaba5e9fbeb8ba9d9aba9cc59db4b17
Components: Vulkan
Affects: dEQP-VK.renderpass.*
VK-GL-CTS: 1180

external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp

index 9c202dd..b39e7b6 100644 (file)
@@ -1448,15 +1448,20 @@ void uploadBufferData (const DeviceInterface&   vk,
                                           VkDevice                                     device,
                                           const Allocation&            memory,
                                           size_t                                       size,
-                                          const void*                          data)
+                                          const void*                          data,
+                                          VkDeviceSize                         nonCoherentAtomSize)
 {
+       // Expand the range to flush to account for the nonCoherentAtomSize
+       VkDeviceSize roundedOffset = (VkDeviceSize)deAlignSize(deUint32(memory.getOffset()), deUint32(nonCoherentAtomSize));
+       VkDeviceSize roundedSize = (VkDeviceSize)deAlignSize(deUint32(memory.getOffset() + size - roundedOffset), deUint32(nonCoherentAtomSize));
+
        const VkMappedMemoryRange range =
        {
                VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,  // sType;
                DE_NULL,                                                                // pNext;
                memory.getMemory(),                                             // mem;
-               memory.getOffset(),                                             // offset;
-               (VkDeviceSize)size                                              // size;
+               roundedOffset,                                                  // offset;
+               roundedSize,                                                    // size;
        };
        void* const ptr = memory.getHostPtr();
 
@@ -1925,7 +1930,9 @@ public:
                        m_vertexBufferMemory    = allocateBuffer(vki, vk, physDevice, device, *m_vertexBuffer, MemoryRequirement::HostVisible, allocator, allocationKind);
 
                        bindBufferMemory(vk, device, *m_vertexBuffer, m_vertexBufferMemory->getMemory(), m_vertexBufferMemory->getOffset());
-                       uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer());
+
+                       const vk::VkPhysicalDeviceProperties properties = vk::getPhysicalDeviceProperties(context.getInstanceInterface(), context.getPhysicalDevice());
+                       uploadBufferData(vk, device, *m_vertexBufferMemory, renderQuad.getVertexDataSize(), renderQuad.getVertexPointer(), properties.limits.nonCoherentAtomSize);
 
                        if (renderInfo.getInputAttachmentCount() > 0)
                        {