Add SPIR-V optimization options to vk-build-programs
authorAlexander Galazin <alexander.galazin@arm.com>
Tue, 25 Sep 2018 13:42:44 +0000 (15:42 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 27 Sep 2018 19:19:30 +0000 (15:19 -0400)
Components: Vulkan

VK-GL-CTS issue: 1378

Change-Id: I05640c67b6bcc3e7daea84a200ca4033c27c2ac4

external/vulkancts/modules/vulkan/vktBuildPrograms.cpp

index a0fd14b..3b501a0 100644 (file)
@@ -567,6 +567,8 @@ DE_DECLARE_COMMAND_LINE_OPT(VulkanVersion,                  deUint32);
 DE_DECLARE_COMMAND_LINE_OPT(ShaderCache,                       bool);
 DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheFilename,       std::string);
 DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheTruncate,       bool);
+DE_DECLARE_COMMAND_LINE_OPT(SpirvOptimize,                     bool);
+DE_DECLARE_COMMAND_LINE_OPT(SpirvOptimizationRecipe,std::string);
 
 static const de::cmdline::NamedValue<bool> s_enableNames[] =
 {
@@ -593,7 +595,9 @@ void registerOptions (de::cmdline::Parser& parser)
                << Option<opt::VulkanVersion>("t", "target-vulkan-version", "Target Vulkan version", s_vulkanVersion, "1.1")
                << Option<opt::ShaderCache>("s", "shadercache", "Enable or disable shader cache", s_enableNames, "enable")
                << Option<opt::ShaderCacheFilename>("r", "shadercache-filename", "Write shader cache to given file", "shadercache.bin")
-               << Option<opt::ShaderCacheTruncate>("x", "shadercache-truncate", "Truncate shader cache before running", s_enableNames, "enable");
+               << Option<opt::ShaderCacheTruncate>("x", "shadercache-truncate", "Truncate shader cache before running", s_enableNames, "enable")
+               << Option<opt::SpirvOptimize>("o", "deqp-optimize-spirv", "Enable optimization for SPIR-V", s_enableNames, "disable")
+               << Option<opt::SpirvOptimizationRecipe>("p","deqp-optimization-recipe", "Shader optimization recipe");
 }
 
 } // opt
@@ -648,6 +652,21 @@ int main (int argc, const char* argv[])
                                deqpArgv.push_back("disable");
                }
 
+               if (cmdLine.hasOption<opt::SpirvOptimize>())
+               {
+            deqpArgv.push_back("--deqp-optimize-spirv");
+                       if (cmdLine.getOption<opt::SpirvOptimize>())
+                               deqpArgv.push_back("enable");
+                        else
+                               deqpArgv.push_back("disable");
+               }
+
+               if (cmdLine.hasOption<opt::SpirvOptimizationRecipe>())
+               {
+                       deqpArgv.push_back("--deqp-optimization-recipe");
+                       deqpArgv.push_back(cmdLine.getOption<opt::SpirvOptimizationRecipe>().c_str());
+               }
+
                if (!deqpCmdLine.parse((int)deqpArgv.size(), &deqpArgv[0]))
                        return -1;
        }