Merge gerrit/vulkan-cts-1.0.2 into gerrit/vulkan-cts-1.0-dev
authorPyry Haulos <phaulos@google.com>
Fri, 6 Jan 2017 20:44:58 +0000 (12:44 -0800)
committerPyry Haulos <phaulos@google.com>
Fri, 6 Jan 2017 20:44:58 +0000 (12:44 -0800)
Change-Id: I5d98762111c8dba323a81a7179026d009f39934e

external/vulkancts/framework/vulkan/vkAllocationCallbackUtil.cpp
external/vulkancts/framework/vulkan/vkAllocationCallbackUtil.hpp
external/vulkancts/modules/vulkan/api/vktApiGranularityTests.cpp
external/vulkancts/modules/vulkan/api/vktApiObjectManagementTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSurfaceTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSwapchainTests.cpp
framework/platform/android/tcuAndroidWindow.cpp

index 36027b9..aa3034f 100644 (file)
@@ -277,21 +277,21 @@ void AllocationCallbackRecorder::notifyInternalFree (size_t size, VkInternalAllo
 
 // DeterministicFailAllocator
 
-DeterministicFailAllocator::DeterministicFailAllocator (const VkAllocationCallbacks* allocator, deUint32 numPassingAllocs, Mode initialMode)
+DeterministicFailAllocator::DeterministicFailAllocator (const VkAllocationCallbacks* allocator, Mode mode, deUint32 numPassingAllocs)
        : ChainedAllocator      (allocator)
-       , m_numPassingAllocs(numPassingAllocs)
-       , m_mode                        (initialMode)
-       , m_allocationNdx       (0)
 {
+       reset(mode, numPassingAllocs);
 }
 
 DeterministicFailAllocator::~DeterministicFailAllocator (void)
 {
 }
 
-void DeterministicFailAllocator::setMode (Mode mode)
+void DeterministicFailAllocator::reset (Mode mode, deUint32 numPassingAllocs)
 {
-       m_mode = mode;
+       m_mode                          = mode;
+       m_numPassingAllocs      = numPassingAllocs;
+       m_allocationNdx         = 0;
 }
 
 void* DeterministicFailAllocator::allocate (size_t size, size_t alignment, VkSystemAllocationScope allocationScope)
index 7e5dbd0..5ae46e1 100644 (file)
@@ -167,18 +167,17 @@ public:
                MODE_LAST
        };
 
-                                                       DeterministicFailAllocator      (const VkAllocationCallbacks* allocator, deUint32 numPassingAllocs, Mode initialMode);
+                                                       DeterministicFailAllocator      (const VkAllocationCallbacks* allocator, Mode mode, deUint32 numPassingAllocs);
                                                        ~DeterministicFailAllocator     (void);
 
