Invalidate memory in draw tests
authorAlexander Galazin <alexander.galazin@arm.com>
Tue, 3 Oct 2017 19:29:50 +0000 (21:29 +0200)
committerChris Forbes <chrisforbes@google.com>
Wed, 1 Aug 2018 20:58:58 +0000 (16:58 -0400)
The test group writes to non-coherent device memory with device,
but fails to call the required invalidate on the region before
reading mapped memory with host.

Components: Vulkan

VK-GL-CTS issue: 529

Affects: dEQP-VK.draw.*

Change-Id: Icf4aa6ea80c8c046e41b37402457b7f094d7ae50
(cherry picked from commit 1ce6e233a6245a1cf81a2a4e88b87c5d381a119a)

external/vulkancts/modules/vulkan/draw/vktDrawImageObjectUtil.cpp

index e016d2c..4cc3635 100644 (file)
@@ -367,6 +367,10 @@ void Image::readUsingBuffer (vk::VkQueue                           queue,
                VK_CHECK(m_vk.queueWaitIdle(queue));
        }
 
+       // Validate the results
+       const vk::Allocation& bufAllocation = stagingResource->getBoundMemory();
+       invalidateMappedMemoryRange(m_vk, m_device, bufAllocation.getMemory(), bufAllocation.getOffset(), VK_WHOLE_SIZE);
+
        deUint8* destPtr = reinterpret_cast<deUint8*>(stagingResource->getBoundMemory().getHostPtr());
        deMemcpy(data, destPtr, static_cast<size_t>(bufferSize));
 }
@@ -466,6 +470,10 @@ de::SharedPtr<Image> Image::copyToLinearImage (vk::VkQueue                                 queue,
 
                // TODO: make this less intrusive
                VK_CHECK(m_vk.queueWaitIdle(queue));
+
+               // Validate the results
+               const vk::Allocation& imgAllocation = stagingResource->getBoundMemory();
+               invalidateMappedMemoryRange(m_vk, m_device, imgAllocation.getMemory(), imgAllocation.getOffset(), VK_WHOLE_SIZE);
        }
        return stagingResource;
 }