From: Jari Komppa Date: Sat, 13 Nov 2021 18:45:18 +0000 (+0200) Subject: Modify dual source blend tests to use discard X-Git-Tag: upstream/1.3.5~488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed8d8fda949fc2ba9ab91ac15155bf7f5792f98e;p=platform%2Fupstream%2FVK-GL-CTS.git Modify dual source blend tests to use discard This change adds discard to the shaders when testing dual source blend shading. The reference renderer does not support discard, so the reference image is updated after rendering to cover for this. Affects: dEQP-VK.pipeline.blend.dual_source.* Components: Vulkan VK-GL-CTS issue: 3230 Change-Id: I06b9b7fb904bc2efbd5d8758a1c5ed5b5f76b4e5 --- diff --git a/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp b/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp index 44073cd..66ccf2b 100644 --- a/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp +++ b/external/vulkancts/modules/vulkan/pipeline/vktPipelineBlendTests.cpp @@ -577,6 +577,8 @@ void DualSourceBlendTest::initPrograms (SourceCollections& sourceCollections) co "{\n" " fragColor0 = vtxColor0;\n" " fragColor1 = vtxColor1;\n" + " if (int(gl_FragCoord.x) == 2 || int(gl_FragCoord.y) == 3)\n" + " discard;\n" "}\n"; sourceCollections.glslSources.add("color_frag") << glu::FragmentSource(fragmentSource.str()); @@ -1476,9 +1478,17 @@ tcu::TestStatus DualSourceBlendTestInstance::verifyImage (void) ReferenceRenderer refRenderer64 (m_renderSize.x(), m_renderSize.y(), 1, tcuColorFormat64, tcuDepthFormat, &program); ReferenceRenderer refRenderer8 (m_renderSize.x(), m_renderSize.y(), 1, tcuColorFormat8, tcuDepthFormat, &program); bool compareOk = false; + tcu::PixelBufferAccess access = refRenderer.getAccess(); + tcu::PixelBufferAccess access8 = refRenderer8.getAccess(); + tcu::PixelBufferAccess access64 = refRenderer64.getAccess(); // Render reference image { + // read clear color + tcu::Vec4 discardColor = access.getPixel(0, 0); + tcu::Vec4 discardColor8 = access8.getPixel(0, 0); + tcu::Vec4 discardColor64 = access64.getPixel(0, 0); + for (int quadNdx = 0; quadNdx < BlendTest::QUAD_COUNT; quadNdx++) { const VkPipelineColorBlendAttachmentState& blendState = m_blendStates[quadNdx]; @@ -1514,6 +1524,37 @@ tcu::TestStatus DualSourceBlendTestInstance::verifyImage (void) m_vertices.begin() + (quadNdx + 1) * 6)); } } + + // re-request the pixel access; copies various formats to accessable ones + // (if we don't do this, the above draws don't matter) + access = refRenderer.getAccess(); + access8 = refRenderer8.getAccess(); + access64 = refRenderer64.getAccess(); + + // Paint back the discarded pixels with the clear color. The reference + // renderer doesn't actually run the shader, and doesn't know about discard, + // so this is a way to get to the images we wanted. + for (int i = 0; i < access.getWidth(); i++) + { + access.setPixel(discardColor, i, 3); + if (isLegalExpandableFormat(tcuColorFormat.type)) + { + access64.setPixel(discardColor64, i, 3); + if (isSmallerThan8BitFormat(tcuColorFormat.type)) + access8.setPixel(discardColor8, i, 3); + } + } + + for (int i = 0; i < access.getHeight(); i++) + { + access.setPixel(discardColor, 2, i); + if (isLegalExpandableFormat(tcuColorFormat.type)) + { + access64.setPixel(discardColor64, 2, i); + if (isSmallerThan8BitFormat(tcuColorFormat.type)) + access8.setPixel(discardColor8, 2, i); + } + } } // Compare result with reference image @@ -1539,7 +1580,7 @@ tcu::TestStatus DualSourceBlendTestInstance::verifyImage (void) compareOk = tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "FloatImageCompare", "Image comparison", - refRenderer.getAccess(), + access, result->getAccess(), threshold, tcu::COMPARE_LOG_RESULT); @@ -1549,7 +1590,7 @@ tcu::TestStatus DualSourceBlendTestInstance::verifyImage (void) if (!compareOk && isSmallerThan8BitFormat(tcuColorFormat.type)) { // Convert to target format - tcu::copy(refLevel.getAccess(), refRenderer8.getAccess()); + tcu::copy(refLevel.getAccess(), access8); compareOk = tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "FloatImageCompare", @@ -1563,7 +1604,7 @@ tcu::TestStatus DualSourceBlendTestInstance::verifyImage (void) if (!compareOk) { // Convert to target format - tcu::copy(refLevel.getAccess(), refRenderer64.getAccess()); + tcu::copy(refLevel.getAccess(), access64); compareOk = tcu::floatThresholdCompare(m_context.getTestContext().getLog(), "FloatImageCompare",