From 2792f6271bdf6345a4a2902b6ccd821c395dc760 Mon Sep 17 00:00:00 2001 From: Victor Lomuller Date: Wed, 12 Jun 2019 15:53:49 +0100 Subject: [PATCH] Allow tests to be executed with SPIR-V 1.4 Components: Framework Change-Id: I3135d7b0d96234bec53bbc4ec0185f4c816a5dcf (cherry picked from commit 9b4c4d1645edb2e09d8357fa62b810df5ba3b9ec) --- .../vulkancts/framework/vulkan/vkShaderProgram.hpp | 7 +++++-- .../vulkancts/framework/vulkan/vkShaderToSpirV.cpp | 3 +++ .../vulkancts/framework/vulkan/vkValidatorOptions.hpp | 4 ++-- .../vulkancts/modules/vulkan/vktBuildPrograms.cpp | 19 +++++++++++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/external/vulkancts/framework/vulkan/vkShaderProgram.hpp b/external/vulkancts/framework/vulkan/vkShaderProgram.hpp index c5e6853..f0ec36c 100644 --- a/external/vulkancts/framework/vulkan/vkShaderProgram.hpp +++ b/external/vulkancts/framework/vulkan/vkShaderProgram.hpp @@ -50,17 +50,20 @@ struct ShaderBuildOptions deUint32 vulkanVersion; SpirvVersion targetVersion; deUint32 flags; + bool supports_VK_KHR_spirv_1_4; - ShaderBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_, deUint32 flags_) + ShaderBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_, deUint32 flags_, bool allowSpirv14 = false) : vulkanVersion (vulkanVersion_) , targetVersion (targetVersion_) , flags (flags_) + , supports_VK_KHR_spirv_1_4(allowSpirv14) {} ShaderBuildOptions (void) : vulkanVersion (VK_MAKE_VERSION(1, 0, 0)) , targetVersion (SPIRV_VERSION_1_0) , flags (0u) + , supports_VK_KHR_spirv_1_4 (false) {} SpirvValidatorOptions getSpirvValidatorOptions() const @@ -80,7 +83,7 @@ struct ShaderBuildOptions rules = SpirvValidatorOptions::kRelaxedBlockLayout; } - return SpirvValidatorOptions(vulkanVersion, rules); + return SpirvValidatorOptions(vulkanVersion, rules, supports_VK_KHR_spirv_1_4); } }; diff --git a/external/vulkancts/framework/vulkan/vkShaderToSpirV.cpp b/external/vulkancts/framework/vulkan/vkShaderToSpirV.cpp index e09d1b4..1fe287a 100644 --- a/external/vulkancts/framework/vulkan/vkShaderToSpirV.cpp +++ b/external/vulkancts/framework/vulkan/vkShaderToSpirV.cpp @@ -293,6 +293,9 @@ bool compileShaderToSpirV (const std::vector* sources, const Shader case SPIRV_VERSION_1_3: shader.setEnvTarget(glslang::EshTargetSpv, (glslang::EShTargetLanguageVersion)0x10300); break; + case SPIRV_VERSION_1_4: + shader.setEnvTarget(glslang::EshTargetSpv, (glslang::EShTargetLanguageVersion)0x10400); + break; default: TCU_THROW(InternalError, "Unsupported SPIR-V target version"); } diff --git a/external/vulkancts/framework/vulkan/vkValidatorOptions.hpp b/external/vulkancts/framework/vulkan/vkValidatorOptions.hpp index e14b4c7..f593913 100644 --- a/external/vulkancts/framework/vulkan/vkValidatorOptions.hpp +++ b/external/vulkancts/framework/vulkan/vkValidatorOptions.hpp @@ -44,8 +44,8 @@ struct SpirvValidatorOptions kScalarBlockLayout }; - SpirvValidatorOptions(deUint32 the_vulkan_version = VK_MAKE_VERSION(1, 0, 0), BlockLayoutRules the_layout = kDefaultBlockLayout) - : vulkanVersion(the_vulkan_version), blockLayout(the_layout), supports_VK_KHR_spirv_1_4(false) {} + SpirvValidatorOptions(deUint32 the_vulkan_version = VK_MAKE_VERSION(1, 0, 0), BlockLayoutRules the_layout = kDefaultBlockLayout, bool allowSpirv14 = false) + : vulkanVersion(the_vulkan_version), blockLayout(the_layout), supports_VK_KHR_spirv_1_4(allowSpirv14) {} // The target Vulkan version. This determines the SPIR-V environment rules to // be checked. The bit pattern is as produced by VK_MAKE_VERSION. diff --git a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp index f04e39c..f93bb00 100644 --- a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp +++ b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp @@ -394,7 +394,8 @@ BuildStats buildPrograms (tcu::TestContext& testCtx, const bool validateBinaries, const deUint32 usedVulkanVersion, const vk::SpirvVersion baselineSpirvVersion, - const vk::SpirvVersion maxSpirvVersion) + const vk::SpirvVersion maxSpirvVersion, + const bool allowSpirV14) { const deUint32 numThreads = deGetNumAvailableLogicalCores(); @@ -447,7 +448,8 @@ BuildStats buildPrograms (tcu::TestContext& testCtx, ++progIter) { // Source program requires higher SPIR-V version than available: skip it to avoid fail - if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion) + // Unless this is SPIR-V 1.4 and is explicitly allowed. + if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion && !(allowSpirV14 && progIter.getProgram().buildOptions.supports_VK_KHR_spirv_1_4 && progIter.getProgram().buildOptions.targetVersion == vk::SPIRV_VERSION_1_4)) continue; programs.pushBack(Program(vk::ProgramIdentifier(casePath, progIter.getName()), progIter.getProgram().buildOptions.getSpirvValidatorOptions())); @@ -461,7 +463,8 @@ BuildStats buildPrograms (tcu::TestContext& testCtx, ++progIter) { // Source program requires higher SPIR-V version than available: skip it to avoid fail - if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion) + // Unless this is SPIR-V 1.4 and is explicitly allowed. + if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion && !(allowSpirV14 && progIter.getProgram().buildOptions.supports_VK_KHR_spirv_1_4 && progIter.getProgram().buildOptions.targetVersion == vk::SPIRV_VERSION_1_4)) continue; programs.pushBack(Program(vk::ProgramIdentifier(casePath, progIter.getName()), progIter.getProgram().buildOptions.getSpirvValidatorOptions())); @@ -475,7 +478,8 @@ BuildStats buildPrograms (tcu::TestContext& testCtx, ++progIter) { // Source program requires higher SPIR-V version than available: skip it to avoid fail - if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion) + // Unless this is SPIR-V 1.4 and is explicitly allowed. + if (progIter.getProgram().buildOptions.targetVersion > maxSpirvVersion && !(allowSpirV14 && progIter.getProgram().buildOptions.supports_VK_KHR_spirv_1_4 && progIter.getProgram().buildOptions.targetVersion == vk::SPIRV_VERSION_1_4)) continue; programs.pushBack(Program(vk::ProgramIdentifier(casePath, progIter.getName()), progIter.getProgram().buildOptions.getSpirvValidatorOptions())); @@ -562,6 +566,7 @@ 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); +DE_DECLARE_COMMAND_LINE_OPT(SpirvAllow14, bool); static const de::cmdline::NamedValue s_enableNames[] = { @@ -590,7 +595,8 @@ void registerOptions (de::cmdline::Parser& parser) << Option("r", "shadercache-filename", "Write shader cache to given file", "shadercache.bin") << Option("x", "shadercache-truncate", "Truncate shader cache before running", s_enableNames, "enable") << Option("o", "deqp-optimize-spirv", "Enable optimization for SPIR-V", s_enableNames, "disable") - << Option("p","deqp-optimization-recipe", "Shader optimization recipe"); + << Option("p","deqp-optimization-recipe", "Shader optimization recipe") + << Option("e","allow-spirv-14", "Allow SPIR-V 1.4 with Vulkan 1.1"); } } // opt @@ -682,7 +688,8 @@ int main (int argc, const char* argv[]) cmdLine.getOption(), cmdLine.getOption(), baselineSpirvVersion, - maxSpirvVersion); + maxSpirvVersion, + cmdLine.getOption()); tcu::print("DONE: %d passed, %d failed, %d not supported\n", stats.numSucceeded, stats.numFailed, stats.notSupported); -- 2.7.4