Select SPIR-V for the robustness' compute shaders
authorTony Zlatinski <tzlatinski@nvidia.com>
Tue, 1 Dec 2020 23:54:21 +0000 (17:54 -0600)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 7 Dec 2020 16:00:40 +0000 (11:00 -0500)
Use SPIR-V v1.3 instead of SPIR-V v1.4 ShaderBuildOptions
for the compute shaders of the robustness tests using 64-bit formats.
Apparently, SPIR-V v1.4 is not required for those shaders.
Otherwise, the SPIR-V validation fails on Vulkan v1.1 devices
such as Android.
For tests that do not require/test 64-bit formats,
fall back to using SPIR-V v1.0.

Components: Vulkan

VK-GL-CTS issue: 2679

Affects:
dEQP-VK.robustness.*.comp

Change-Id: I6054682e7dbc4460595a8264338a04ee36f9e3d1
(cherry picked from commit 9f0afc24c74fa608e1993f7ec342053949f152d8)

external/vulkancts/modules/vulkan/robustness/vktRobustnessExtsTests.cpp

index be1e482..d4b6dc2 100644 (file)
@@ -447,7 +447,7 @@ void RobustnessExtsTestCase::checkSupport(Context& context) const
                !features2.features.shaderStorageImageMultisample)
                TCU_THROW(NotSupportedError, "shaderStorageImageMultisample not supported");
 
-       if (m_data.useTemplate && !context.contextSupports(vk::ApiVersion(1, 1, 0)))
+       if ((m_data.useTemplate || formatIsR64(m_data.format)) && !context.contextSupports(vk::ApiVersion(1, 1, 0)))
                TCU_THROW(NotSupportedError, "Vulkan 1.1 not supported");
 
        if ((m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER || m_data.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) &&
@@ -1338,10 +1338,13 @@ void RobustnessExtsTestCase::initPrograms (SourceCollections& programCollection)
                }
        }
        checks << "  }\n";
-       std::string SupportR64 = (formatIsR64(m_data.format) ?
+
+       const bool is64BitFormat = formatIsR64(m_data.format);
+       std::string SupportR64 = (is64BitFormat ?
                                                        std::string("#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require\n"
                                                        "#extension GL_EXT_shader_image_int64 : require\n") :
                                                        std::string());
+
        switch (m_data.stage)
        {
        default: DE_ASSERT(0); // Fallthrough
@@ -1368,7 +1371,7 @@ void RobustnessExtsTestCase::initPrograms (SourceCollections& programCollection)
                                "}\n";
 
                        programCollection.glslSources.add("test") << glu::ComputeSource(css.str())
-                               << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_4, vk::ShaderBuildOptions::FLAG_ALLOW_SCALAR_OFFSETS);
+                               << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, is64BitFormat ? vk::SPIRV_VERSION_1_3 : vk::SPIRV_VERSION_1_0, vk::ShaderBuildOptions::FLAG_ALLOW_SCALAR_OFFSETS);
                        break;
                }
        case STAGE_RAYGEN:
@@ -1463,8 +1466,8 @@ void RobustnessExtsTestCase::initPrograms (SourceCollections& programCollection)
                }
        }
 
-
-       if ((m_data.samples > VK_SAMPLE_COUNT_1_BIT) && formatIsR64(m_data.format))
+       // The 64-bit conditions below are redundant. Can we support the below shader for other than 64-bit formats?
+       if ((m_data.samples > VK_SAMPLE_COUNT_1_BIT) && is64BitFormat)
        {
                const std::string       ivecCords = (m_data.viewType == VK_IMAGE_VIEW_TYPE_2D ? "ivec2(gx, gy)" : "ivec3(gx, gy, gz)");
                std::stringstream       fillShader;
@@ -1475,11 +1478,11 @@ void RobustnessExtsTestCase::initPrograms (SourceCollections& programCollection)
                        << "\n"
                        "layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n"
                        "layout (" + getShaderImageFormatQualifier(mapVkFormat(m_data.format)) + ", binding=0) volatile uniform "
-                       << string(formatIsSignedInt(m_data.format) ? "i" : "u") + string(formatIsR64(m_data.format) ? "64" : "") << "image" << imageDim << +" u_resultImage;\n"
+                       << string(formatIsSignedInt(m_data.format) ? "i" : "u") + string(is64BitFormat ? "64" : "") << "image" << imageDim << +" u_resultImage;\n"
                        "\n"
                        "layout(std430, binding = 1) buffer inputBuffer\n"
                        "{\n"
-                       "  int" << (formatIsR64(m_data.format) ? "64_t" : "") << " data[];\n"
+                       "  int" << (is64BitFormat ? "64_t" : "") << " data[];\n"
                        "} inBuffer;\n"
                        "\n"
                        "void main(void)\n"
@@ -1497,7 +1500,7 @@ void RobustnessExtsTestCase::initPrograms (SourceCollections& programCollection)
                        fillShader << "}\n";
 
                programCollection.glslSources.add("fillShader") << glu::ComputeSource(fillShader.str())
-                       << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, vk::SPIRV_VERSION_1_3, vk::ShaderBuildOptions::FLAG_ALLOW_SCALAR_OFFSETS);
+                       << vk::ShaderBuildOptions(programCollection.usedVulkanVersion, is64BitFormat ? vk::SPIRV_VERSION_1_3 : vk::SPIRV_VERSION_1_0, vk::ShaderBuildOptions::FLAG_ALLOW_SCALAR_OFFSETS);
        }
 
 }