return vk::SPIRV_VERSION_1_0;
}
-// Max supported versions for each vulkan version, without requiring a Vulkan extension.
-vk::SpirvVersion getMaxSpirvVersionForAsm (const deUint32 vulkanVersion)
+// Max supported versions for each Vulkan version, without requiring a Vulkan extension.
+vk::SpirvVersion getMaxSpirvVersionForVulkan (const deUint32 vulkanVersion)
{
vk::SpirvVersion result = vk::SPIRV_VERSION_LAST;
return result;
}
-vk::SpirvVersion getMaxSpirvVersionForGlsl (const deUint32 vulkanVersion)
+vk::SpirvVersion getMaxSpirvVersionForAsm (const deUint32 vulkanVersion)
{
- vk::SpirvVersion result = vk::SPIRV_VERSION_LAST;
-
- deUint32 vulkanVersionMajorMinor = VK_MAKE_VERSION(VK_VERSION_MAJOR(vulkanVersion), VK_VERSION_MINOR(vulkanVersion), 0);
- if (vulkanVersionMajorMinor == VK_API_VERSION_1_0)
- result = vk::SPIRV_VERSION_1_0;
- else if (vulkanVersionMajorMinor >= VK_API_VERSION_1_1)
- result = vk::SPIRV_VERSION_1_3;
-
- DE_ASSERT(result < vk::SPIRV_VERSION_LAST);
+ return getMaxSpirvVersionForVulkan(vulkanVersion);
+}
- return result;
+vk::SpirvVersion getMaxSpirvVersionForGlsl (const deUint32 vulkanVersion)
+{
+ return getMaxSpirvVersionForVulkan(vulkanVersion);
}
SpirvVersion extractSpirvVersion (const ProgramBinary& binary)
glu::ShaderType getGluShaderType (VkShaderStageFlagBits shaderStage);
VkShaderStageFlagBits getVkShaderStage (glu::ShaderType shaderType);
+// Returns the max SPIR-V version usable with a given Vulkan version, without requiring an extension.
+vk::SpirvVersion getMaxSpirvVersionForVulkan (const deUint32 vulkanVersion);
+// Deprecated. Use getMaxSpirvVersionForVulkan instead.
vk::SpirvVersion getMaxSpirvVersionForAsm (const deUint32 vulkanVersion);
+// Deprecated. Use getMaxSpirvVersionForVulkan instead.
vk::SpirvVersion getMaxSpirvVersionForGlsl (const deUint32 vulkanVersion);
vk::SpirvVersion getBaselineSpirvVersion (const deUint32 vulkanVersion);
SpirvVersion extractSpirvVersion (const ProgramBinary& binary);
using std::string;
using std::vector;
-// Convert a Vulkan version number to a SPIRV-Tools target environment enum.
-static spv_target_env mapVulkanVersionToSpirvToolsEnv(deUint32 vulkanVersion)
+// Returns the SPIRV-Tools target environment enum for the given dEQP Spirv validator options object.
+// Do this here instead of as a method on SpirvValidatorOptions because only this file has access to
+// the SPIRV-Tools headers.
+static spv_target_env getSpirvToolsEnvForValidatorOptions(SpirvValidatorOptions opts)
{
- switch (vulkanVersion)
+ const bool allow_1_4 = opts.supports_VK_KHR_spirv_1_4;
+ switch (opts.vulkanVersion)
{
case VK_MAKE_VERSION(1, 0, 0): return SPV_ENV_VULKAN_1_0;
- case VK_MAKE_VERSION(1, 1, 0): return SPV_ENV_VULKAN_1_1;
+ case VK_MAKE_VERSION(1, 1, 0): return allow_1_4 ? SPV_ENV_VULKAN_1_1_SPIRV_1_4 : SPV_ENV_VULKAN_1_1;
default:
break;
}
case SPIRV_VERSION_1_1: result = SPV_ENV_UNIVERSAL_1_1; break; //!< SPIR-V 1.1
case SPIRV_VERSION_1_2: result = SPV_ENV_UNIVERSAL_1_2; break; //!< SPIR-V 1.2
case SPIRV_VERSION_1_3: result = SPV_ENV_UNIVERSAL_1_3; break; //!< SPIR-V 1.3
+ case SPIRV_VERSION_1_4: result = SPV_ENV_UNIVERSAL_1_4; break; //!< SPIR-V 1.4
default: TCU_THROW(InternalError, "Unknown SPIR-V version");
}
bool validateSpirV (size_t binarySizeInWords, const deUint32* binary, std::ostream* infoLog, const SpirvValidatorOptions &val_options)
{
- const spv_context context = spvContextCreate(mapVulkanVersionToSpirvToolsEnv(val_options.vulkanVersion));
+ const spv_context context = spvContextCreate(getSpirvToolsEnvForValidatorOptions(val_options));
spv_diagnostic diagnostic = DE_NULL;
spv_validator_options options = DE_NULL;
spv_text disasmText = DE_NULL;
struct SpirVAsmBuildOptions
{
- deUint32 vulkanVersion;
+ deUint32 vulkanVersion;
SpirvVersion targetVersion;
+ bool supports_VK_KHR_spirv_1_4;
SpirVAsmBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_)
- : vulkanVersion (vulkanVersion_)
- , targetVersion (targetVersion_)
+ : vulkanVersion (vulkanVersion_)
+ , targetVersion (targetVersion_)
+ , supports_VK_KHR_spirv_1_4 (false)
{}
SpirVAsmBuildOptions (void)
- : vulkanVersion (VK_MAKE_VERSION(1, 0, 0))
- , targetVersion (SPIRV_VERSION_1_0)
+ : vulkanVersion (VK_MAKE_VERSION(1, 0, 0))
+ , targetVersion (SPIRV_VERSION_1_0)
+ , supports_VK_KHR_spirv_1_4 (false)
{}
SpirvValidatorOptions getSpirvValidatorOptions() const
{
- return SpirvValidatorOptions(vulkanVersion);
+ SpirvValidatorOptions result(vulkanVersion);
+ result.supports_VK_KHR_spirv_1_4 = supports_VK_KHR_spirv_1_4;
+ return result;
}
};
};
SpirvValidatorOptions(deUint32 the_vulkan_version = VK_MAKE_VERSION(1, 0, 0), BlockLayoutRules the_layout = kDefaultBlockLayout)
- : vulkanVersion(the_vulkan_version), blockLayout(the_layout) {}
+ : vulkanVersion(the_vulkan_version), blockLayout(the_layout), supports_VK_KHR_spirv_1_4(false) {}
// The target Vulkan version. This determines the SPIR-V environment rules to
// be checked. The bit pattern is as produced by VK_MAKE_VERSION.
// The block layout rules to enforce.
BlockLayoutRules blockLayout;
+
+ // Does the device support VK_KHR_spirv_1_4?
+ // (Camelcase would just be wrong here.)
+ bool supports_VK_KHR_spirv_1_4;
};
} // namespace vk
virtual tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
private:
+ bool spirvVersionSupported(vk::SpirvVersion);
vk::BinaryCollection m_progCollection;
vk::BinaryRegistryReader m_prebuiltBinRegistry;
for (vk::GlslSourceCollection::Iterator progIter = sourceProgs.glslSources.begin(); progIter != sourceProgs.glslSources.end(); ++progIter)
{
- if (progIter.getProgram().buildOptions.targetVersion > vk::getMaxSpirvVersionForGlsl(m_context.getUsedApiVersion()))
+ if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::GlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
for (vk::HlslSourceCollection::Iterator progIter = sourceProgs.hlslSources.begin(); progIter != sourceProgs.hlslSources.end(); ++progIter)
{
- if (progIter.getProgram().buildOptions.targetVersion > vk::getMaxSpirvVersionForGlsl(m_context.getUsedApiVersion()))
+ if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::HlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
for (vk::SpirVAsmCollection::Iterator asmIterator = sourceProgs.spirvAsmSources.begin(); asmIterator != sourceProgs.spirvAsmSources.end(); ++asmIterator)
{
- if (asmIterator.getProgram().buildOptions.targetVersion > vk::getMaxSpirvVersionForAsm(m_context.getUsedApiVersion()))
+ if (!spirvVersionSupported(asmIterator.getProgram().buildOptions.targetVersion))
TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
buildProgram<vk::SpirVProgramInfo, vk::SpirVAsmCollection::Iterator>(casePath, asmIterator, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
return tcu::TestNode::CONTINUE;
}
+bool TestCaseExecutor::spirvVersionSupported (vk::SpirvVersion spirvVersion)
+{
+ if (spirvVersion <= vk::getMaxSpirvVersionForVulkan(m_context.getUsedApiVersion()))
+ return true;
+
+ if (spirvVersion <= vk::SPIRV_VERSION_1_4)
+ return vk::isDeviceExtensionSupported(m_context.getUsedApiVersion(), m_context.getDeviceExtensions(), "VK_KHR_spirv_1_4");
+
+ return false;
+}
+
// GLSL shader tests
void createGlslTests (tcu::TestCaseGroup* glslTests)