Fixup some missing/incorrect flushes and invalidates
authorGary Sweet <gsweet@broadcom.com>
Mon, 4 Sep 2017 10:14:58 +0000 (11:14 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 7 Sep 2017 15:41:08 +0000 (11:41 -0400)
Some of the flushes were too small, and there were a few
missing invalidates.

Affects:
dEQP-VK.ssbo.layout.*
dEQP-VK.pipeline.push_constant.compute_pipeline.simple_test

Components: Vulkan

VK-GL-CTS issue: 660

Change-Id: I27fac24397984f82865683f30b823570c3e52aed

external/vulkancts/modules/vulkan/pipeline/vktPipelinePushConstantTests.cpp
external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutCase.cpp

index d49b7ae..dddf31b 100644 (file)
@@ -1549,6 +1549,8 @@ tcu::TestStatus PushConstantComputeTestInstance::iterate (void)
        VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
        VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity*/));
 
+       invalidateMappedMemoryRange(vk, vkDevice, m_outBufferAlloc->getMemory(), m_outBufferAlloc->getOffset(), (size_t)(sizeof(tcu::Vec4) * 8));
+
        // verify result
        std::vector<tcu::Vec4>  expectValue(8, tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
        if (deMemCmp((void*)(&expectValue[0]), m_outBufferAlloc->getHostPtr(), (size_t)(sizeof(tcu::Vec4) * 8)))
index c77b90f..95703c8 100644 (file)
@@ -2111,29 +2111,10 @@ tcu::TestStatus SSBOLayoutCaseInstance::iterate (void)
                        mappedBlockPtrs = blockLocationsToPtrs(m_refLayout, blockLocations, mapPtrs);
                        copyData(m_refLayout, mappedBlockPtrs, m_refLayout, m_initialData.pointers);
 
-                       if (m_bufferMode == SSBOLayoutCase::BUFFERMODE_PER_BLOCK)
+                       for (size_t allocNdx = 0; allocNdx < m_uniformAllocs.size(); allocNdx++)
                        {
-                               DE_ASSERT(m_uniformAllocs.size() == bufferSizes.size());
-                               for (size_t allocNdx = 0; allocNdx < m_uniformAllocs.size(); allocNdx++)
-                               {
-                                       const int size = bufferSizes[allocNdx];
-                                       vk::Allocation* alloc = m_uniformAllocs[allocNdx].get();
-                                       flushMappedMemoryRange(vk, device, alloc->getMemory(), alloc->getOffset(), size);
-                               }
-                       }
-                       else
-                       {
-                               DE_ASSERT(m_bufferMode == SSBOLayoutCase::BUFFERMODE_SINGLE);
-                               DE_ASSERT(m_uniformAllocs.size() == 1);
-                               int totalSize = 0;
-                               for (size_t bufferNdx = 0; bufferNdx < bufferSizes.size(); bufferNdx++)
-                               {
-                                       totalSize += bufferSizes[bufferNdx];
-                               }
-
-                               DE_ASSERT(totalSize > 0);
-                               vk::Allocation* alloc = m_uniformAllocs[0].get();
-                               flushMappedMemoryRange(vk, device, alloc->getMemory(), alloc->getOffset(), totalSize);
+                               vk::Allocation* alloc = m_uniformAllocs[allocNdx].get();
+                               flushMappedMemoryRange(vk, device, alloc->getMemory(), alloc->getOffset(), VK_WHOLE_SIZE);
                        }
                }
        }
@@ -2266,6 +2247,8 @@ tcu::TestStatus SSBOLayoutCaseInstance::iterate (void)
                const int refCount = 1;
                int resCount = 0;
 
+               invalidateMappedMemoryRange(vk, device, acBufferAlloc->getMemory(), acBufferAlloc->getOffset(), acBufferSize);
+
                resCount = *((const int*)acBufferAlloc->getHostPtr());
 
                counterOk = (refCount == resCount);
@@ -2275,6 +2258,12 @@ tcu::TestStatus SSBOLayoutCaseInstance::iterate (void)
                }
        }
 
+       for (size_t allocNdx = 0; allocNdx < m_uniformAllocs.size(); allocNdx++)
+       {
+               vk::Allocation *alloc = m_uniformAllocs[allocNdx].get();
+               invalidateMappedMemoryRange(vk, device, alloc->getMemory(), alloc->getOffset(), VK_WHOLE_SIZE);
+       }
+
        // Validate result
        const bool compareOk = compareData(m_context.getTestContext().getLog(), m_refLayout, m_writeData.pointers, m_refLayout, mappedBlockPtrs);