Fix vk::Allocation usage in pipeline tests
authorPyry Haulos <phaulos@google.com>
Thu, 10 Sep 2015 17:15:40 +0000 (10:15 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 10 Sep 2015 17:15:40 +0000 (10:15 -0700)
vk::Allocation API semantics had changed; memory mappings are now
managed by Allocation and must not be manipulated from outside.

Change-Id: I47406e7842b8cce0544c9c9585714454114d66bf

external/vulkancts/modules/vulkan/pipeline/vktPipelineDepthTests.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageUtil.cpp

index 6685160..a364e0a 100644 (file)
@@ -740,21 +740,8 @@ DepthTestInstance::DepthTestInstance (Context&                             context,
                                m_vertices[quadNdx * 6 + vertexNdx].position.z() = DepthTest::quadDepths[quadNdx];
 
                // Load vertices into vertex buffer
-
-               const VkMappedMemoryRange flushRange =
-               {
-                       VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,  // VkStructureType      sType;
-                       DE_NULL,                                                                // const void*          pNext;
-                       m_vertexBufferAlloc->getMemory(),               // VkDeviceMemory       mem;
-                       m_vertexBufferAlloc->getOffset(),               // VkDeviceSize offset;
-                       vertexBufferParams.size                                 // VkDeviceSize size;
-               };
-
-               void* bufferPtr;
-               VK_CHECK(vk.mapMemory(vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size, 0, &bufferPtr));
-               deMemcpy(bufferPtr, m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA));
-               vk.flushMappedMemoryRanges(vkDevice, 1, &flushRange);
-               VK_CHECK(vk.unmapMemory(vkDevice, m_vertexBufferAlloc->getMemory()));
+               deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA));
+               flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size);
        }
 
        // Create command pool
index 2f6dc6d..f648f1d 100644 (file)
@@ -188,23 +188,9 @@ de::MovePtr<tcu::TextureLevel> readColorAttachment (const vk::DeviceInterface&     v
        VK_CHECK(vk.queueSubmit(queue, 1, &cmdBuffer.get(), *fence));
        VK_CHECK(vk.waitForFences(device, 1, &fence.get(), 0, ~(0ull) /* infinity */));
 
-
-       // Map and read buffer data
-
-       const VkMappedMemoryRange memoryRange =
-       {
-               VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,          // VkStructureType      sType;
-               DE_NULL,                                                                        // const void*          pNext;
-               bufferAlloc->getMemory(),                                       // VkDeviceMemory       mem;
-               bufferAlloc->getOffset(),                                       // VkDeviceSize         offset;
-               pixelDataSize                                                           // VkDeviceSize         size;
-       };
-
-       void* bufferPtr;
-       VK_CHECK(vk.mapMemory(device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize, 0, &bufferPtr));
-       VK_CHECK(vk.invalidateMappedMemoryRanges(device, 1, &memoryRange));
-       tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferPtr));
-       VK_CHECK(vk.unmapMemory(device, bufferAlloc->getMemory()));
+       // Read buffer data
+       invalidateMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), pixelDataSize);
+       tcu::copy(*resultLevel, tcu::ConstPixelBufferAccess(resultLevel->getFormat(), resultLevel->getSize(), bufferAlloc->getHostPtr()));
 
        return resultLevel;
 }