Fix validation errors with unnormalized coordinates samplers
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Fri, 8 Oct 2021 13:26:21 +0000 (15:26 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 15 Oct 2021 17:56:11 +0000 (17:56 +0000)
Components: Vulkan
VK-GL-CTS issue: 3190

Affects:

   dEQP-VK.pipeline.sampler.*unnormalized*

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Change-Id: I1dde344fe39289b945a434eab7276dc58deab881

external/vulkancts/modules/vulkan/pipeline/vktPipelineSamplerTests.cpp

index e01ac29..a1a50e0 100644 (file)
@@ -399,9 +399,9 @@ void SamplerTest::initPrograms (SourceCollections& sourceCollections) const
                                << "{\n"
                                << "    fragColor = ";
 
-       if (m_samplerLod > 0.0f)
+       if (m_samplerLod > 0.0f || !m_imageViewType.isNormalized())
        {
-               DE_ASSERT(m_imageViewType.isNormalized());
+               DE_ASSERT(m_imageViewType.isNormalized() || (m_samplerLod == 0.0f && !m_imageViewType.isNormalized()));
                fragmentSrc << "textureLod(texSampler, vtxTexCoords." << texCoordSwizzle << ", " << std::fixed <<  m_samplerLod << ")";
        }
        else
@@ -1231,10 +1231,18 @@ void ExactSamplingCase::initPrograms (vk::SourceCollections& programCollection)
                << "\n"
                << "layout(location = 0) out " << colorType << " outColor;\n"
                << "\n"
-               << "void main() {\n"
-               << "    outColor = texture(texSampler, fragTexCoord);\n"
-               << "}\n"
-               ;
+               << "void main() {\n";
+
+       if (m_params.unnormalizedCoordinates)
+       {
+               fragmentShader << "    outColor = textureLod(texSampler, fragTexCoord, 0.0f);";
+       }
+       else
+       {
+               fragmentShader << "    outColor = texture(texSampler, fragTexCoord);\n";
+       }
+
+       fragmentShader << "}\n";
 
        programCollection.glslSources.add("frag") << glu::FragmentSource{fragmentShader.str()};
 }