Fix flush memory range in ssbo corner case tests
authorziga-lunarg <ziga@lunarg.com>
Fri, 14 Oct 2022 22:53:12 +0000 (00:53 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 10 Nov 2022 18:11:43 +0000 (18:11 +0000)
The size in VKMappedMemoryRange used in vkFlushMappedMemoryRanges must
either be a multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize or
offset + size must be equal to the size of memory

Components: Vulkan

VK-GL-CTS issue: 4044

Affected tests:
dEQP-VK.ssbo.corner_case.*

Change-Id: I9ea2ee1e055b55ec39988a6ec0539cd3219937f4

external/vulkancts/modules/vulkan/ssbo/vktSSBOCornerCase.cpp

index bd7f753718a552112e9e17ef8e2a8e241c9f4fed..f1bcd003762bbae2096dbdb6e7b861c18ef69ce2 100644 (file)
@@ -113,13 +113,17 @@ struct Buffer
        Buffer          (void)                                                  : buffer(0), size(0) {}
 };
 
-de::MovePtr<vk::Allocation> allocateAndBindMemory (Context &context, vk::VkBuffer buffer, vk::MemoryRequirement memReqs)
+de::MovePtr<vk::Allocation> allocateAndBindMemory (Context &context, vk::VkBuffer buffer, vk::MemoryRequirement memReqs, vk::VkDeviceSize* allocationSize = DE_NULL)
 {
        const vk::DeviceInterface               &vkd    = context.getDeviceInterface();
        const vk::VkMemoryRequirements  bufReqs = vk::getBufferMemoryRequirements(vkd, context.getDevice(), buffer);
        de::MovePtr<vk::Allocation>             memory  = context.getDefaultAllocator().allocate(bufReqs, memReqs);
 
        vkd.bindBufferMemory(context.getDevice(), buffer, memory->getMemory(), memory->getOffset());
+       if (allocationSize)
+       {
+               *allocationSize = bufReqs.size;
+       }
 
        return memory;
 }
@@ -176,10 +180,11 @@ tcu::TestStatus SSBOCornerCaseInstance::iterate (void)
        // Create descriptor set
        const deUint32                                  acBufferSize            = 4;
        vk::Move<vk::VkBuffer>                  acBuffer                        (createBuffer(m_context, acBufferSize, vk:: VK_BUFFER_USAGE_STORAGE_BUFFER_BIT));
-       de::UniquePtr<vk::Allocation>   acBufferAlloc           (allocateAndBindMemory(m_context, *acBuffer, vk::MemoryRequirement::HostVisible));
+       vk::VkDeviceSize                                acMemorySize            = 0;
+       de::UniquePtr<vk::Allocation>   acBufferAlloc           (allocateAndBindMemory(m_context, *acBuffer, vk::MemoryRequirement::HostVisible, &acMemorySize));
 
        deMemset(acBufferAlloc->getHostPtr(), 0, acBufferSize);
-       flushMappedMemoryRange(vk, device, acBufferAlloc->getMemory(), acBufferAlloc->getOffset(), acBufferSize);
+       flushMappedMemoryRange(vk, device, acBufferAlloc->getMemory(), acBufferAlloc->getOffset(), acMemorySize);
 
        vk::DescriptorSetLayoutBuilder  setLayoutBuilder;
        vk::DescriptorPoolBuilder               poolBuilder;