Added optimization avoiding shader disassembly
authorJari Komppa <jari.komppa@siru.fi>
Fri, 2 Feb 2018 13:00:22 +0000 (15:00 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 8 Feb 2018 12:44:12 +0000 (07:44 -0500)
This change avoids disassembling shaders if the
--deqp-log-shader-sources=disable option is used.

The default functionality disassembles everything and discards the
result if the shader source logging is disabled. This change skips the
disassembly too.

The performance gain for this is approximately 10% of runtime.

The timings are based on assumption of debug build and having the
shader cache with zero cache misses.

Affects:

none

Components: Framework

Vk-GL-CTS isue: 899

Change-Id: I36eda000a94400d8f50a565c7ef30f4170d51c83

external/vulkancts/modules/vulkan/vktTestPackage.cpp
framework/common/tcuTestLog.cpp
framework/common/tcuTestLog.hpp

index a45302e7b2c276596275a6cb73c5102faf4afc80..d334eaf98c583612f33c3577b3d5cdab411cf67d 100644 (file)
@@ -221,6 +221,7 @@ void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePat
        const TestCase*                 vktCase         = dynamic_cast<TestCase*>(testCase);
        tcu::TestLog&                   log                     = m_context.getTestContext().getLog();
        vk::SourceCollections   sourceProgs;
+       const bool                              doShaderLog     = log.isShaderLoggingEnabled();
 
        DE_UNREF(casePath); // \todo [2015-03-13 pyry] Use this to identify ProgramCollection storage path
 
@@ -234,17 +235,20 @@ void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePat
        {
                const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::GlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection);
 
-               try
+               if (doShaderLog)
                {
-                       std::ostringstream disasm;
+                       try
+                       {
+                               std::ostringstream disasm;
 
-                       vk::disassembleProgram(*binProg, &disasm);
+                               vk::disassembleProgram(*binProg, &disasm);
 
-                       log << vk::SpirVAsmSource(disasm.str());
-               }
-               catch (const tcu::NotSupportedError& err)
-               {
-                       log << err;
+                               log << vk::SpirVAsmSource(disasm.str());
+                       }
+                       catch (const tcu::NotSupportedError& err)
+                       {
+                               log << err;
+                       }
                }
        }
 
@@ -252,17 +256,20 @@ void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePat
        {
                const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::HlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection);
 
-               try
+               if (doShaderLog)
                {
-                       std::ostringstream disasm;
+                       try
+                       {
+                               std::ostringstream disasm;
 
-                       vk::disassembleProgram(*binProg, &disasm);
+                               vk::disassembleProgram(*binProg, &disasm);
 
-                       log << vk::SpirVAsmSource(disasm.str());
-               }
-               catch (const tcu::NotSupportedError& err)
-               {
-                       log << err;
+                               log << vk::SpirVAsmSource(disasm.str());
+                       }
+                       catch (const tcu::NotSupportedError& err)
+                       {
+                               log << err;
+                       }
                }
        }
 
index df60b50cd11b29610da4e5341fda0184db19b31a..4ff823e729616c5b674140bcaacfacca780e6e48 100644 (file)
@@ -513,6 +513,11 @@ void TestLog::endSampleList (void)
                throw LogWriteFailedError();
 }
 
+bool TestLog::isShaderLoggingEnabled (void)
+{
+       return (qpTestLog_getLogFlags(m_log) & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) == 0;
+}
+
 const TestLog::BeginMessageToken               TestLog::Message                        = TestLog::BeginMessageToken();
 const TestLog::EndMessageToken                 TestLog::EndMessage                     = TestLog::EndMessageToken();
 const TestLog::EndImageSetToken                        TestLog::EndImageSet            = TestLog::EndImageSetToken();
index 5b2bc3c50fd31553a2e5931b31165f33b872c025..03d236eac80c0f914b9a4765da08b4a1015b3281 100644 (file)
@@ -171,6 +171,7 @@ public:
        void                            endSample                               (void);
        void                            endSampleList                   (void);
 
+       bool                            isShaderLoggingEnabled  (void);
 private:
                                                TestLog                                 (const TestLog& other); // Not allowed!
        TestLog&                        operator=                               (const TestLog& other); // Not allowed!