Fix swapchain mutable tests buffer allocations
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 23 Jan 2019 18:29:34 +0000 (18:29 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 21 Feb 2019 16:20:18 +0000 (11:20 -0500)
We're seeing failure on our implementation and those seem to be
related to the fact that some buffers are allocated with one VkDevice
and used with another VkDevice. This raises errors in the validation
layers :

   Validation(ERROR): msg_code: 385926663:
   [ VUID-vkBindBufferMemory-memory-parent ] Object: 0x6 (Type = 8) |
   Object 0x6 was not created, allocated or retrieved from the correct
   device. The spec valid usage text states 'memory must have been
   created, allocated, or retrieved from device'

Affects: dEQP-VK.image.swapchain_mutable.*

Change-Id: I4d3c62dace2d259061382d3014deb05bc4eac9d7
(cherry picked from commit b48fc89ada2a1b88796d1354d10210928b1fbf0d)

external/vulkancts/modules/vulkan/image/vktImageMutableTests.cpp

index 141634f..4ae65dc 100644 (file)
@@ -923,14 +923,16 @@ VkImageUsageFlags getImageUsageForTestCase (const CaseDef& caseDef)
 class UploadDownloadExecutor
 {
 public:
-       UploadDownloadExecutor(Context& context, const CaseDef& caseSpec) :
+       UploadDownloadExecutor(Context& context, VkDevice device, VkQueue queue, deUint32 queueFamilyIndex, const CaseDef& caseSpec) :
        m_caseDef(caseSpec),
        m_haveMaintenance2(isDeviceExtensionSupported(context.getUsedApiVersion(), context.getDeviceExtensions(), "VK_KHR_maintenance2")),
        m_vk(context.getDeviceInterface()),
-       m_device(context.getDevice()),
-       m_queue(context.getUniversalQueue()),
-       m_queueFamilyIndex(context.getUniversalQueueFamilyIndex()),
-       m_allocator(context.getDefaultAllocator())
+       m_device(device),
+       m_queue(queue),
+       m_queueFamilyIndex(queueFamilyIndex),
+       m_allocator(context.getDeviceInterface(), device,
+                   getPhysicalDeviceMemoryProperties(context.getInstanceInterface(),
+                                                     context.getPhysicalDevice()))
        {
        }
 
@@ -962,7 +964,7 @@ private:
        const VkDevice                                          m_device;
        const VkQueue                                           m_queue;
        const deUint32                                          m_queueFamilyIndex;
-       Allocator&                                                      m_allocator;
+       SimpleAllocator                                         m_allocator;
 
        Move<VkCommandPool>                                     m_cmdPool;
        Move<VkCommandBuffer>                           m_cmdBuffer;
@@ -1750,7 +1752,7 @@ tcu::TestStatus testMutable (Context& context, const CaseDef caseDef)
        flushAlloc(vk, device, *colorBufferAlloc);
 
        // Execute the test
-       UploadDownloadExecutor executor(context, caseDef);
+       UploadDownloadExecutor executor(context, device, context.getUniversalQueue(), context.getUniversalQueueFamilyIndex(), caseDef);
        executor.run(context, *colorBuffer);
 
        // Verify results
@@ -2119,7 +2121,7 @@ tcu::TestStatus testSwapchainMutable(Context& context, CaseDef caseDef)
        const VkDevice                                  device = *devHelper.device;
        const VkPhysicalDevice                  physDevice = devHelper.physicalDevice;
 
-       Allocator&                                              allocator = context.getDefaultAllocator();
+       SimpleAllocator                         allocator(vk, device, getPhysicalDeviceMemoryProperties(vki, context.getPhysicalDevice()));
 
        // Check required features on the format for the required upload/download methods
        VkFormatProperties      imageFormatProps, viewFormatProps;
@@ -2257,7 +2259,7 @@ tcu::TestStatus testSwapchainMutable(Context& context, CaseDef caseDef)
 
 
        // Execute the test
-       UploadDownloadExecutor executor(context, caseDef);
+       UploadDownloadExecutor executor(context, device, devHelper.queue, devHelper.queueFamilyIndex, caseDef);
 
        executor.runSwapchain(context, *colorBuffer, swapchainImages[0]);