Restructure copy image test iterations
authorKalle Raita <kraita@google.com>
Tue, 24 Jan 2017 19:47:17 +0000 (11:47 -0800)
committerKalle Raita <kraita@google.com>
Tue, 14 Feb 2017 20:44:46 +0000 (12:44 -0800)
Packing test iterations so that work per buffer swap is maximized
without running the risk of hitting per-iteration timeout. Yields
execution time drops of roughly 50% on at least 2 GPU architectures.

Bug: 33965234
Test: Copy image tests on multiple devices and L MR1 N9 for detection capability.
Change-Id: I7de5231da0d8a1d2bd22ec3741f1481e2ebd5475

modules/gles31/functional/es31fCopyImageTests.cpp

index 050e201..6a37335 100644 (file)
@@ -1669,6 +1669,7 @@ public:
        TestCase::IterateResult iterate                                 (void);
 
 private:
+
        void                                    logTestInfoIter                 (void);
        void                                    createImagesIter                (void);
        void                                    destroyImagesIter               (void);
@@ -1678,6 +1679,20 @@ private:
        void                                    renderDestinationIter   (void);
        void                                    copyImageIter                   (void);
 
+       typedef void (CopyImageTest::*IterationFunc)(void);
+
+       struct Iteration
+       {
+               Iteration (int methodCount_, const IterationFunc* methods_)
+                       : methodCount   (methodCount_)
+                       , methods               (methods_)
+               {
+               }
+
+               int                                             methodCount;
+               const IterationFunc*    methods;
+       };
+
        struct State
        {
                State (int                                      seed,
@@ -2058,31 +2073,65 @@ void CopyImageTest::copyImageIter (void)
 
 TestCase::IterateResult CopyImageTest::iterate (void)
 {
-       void(CopyImageTest::*methods[])(void) =
+       // Note: Returning from iterate() has two side-effects: it touches
+       // watchdog and calls eglSwapBuffers. For the first it's important
+       // to keep work per iteration reasonable to avoid
+       // timeouts. Because of the latter, it's prudent to do more than
+       // trivial amount of work. Otherwise we'll end up waiting for a
+       // new buffer in swap, it seems.
+
+       // The split below tries to combine trivial work with actually
+       // expensive rendering iterations without having too much
+       // rendering in one iteration to avoid timeouts.
+       const IterationFunc iteration1[] =
        {
                &CopyImageTest::logTestInfoIter,
-
-               // Render both images and then copy and verify again.
                &CopyImageTest::createImagesIter,
-               &CopyImageTest::renderSourceIter,
-               &CopyImageTest::renderDestinationIter,
+               &CopyImageTest::renderSourceIter
+       };
+       const IterationFunc iteration2[] =
+       {
+               &CopyImageTest::renderDestinationIter
+       };
+       const IterationFunc iteration3[] =
+       {
                &CopyImageTest::copyImageIter,
-               &CopyImageTest::verifySourceIter,
+               &CopyImageTest::verifySourceIter
+       };
+       const IterationFunc iteration4[] =
+       {
                &CopyImageTest::verifyDestinationIter,
-               &CopyImageTest::destroyImagesIter,
-
-               // Create images and immediately copies between thew and verify.
+               &CopyImageTest::destroyImagesIter
+       };
+       const IterationFunc iteration5[] =
+       {
                &CopyImageTest::createImagesIter,
                &CopyImageTest::copyImageIter,
-               &CopyImageTest::verifySourceIter,
+               &CopyImageTest::verifySourceIter
+       };
+       const IterationFunc iteration6[] =
+       {
                &CopyImageTest::verifyDestinationIter,
                &CopyImageTest::destroyImagesIter
        };
+       const Iteration iterations[] =
+       {
+               Iteration(DE_LENGTH_OF_ARRAY(iteration1), iteration1),
+               Iteration(DE_LENGTH_OF_ARRAY(iteration2), iteration2),
+               Iteration(DE_LENGTH_OF_ARRAY(iteration3), iteration3),
+               Iteration(DE_LENGTH_OF_ARRAY(iteration4), iteration4),
+               Iteration(DE_LENGTH_OF_ARRAY(iteration5), iteration5),
+               Iteration(DE_LENGTH_OF_ARRAY(iteration6), iteration6)
+       };
+
+       DE_ASSERT(m_iteration < DE_LENGTH_OF_ARRAY(iterations));
+       for (int method = 0; method < iterations[m_iteration].methodCount; method++)
+               (this->*iterations[m_iteration].methods[method])();
+
+       m_iteration++;
 
-       if (m_iteration < DE_LENGTH_OF_ARRAY(methods))
+       if (m_iteration < DE_LENGTH_OF_ARRAY(iterations))
        {
-               (this->*methods[m_iteration])();
-               m_iteration++;
                return CONTINUE;
        }
        else