Fixup some missing/incorrect flushes and invalidates
authorGary Sweet <gsweet@broadcom.com>
Mon, 4 Sep 2017 09:39:36 +0000 (10:39 +0100)
committerGary Sweet <gsweet@broadcom.com>
Mon, 4 Sep 2017 09:39:36 +0000 (10:39 +0100)
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: Id29b59d127e004a028c04a1075db563d697140a1

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

index aeef07f9beea8dbc10b4a6ecb97136e27591a504..5c7314d1a2fa2365908cf83090a014fe73e40b07 100644 (file)
@@ -1445,6 +1445,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 7ac5fe383e487712dea445b8de10e12212991e0b..fd5309efc1f8f836c9ad514ec0ab15bb66ac33e9 100644 (file)
@@ -2039,29 +2039,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);
                        }
                }
        }
@@ -2216,6 +2197,8 @@ tcu::TestStatus SSBOLayoutCaseInstance::iterate (void)
                const int refCount = 1;
                int resCount = 0;
 
+               invalidateMappedMemoryRange(vk, device, acBufferAlloc->getMemory(), acBufferAlloc->getOffset(), acBufferSize);
+
                resCount = *(const int*)((const deUint8*)acBufferAlloc->getHostPtr());
 
                counterOk = (refCount == resCount);
@@ -2225,6 +2208,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);