Fix flushing memory range in memory model shared tests
authorziga-lunarg <ziga@lunarg.com>
Sat, 19 Nov 2022 19:06:44 +0000 (20:06 +0100)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 8 Dec 2022 18:01:11 +0000 (18:01 +0000)
Each size of pMemRanges in vkFlushMappedMemoryRanges must be either a
multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize or equal to the
size of memory

Components: Vulkan

VK-GL-CTS issue: 4123

Affected tests:
dEQP-VK.memory_model.shared.*

Change-Id: I0f3ea96736aa73eb92c7809c04297923d84e348c

external/vulkancts/modules/vulkan/memory_model/vktMemoryModelSharedLayoutCase.cpp

index be47515f112bca48f2482eaa5053e10ae7164f0a..34321106947b7a441d61e8c1b7760d6e90af69fb 100644 (file)
@@ -362,6 +362,7 @@ tcu::TestStatus SharedLayoutCaseInstance::iterate (void)
        const vk::VkDevice                                                      device                                          = m_context.getDevice();
        const vk::VkQueue                                                       queue                                           = m_context.getUniversalQueue();
        const deUint32                                                          queueFamilyIndex                        = m_context.getUniversalQueueFamilyIndex();
+       vk::Allocator&                                                          allocator                                       = m_context.getDefaultAllocator();
        const deUint32                                                          bufferSize                                      = 4;
 
        // Create descriptor set
@@ -378,12 +379,12 @@ tcu::TestStatus SharedLayoutCaseInstance::iterate (void)
        };
 
        vk::Move<vk::VkBuffer>                                          buffer                                          (vk::createBuffer(vk, device, &params));
-
-       de::MovePtr<vk::Allocation>                                     bufferAlloc                                     (vk::bindBuffer (m_context.getDeviceInterface(), m_context.getDevice(),
-                                                                                                                                                       m_context.getDefaultAllocator(), *buffer, vk::MemoryRequirement::HostVisible));
+       vk::VkMemoryRequirements                                        requirements                            = getBufferMemoryRequirements(vk, device, *buffer);
+       de::MovePtr<vk::Allocation>                                     bufferAlloc                                     (allocator.allocate(requirements, vk::MemoryRequirement::HostVisible));
+       VK_CHECK(vk.bindBufferMemory(device, *buffer, bufferAlloc->getMemory(), bufferAlloc->getOffset()));
 
        deMemset(bufferAlloc->getHostPtr(), 0, bufferSize);
-       flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), bufferSize);
+       flushMappedMemoryRange(vk, device, bufferAlloc->getMemory(), bufferAlloc->getOffset(), requirements.size);
 
        vk::DescriptorSetLayoutBuilder                          setLayoutBuilder;
        vk::DescriptorPoolBuilder                                       poolBuilder;