Ensure the vertex shader matches the vertex input definition
authorPiers Daniell <pdaniell@nvidia.com>
Wed, 15 Sep 2021 13:41:49 +0000 (15:41 +0200)
committerRicardo Garcia <rgarcia@igalia.com>
Wed, 15 Sep 2021 13:41:49 +0000 (15:41 +0200)
When doing the "reversed" variants of the extended dynamic
state tests, the vertex input attribute and binding information
was reversed, but the vertex shaders were not. The meant that
in some tests the vertex shader may try to fetch from unbound
or undefined vertex attributes or vertex attribute data.

This commit fixes the issue by swapping vertex shaders for the
affected variants.

Affects:
dEQP-VK.pipeline.extended_dynamic_state.*

Components: Vulkan
VK-GL-CTS issue: 3111

Change-Id: I7d9abbe7dab0b44127f6b194ee5da79755f7658c
Co-authored-by: Ricardo Garcia <rgarcia@igalia.com>
external/vulkancts/modules/vulkan/pipeline/vktPipelineExtendedDynamicStateTests.cpp

index d79463b..bdf8e07 100644 (file)
@@ -1432,9 +1432,11 @@ void ExtendedDynamicStateTest::initPrograms (vk::SourceCollections& programColle
                        << "}\n";
        }
 
+       // In reversed test configurations, the pipeline with dynamic state needs to have the inactive shader.
+       const auto kReversed = m_testConfig.isReversed();
+       programCollection.glslSources.add("dynamicVert") << glu::VertexSource(kReversed ? inactiveVertSource : activeVertSource);
+       programCollection.glslSources.add("staticVert") << glu::VertexSource(kReversed ? activeVertSource : inactiveVertSource);
 
-       programCollection.glslSources.add("vert") << glu::VertexSource(activeVertSource);
-       programCollection.glslSources.add("vert2") << glu::VertexSource(inactiveVertSource);
        programCollection.glslSources.add("frag") << glu::FragmentSource(fragSource.str());
        if (m_testConfig.needsGeometryShader())
                programCollection.glslSources.add("geom") << glu::GeometrySource(geomSource.str());
@@ -1992,9 +1994,9 @@ tcu::TestStatus ExtendedDynamicStateInstance::iterate (void)
        }
 
        // Shader modules.
-       const auto                                              vertModule      = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("vert"), 0u);
-       const auto                                              vertModule2     = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("vert2"), 0u);
-       const auto                                              fragModule      = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("frag"), 0u);
+       const auto                                              dynamicVertModule       = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("dynamicVert"), 0u);
+       const auto                                              staticVertModule        = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("staticVert"), 0u);
+       const auto                                              fragModule                      = vk::createShaderModule(vkd, device, m_context.getBinaryCollection().get("frag"), 0u);
        vk::Move<vk::VkShaderModule>    geomModule;
        vk::Move<vk::VkShaderModule>    tescModule;
        vk::Move<vk::VkShaderModule>    teseModule;
@@ -2047,10 +2049,10 @@ tcu::TestStatus ExtendedDynamicStateInstance::iterate (void)
        shaderStaticStages = shaderStages;
        shaderStageCreateInfo.stage = vk::VK_SHADER_STAGE_VERTEX_BIT;
 
-       shaderStageCreateInfo.module = vertModule.get();
+       shaderStageCreateInfo.module = dynamicVertModule.get();
        shaderStages.push_back(shaderStageCreateInfo);
 
-       shaderStageCreateInfo.module = vertModule2.get();
+       shaderStageCreateInfo.module = staticVertModule.get();
        shaderStaticStages.push_back(shaderStageCreateInfo);
 
        // Input state.