-       void                                    setMode                                         (Mode mode);
+       void                                    reset                                           (Mode mode, deUint32 numPassingAllocs);
 
        void*                                   allocate                                        (size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
        void*                                   reallocate                                      (void* original, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
 
 private:
-       const deUint32                  m_numPassingAllocs;
-
        Mode                                    m_mode;
+       deUint32                                m_numPassingAllocs;
        volatile deUint32               m_allocationNdx;
 };
 
index fa79bfb..9e5582e 100644 (file)
@@ -200,6 +200,14 @@ void GranularityInstance::initImages (void)
                if (!aspectFlags)
                        aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
 
+               VkFormatProperties formatProperties;
+               m_context.getInstanceInterface().getPhysicalDeviceFormatProperties(m_context.getPhysicalDevice(),
+                                                                                  it->format, &formatProperties);
+
+               if ((formatProperties.optimalTilingFeatures & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
+                                                              VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
+                       throw tcu::NotSupportedError("Format not supported as attachment");
+
                const VkImageViewCreateInfo             createInfo      =
                {
                        VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,               // VkStructureType                      sType;
@@ -282,7 +290,7 @@ void GranularityInstance::initRenderPass (void)
                        &imageViews[0],                                                         // const VkImageView*           pAttachments;
                        1,                                                                                      // deUint32                                     width;
                        1,                                                                                      // deUint32                                     height;
-                       0                                                                                       // deUint32                                     layers;
+                       1                                                                                       // deUint32                                     layers;
                };
 
                m_frameBuffer   = createFramebuffer(vk, device, &framebufferParams);
index 48e04ac..e1b824a 100644 (file)
@@ -2464,8 +2464,8 @@ tcu::TestStatus allocCallbackFailTest (Context& context, typename Object::Parame
                for (; numPassingAllocs < maxTries; ++numPassingAllocs)
                {
                        DeterministicFailAllocator                      objAllocator(getSystemAllocator(),
-                                                                                                                        numPassingAllocs,
-                                                                                                                        DeterministicFailAllocator::MODE_COUNT_AND_FAIL);
+                                                                                                                        DeterministicFailAllocator::MODE_COUNT_AND_FAIL,
+                                                                                                                        numPassingAllocs);
                        AllocationCallbackRecorder                      recorder        (objAllocator.getCallbacks(), 128);
                        const Environment                                       objEnv          (resEnv.env.vkp,
                                                                                                                         resEnv.env.vkd,
@@ -2545,7 +2545,7 @@ tcu::TestStatus allocCallbackFailMultipleObjectsTest (Context& context, typename
 
                        // \note We have to use the same allocator for both resource dependencies and the object under test,
                        //       because pooled objects take memory from the pool.
-                       DeterministicFailAllocator                      objAllocator(getSystemAllocator(), numPassingAllocs, DeterministicFailAllocator::MODE_DO_NOT_COUNT);
+                       DeterministicFailAllocator                      objAllocator(getSystemAllocator(), DeterministicFailAllocator::MODE_DO_NOT_COUNT, 0);
                        AllocationCallbackRecorder                      recorder        (objAllocator.getCallbacks(), 128);
                        const Environment                                       objEnv          (context.getPlatformInterface(),
                                                                                                                         context.getDeviceInterface(),
@@ -2563,7 +2563,7 @@ tcu::TestStatus allocCallbackFailMultipleObjectsTest (Context& context, typename
                        {
                                const typename Object::Resources res (objEnv, params);
 
-                               objAllocator.setMode(DeterministicFailAllocator::MODE_COUNT_AND_FAIL);
+                               objAllocator.reset(DeterministicFailAllocator::MODE_COUNT_AND_FAIL, numPassingAllocs);
                                const vector<ObjectTypeSp> scopedHandles = Object::createMultiple(objEnv, res, params, &handles, &result);
                        }
 
index 0167e2d..2c108e9 100644 (file)
@@ -281,8 +281,8 @@ tcu::TestStatus createSurfaceSimulateOOMTest (Context& context, Type wsiType)
        {
                AllocationCallbackRecorder      allocationRecorder      (getSystemAllocator());
                DeterministicFailAllocator      failingAllocator        (allocationRecorder.getCallbacks(),
-                                                                                                                numPassingAllocs,
-                                                                                                                DeterministicFailAllocator::MODE_DO_NOT_COUNT);
+                                                                                                                DeterministicFailAllocator::MODE_DO_NOT_COUNT,
+                                                                                                                0);
                bool                                            gotOOM                          = false;
 
                log << TestLog::Message << "Testing with " << numPassingAllocs << " first allocations succeeding" << TestLog::EndMessage;
@@ -293,7 +293,7 @@ tcu::TestStatus createSurfaceSimulateOOMTest (Context& context, Type wsiType)
 
                        // OOM is not simulated for VkInstance as we don't want to spend time
                        // testing OOM paths inside instance creation.
-                       failingAllocator.setMode(DeterministicFailAllocator::MODE_COUNT_AND_FAIL);
+                       failingAllocator.reset(DeterministicFailAllocator::MODE_COUNT_AND_FAIL, numPassingAllocs);
 
                        const NativeObjects                     native          (context, instHelper.supportedExtensions, wsiType);
                        const Unique<VkSurfaceKHR>      surface         (createSurface(instHelper.vki,
index 683d922..1d78145 100644 (file)
@@ -578,99 +578,84 @@ tcu::TestStatus createSwapchainTest (Context& context, TestParameters params)
        return tcu::TestStatus::pass("Creating swapchain succeeded");
 }
 
-class CreateSwapchainSimulateOOMTest : public TestInstance
+tcu::TestStatus createSwapchainSimulateOOMTest (Context& context, TestParameters params)
 {
-public:
-                                                       CreateSwapchainSimulateOOMTest  (Context& context, TestParameters params)
-                       : TestInstance                  (context)
-                       , m_params                              (params)
-                       , m_numPassingAllocs    (0)
-       {
-       }
-
-       tcu::TestStatus                 iterate                                                 (void);
-
-private:
-       const TestParameters    m_params;
-       deUint32                                m_numPassingAllocs;
-};
+       const size_t                            maxCases                        = 300u;
+       const deUint32                          maxAllocs                       = 1024u;
 
-tcu::TestStatus CreateSwapchainSimulateOOMTest::iterate (void)
-{
-       tcu::TestLog&   log     = m_context.getTestContext().getLog();
+       tcu::TestLog&                           log                                     = context.getTestContext().getLog();
+       tcu::ResultCollector            results                         (log);
 
-       // \note This is a little counter-intuitive order (iterating on callback count until all cases pass)
-       //               but since cases depend on what device reports, it is the only easy way. In practice
-       //               we should see same number of total callbacks (and executed code) regardless of the
-       //               loop order.
-
-       if (m_numPassingAllocs <= 16*1024u)
+       AllocationCallbackRecorder      allocationRecorder      (getSystemAllocator());
+       DeterministicFailAllocator      failingAllocator        (allocationRecorder.getCallbacks(),
+                                                                                                        DeterministicFailAllocator::MODE_DO_NOT_COUNT,
+                                                                                                        0);
        {
-               AllocationCallbackRecorder      allocationRecorder      (getSystemAllocator());
-               DeterministicFailAllocator      failingAllocator        (allocationRecorder.getCallbacks(),
-                                                                                                                m_numPassingAllocs,
-                                                                                                                DeterministicFailAllocator::MODE_DO_NOT_COUNT);
-               bool                                            gotOOM                          = false;
-
-               log << TestLog::Message << "Testing with " << m_numPassingAllocs << " first allocations succeeding" << TestLog::EndMessage;
-
-               try
+               const InstanceHelper                                    instHelper      (context, params.wsiType, failingAllocator.getCallbacks());
+               const NativeObjects                                             native          (context, instHelper.supportedExtensions, params.wsiType);
+               const Unique<VkSurfaceKHR>                              surface         (createSurface(instHelper.vki,
+                                                                                                                                                       *instHelper.instance,
+                                                                                                                                                       params.wsiType,
+                                                                                                                                                       *native.display,
+                                                                                                                                                       *native.window,
+                                                                                                                                                       failingAllocator.getCallbacks()));
+               const DeviceHelper                                              devHelper       (context, instHelper.vki, *instHelper.instance, *surface, failingAllocator.getCallbacks());
+               const vector<VkSwapchainCreateInfoKHR>  allCases        (generateSwapchainParameterCases(params.wsiType, params.dimension, instHelper.vki, devHelper.physicalDevice, *surface));
+
+               if (maxCases < allCases.size())
+                       log << TestLog::Message << "Note: Will only test first " << maxCases << " cases out of total of " << allCases.size() << " parameter combinations" << TestLog::EndMessage;
+
+               for (size_t caseNdx = 0; caseNdx < de::min(maxCases, allCases.size()); ++caseNdx)
                {
-                       const InstanceHelper                                    instHelper      (m_context, m_params.wsiType, failingAllocator.getCallbacks());
-                       const NativeObjects                                             native          (m_context, instHelper.supportedExtensions, m_params.wsiType);
-                       const Unique<VkSurfaceKHR>                              surface         (createSurface(instHelper.vki,
-                                                                                                                                                          *instHelper.instance,
-                                                                                                                                                          m_params.wsiType,
-                                                                                                                                                          *native.display,
-                                                                                                                                                          *native.window,
-                                                                                                                                                          failingAllocator.getCallbacks()));
-                       const DeviceHelper                                              devHelper       (m_context, instHelper.vki, *instHelper.instance, *surface, failingAllocator.getCallbacks());
-                       const vector<VkSwapchainCreateInfoKHR>  cases           (generateSwapchainParameterCases(m_params.wsiType, m_params.dimension, instHelper.vki, devHelper.physicalDevice, *surface));
-
-                       // We don't care testing OOM paths in VkInstance, VkSurface, or VkDevice
-                       // creation as they are tested elsewhere.
-                       failingAllocator.setMode(DeterministicFailAllocator::MODE_COUNT_AND_FAIL);
-
-                       for (size_t caseNdx = 0; caseNdx < cases.size(); ++caseNdx)
+                       log << TestLog::Message << "Testing parameter case " << caseNdx << ": " << allCases[caseNdx] << TestLog::EndMessage;
+
+                       for (deUint32 numPassingAllocs = 0; numPassingAllocs <= maxAllocs; ++numPassingAllocs)
                        {
-                               VkSwapchainCreateInfoKHR        curParams       = cases[caseNdx];
+                               bool    gotOOM  = false;
 
-                               curParams.surface                               = *surface;
-                               curParams.queueFamilyIndexCount = 1u;
-                               curParams.pQueueFamilyIndices   = &devHelper.queueFamilyIndex;
+                               failingAllocator.reset(DeterministicFailAllocator::MODE_COUNT_AND_FAIL, numPassingAllocs);
 
-                               log
-                                       << TestLog::Message << "Sub-case " << (caseNdx+1) << " / " << cases.size() << TestLog::EndMessage;
+                               log << TestLog::Message << "Testing with " << numPassingAllocs << " first allocations succeeding" << TestLog::EndMessage;
 
+                               try
                                {
-                                       const Unique<VkSwapchainKHR>    swapchain       (createSwapchainKHR(devHelper.vkd, *devHelper.device, &curParams, failingAllocator.getCallbacks()));
+                                       VkSwapchainCreateInfoKHR        curParams       = allCases[caseNdx];
+
+                                       curParams.surface                               = *surface;
+                                       curParams.queueFamilyIndexCount = 1u;
+                                       curParams.pQueueFamilyIndices   = &devHelper.queueFamilyIndex;
+
+                                       {
+                                               const Unique<VkSwapchainKHR>    swapchain       (createSwapchainKHR(devHelper.vkd, *devHelper.device, &curParams, failingAllocator.getCallbacks()));
+                                       }
+                               }
+                               catch (const OutOfMemoryError& e)
+                               {
+                                       log << TestLog::Message << "Got " << e.getError() << TestLog::EndMessage;
+                                       gotOOM = true;
                                }
-                       }
-               }
-               catch (const OutOfMemoryError& e)
-               {
-                       log << TestLog::Message << "Got " << e.getError() << TestLog::EndMessage;
-                       gotOOM = true;
-               }
 
-               if (!validateAndLog(log, allocationRecorder, 0u))
-                       return tcu::TestStatus::fail("Detected invalid system allocation callback");
+                               if (!gotOOM)
+                               {
+                                       log << TestLog::Message << "Creating swapchain succeeded!" << TestLog::EndMessage;
 
-               if (!gotOOM)
-               {
-                       log << TestLog::Message << "Creating surface succeeded!" << TestLog::EndMessage;
+                                       if (numPassingAllocs == 0)
+                                               results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Allocation callbacks were not used");
 
-                       if (m_numPassingAllocs == 0)
-                               return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Allocation callbacks were not used");
-                       else
-                               return tcu::TestStatus::pass("OOM simulation completed");
+                                       break;
+                               }
+                               else if (numPassingAllocs == maxAllocs)
+                                       results.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Creating swapchain did not succeed, callback limit exceeded");
+                       }
                }
 
-               m_numPassingAllocs++;
-               return tcu::TestStatus::incomplete();
+               context.getTestContext().touchWatchdog();
        }
-       else
-               return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Creating swapchain did not succeed, callback limit exceeded");
+
+       if (!validateAndLog(log, allocationRecorder, 0u))
+               results.fail("Detected invalid system allocation callback");
+
+       return tcu::TestStatus(results.getResult(), results.getMessage());
 }
 
 struct GroupParameters
@@ -701,16 +686,6 @@ void populateSwapchainGroup (tcu::TestCaseGroup* testGroup, GroupParameters para
        }
 }
 
-void populateSwapchainOOMGroup (tcu::TestCaseGroup* testGroup, Type wsiType)
-{
-       for (int dimensionNdx = 0; dimensionNdx < TEST_DIMENSION_LAST; ++dimensionNdx)
-       {
-               const TestDimension             testDimension   = (TestDimension)dimensionNdx;
-
-               testGroup->addChild(new InstanceFactory1<CreateSwapchainSimulateOOMTest, TestParameters>(testGroup->getTestContext(), tcu::NODETYPE_SELF_VALIDATE, getTestDimensionName(testDimension), "", TestParameters(wsiType, testDimension)));
-       }
-}
-
 VkSwapchainCreateInfoKHR getBasicSwapchainParameters (Type                                             wsiType,
                                                                                                          const InstanceInterface&      vki,
                                                                                                          VkPhysicalDevice                      physicalDevice,
@@ -1760,7 +1735,7 @@ void populateDestroyGroup (tcu::TestCaseGroup* testGroup, Type wsiType)
 void createSwapchainTests (tcu::TestCaseGroup* testGroup, vk::wsi::Type wsiType)
 {
        addTestGroup(testGroup, "create",                       "Create VkSwapchain with various parameters",                                   populateSwapchainGroup,         GroupParameters(wsiType, createSwapchainTest));
-       addTestGroup(testGroup, "simulate_oom",         "Simulate OOM using callbacks during swapchain construction",   populateSwapchainOOMGroup,      wsiType);
+       addTestGroup(testGroup, "simulate_oom",         "Simulate OOM using callbacks during swapchain construction",   populateSwapchainGroup,         GroupParameters(wsiType, createSwapchainSimulateOOMTest));
        addTestGroup(testGroup, "render",                       "Rendering Tests",                                                                                              populateRenderGroup,            wsiType);
        addTestGroup(testGroup, "modify",                       "Modify VkSwapchain",                                                                                   populateModifyGroup,            wsiType);
        addTestGroup(testGroup, "destroy",                      "Destroy VkSwapchain",                                                                                  populateDestroyGroup,           wsiType);
index 619df0e..6444096 100644 (file)
@@ -72,7 +72,12 @@ void Window::release (void)
        de::ScopedLock lock(m_stateLock);
 
        if (m_state == STATE_IN_USE)
+       {
+               // Reset buffer size and format back to initial state
+               ANativeWindow_setBuffersGeometry(m_window, 0, 0, 0);
+
                m_state = STATE_AVAILABLE;
+       }
        else if (m_state == STATE_PENDING_DESTROY)
                m_state = STATE_READY_FOR_DESTROY;
        else