From ec2837040a7b3ca5d4ef64ee6b24735a150358f1 Mon Sep 17 00:00:00 2001 From: Jari Komppa Date: Fri, 2 Feb 2018 15:00:22 +0200 Subject: [PATCH] Added optimization avoiding shader disassembly 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 --- .../vulkancts/modules/vulkan/vktTestPackage.cpp | 39 +++++++++++++--------- framework/common/tcuTestLog.cpp | 5 +++ framework/common/tcuTestLog.hpp | 1 + 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/external/vulkancts/modules/vulkan/vktTestPackage.cpp b/external/vulkancts/modules/vulkan/vktTestPackage.cpp index a45302e..d334eaf 100644 --- a/external/vulkancts/modules/vulkan/vktTestPackage.cpp +++ b/external/vulkancts/modules/vulkan/vktTestPackage.cpp @@ -221,6 +221,7 @@ void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePat const TestCase* vktCase = dynamic_cast(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(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(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; + } } } diff --git a/framework/common/tcuTestLog.cpp b/framework/common/tcuTestLog.cpp index df60b50..4ff823e 100644 --- a/framework/common/tcuTestLog.cpp +++ b/framework/common/tcuTestLog.cpp @@ -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(); diff --git a/framework/common/tcuTestLog.hpp b/framework/common/tcuTestLog.hpp index 5b2bc3c..03d236e 100644 --- a/framework/common/tcuTestLog.hpp +++ b/framework/common/tcuTestLog.hpp @@ -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! -- 2.7.4