Lines Matching refs:tcu

66 using tcu::TestLog;
167 static inline tcu::BVec4 getDerivateMask (glu::DataType type)
171 case glu::TYPE_FLOAT: return tcu::BVec4(true, false, false, false);
172 case glu::TYPE_FLOAT_VEC2: return tcu::BVec4(true, true, false, false);
173 case glu::TYPE_FLOAT_VEC3: return tcu::BVec4(true, true, true, false);
174 case glu::TYPE_FLOAT_VEC4: return tcu::BVec4(true, true, true, true);
177 return tcu::BVec4(true);
181 static inline bool isSkippedPixel (const tcu::ConstPixelBufferAccess& surface, int x, int y)
183 const tcu::Vec4 skipValue(0.7843f, 0.2039f, 0.4706f, 0.0f);
184 const tcu::Vec4 value = surface.getPixel(x, y);
185 return tcu::allEqual(tcu::lessThanEqual(tcu::abs(value - skipValue), tcu::Vec4(0.01f)), tcu::BVec4(true));
188 static inline tcu::Vec4 readDerivate (const tcu::ConstPixelBufferAccess& surface, const tcu::Vec4& derivScale, const tcu::Vec4& derivBias, int x, int y)
193 static inline tcu::UVec4 getCompExpBits (const tcu::Vec4& v)
195 return tcu::UVec4(tcu::Float32(v[0]).exponentBits(),
196 tcu::Float32(v[1]).exponentBits(),
197 tcu::Float32(v[2]).exponentBits(),
198 tcu::Float32(v[3]).exponentBits());
205 const int exp = tcu::Float32(value).exponent();
207 return tcu::Float32::construct(+1, exp, (1u<<23) | mask).asFloat() - tcu::Float32::construct(+1, exp, 1u<<23).asFloat();
243 return tcu::Float32::construct(+1, exp, (1<<23) | (1 << ulpBitNdx)).asFloat() - tcu::Float32::construct(+1, exp, (1<<23)).asFloat();
248 return tcu::Float32::construct(+1, exp, (1<<23)).asFloat();
254 const int exp = tcu::Float32(value).exponent();
266 const tcu::Float32 inputFloat = tcu::Float32(value);
272 if (value > 0.0f && tcu::Float32(value).exponent() < minExponent)
280 return tcu::Float32::construct(+1, inputFloat.exponent(), inputFloat.mantissa() & ~truncMask).asFloat();
288 return tcu::Float32::construct(-1, inputFloat.exponent(), inputFloat.mantissa() & ~truncMask).asFloat() - getSingleULPForExponent(inputFloat.exponent(), numAccurateBits);
314 static inline tcu::Vec4 getDerivateThreshold (const glu::Precision precision, const tcu::Vec4& valueMin, const tcu::Vec4& valueMax, const tcu::Vec4& expectedDerivate)
317 const tcu::UVec4 derivExp = getCompExpBits(expectedDerivate);
318 const tcu::UVec4 maxValueExp = max(getCompExpBits(valueMin), getCompExpBits(valueMax));
319 const tcu::UVec4 numBitsLost = maxValueExp - min(maxValueExp, derivExp);
320 const tcu::IVec4 numAccurateBits = max(baseBits - numBitsLost.asInt() - (int)INTERPOLATION_LOST_BITS, tcu::IVec4(0));
322 return tcu::Vec4(computeFloatingPointError(expectedDerivate[0], numAccurateBits[0]),
330 const tcu::Vec4& v;
333 LogVecComps (const tcu::Vec4& v_, int numComps_)
355 static bool verifyConstantDerivate (tcu::TestLog& log,
356 const tcu::ConstPixelBufferAccess& result,
357 const tcu::PixelBufferAccess& errorMask,
359 const tcu::Vec4& reference,
360 const tcu::Vec4& threshold,
361 const tcu::Vec4& scale,
362 const tcu::Vec4& bias,
366 const tcu::BVec4 mask = tcu::logicalNot(getDerivateMask(dataType));
379 const tcu::Vec4 resDerivate = readDerivate(result, scale, bias, x, y);
380 const bool isOk = tcu::allEqual(tcu::logicalOr(tcu::lessThanEqual(tcu::abs(reference - resDerivate), threshold), mask), tcu::BVec4(true));
386 << ", diff = " << LogVecComps(tcu::abs(reference - resDerivate), numComps)
390 errorMask.setPixel(tcu::RGBA::red().toVec(), x, y);
406 tcu::Matrix<float, 4, 3> matrix;
413 tcu::Vec4 evaluateAt (float screenX, float screenY) const;
416 tcu::Vec4 Linear2DFunctionEvaluator::evaluateAt (float screenX, float screenY) const
418 const tcu::Vec3 position(screenX, screenY, 1.0f);
422 static bool reverifyConstantDerivateWithFlushRelaxations (tcu::TestLog& log,
423 const tcu::ConstPixelBufferAccess& result,
424 const tcu::PixelBufferAccess& errorMask,
427 const tcu::Vec4& derivScale,
428 const tcu::Vec4& derivBias,
429 const tcu::Vec4& surfaceThreshold,
437 const tcu::IVec4 red (255, 0, 0, 255);
438 const tcu::IVec4 green (0, 255, 0, 255);
448 tcu::clear(errorMask, green);
461 const tcu::Vec4 resultDerivative = readDerivate(result, derivScale, derivBias, x, y);
469 const tcu::Vec4 functionValueForward = (isDfdxFunc(derivateFunc))
472 const tcu::Vec4 functionValueBackward = (isDfdyFunc(derivateFunc))
482 const tcu::Interval forwardComponent (convertFloatFlushToZeroRtn(addErrorUlp((float)functionValueForward[c], -0.5f, numVaryingSampleBits), minExponent, numBits),
484 const tcu::Interval backwardComponent (convertFloatFlushToZeroRtn(addErrorUlp((float)functionValueBackward[c], -0.5f, numVaryingSampleBits), minExponent, numBits),
486 const int maxValueExp = de::max(de::max(tcu::Float32(forwardComponent.lo()).exponent(), tcu::Float32(forwardComponent.hi()).exponent()),
487 de::max(tcu::Float32(backwardComponent.lo()).exponent(), tcu::Float32(backwardComponent.hi()).exponent()));
492 const tcu::Interval numerator (forwardComponent - backwardComponent);
493 const int numeratorLoExp = tcu::Float32(numerator.lo()).exponent();
494 const int numeratorHiExp = tcu::Float32(numerator.hi()).exponent();
500 const tcu::Interval numeratorRange (convertFloatFlushToZeroRtn((float)numerator.lo(), minExponent, numeratorLoBits),
503 const tcu::Interval divisionRange = numeratorRange / 3.0f; // legal sample area is anywhere within this and neighboring pixels (i.e. size = 3)
504 const tcu::Interval divisionResultRange (convertFloatFlushToZeroRtn(addErrorUlp((float)divisionRange.lo(), -divisionErrorUlps, numBits), minExponent, numBits),
506 const tcu::Interval finalResultRange (divisionResultRange.lo() - surfaceThreshold[c], divisionResultRange.hi() + surfaceThreshold[c]);
515 log << tcu::TestLog::Message
526 << tcu::TestLog::EndMessage;
576 tcu::Vec4 coordMin;
577 tcu::Vec4 coordMax;
578 tcu::Vec4 derivScale;
579 tcu::Vec4 derivBias;
584 tcu::Vec4 texValueMin;
585 tcu::Vec4 texValueMax;
594 virtual void setup (ShaderRenderCaseInstance& instance, const tcu::Vec4&) const;
619 virtual tcu::TestStatus iterate (void);
624 virtual bool verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask) = 0;
625 tcu::Vec4 getSurfaceThreshold (void) const;
653 m_renderSize = tcu::UVec2(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
663 tcu::Vec4 TriangleDerivateCaseInstance::getSurfaceThreshold (void) const
667 case SURFACETYPE_UNORM_FBO: return tcu::IVec4(1).asFloat() / 255.0f;
668 case SURFACETYPE_FLOAT_FBO: return tcu::Vec4(0.0f);
671 return tcu::Vec4(0.0f);
698 tcu::TestStatus TriangleDerivateCaseInstance::iterate (void)
700 tcu::TestLog& log = m_context.getTestContext().getLog();
704 tcu::TextureLevel resultImage;
711 const tcu::TextureLevel& renderedImage = getResultImage();
715 const tcu::TextureFormat dataFormat (tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT);
718 tcu::copy(resultImage.getAccess(), tcu::ConstPixelBufferAccess(dataFormat, renderedImage.getSize(), renderedImage.getAccess().getDataPtr()));
728 tcu::Surface errorMask(resultImage.getWidth(), resultImage.getHeight());
729 tcu::clear(errorMask.getAccess(), tcu::RGBA::green().toVec());
742 return tcu::TestStatus::pass("Pass");
744 return tcu::TestStatus::fail("Image comparison failed");
748 void DerivateUniformSetup::setup (ShaderRenderCaseInstance& instance, const tcu::Vec4&) const
767 TriangleDerivateCase (tcu::TestContext& testCtx,
779 TriangleDerivateCase::TriangleDerivateCase (tcu::TestContext& testCtx,
804 throw tcu::NotSupportedError(errorPrefix + " require Vulkan 1.1");
809 throw tcu::NotSupportedError(errorPrefix + " require subgroupSize >= 4");
812 throw tcu::NotSupportedError(errorPrefix + " tests require VK_SUBGROUP_FEATURE_BALLOT_BIT");
815 throw tcu::NotSupportedError(errorPrefix + " tests require subgroup supported stage including VK_SHADER_STAGE_FRAGMENT_BIT");
818 throw tcu::NotSupportedError(errorPrefix + " tests require VK_SUBGROUP_FEATURE_QUAD_BIT");
848 return tcu::StringTemplate(vertexTmpl).specialize(vertexParams);
862 virtual bool verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask);
877 bool ConstantDerivateCaseInstance::verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask)
879 const tcu::Vec4 reference (0.0f); // Derivate of constant argument should always be 0
880 const tcu::Vec4 threshold = getSurfaceThreshold() / abs(m_values.derivScale);
891 ConstantDerivateCase (tcu::TestContext& testCtx,
901 ConstantDerivateCase::ConstantDerivateCase (tcu::TestContext& testCtx,
911 m_values.derivScale = tcu::Vec4(1e3f, 1e3f, 1e3f, 1e3f);
912 m_values.derivBias = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f);
951 std::string fragmentSrc = tcu::StringTemplate(fragmentTmpl).specialize(fragmentParams);
964 virtual void setup (ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords) const;
980 void LinearDerivateUniformSetup::setup (ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords) const
1007 virtual bool verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask);
1022 bool LinearDerivateCaseInstance::verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask)
1024 const tcu::Vec4 xScale = tcu::Vec4(1.0f, 0.0f, 0.5f, -0.5f);
1025 const tcu::Vec4 yScale = tcu::Vec4(0.0f, 1.0f, 0.5f, -0.5f);
1026 const tcu::Vec4 surfaceThreshold = getSurfaceThreshold() / abs(m_values.derivScale);
1032 const tcu::Vec4 scale = isX ? xScale : yScale;
1033 tcu::Vec4 reference = ((m_values.coordMax - m_values.coordMin) / div);
1034 const tcu::Vec4 opThreshold = getDerivateThreshold(m_definitions.precision, m_values.coordMin, m_values.coordMax, reference);
1035 const tcu::Vec4 threshold = max(surfaceThreshold, opThreshold);
1042 << tcu::TestLog::Message
1045 << tcu::TestLog::EndMessage;
1054 << tcu::TestLog::Message
1056 << tcu::TestLog::EndMessage;
1065 << tcu::TestLog::Message
1068 << tcu::TestLog::EndMessage;
1071 const tcu::UVec2 viewportSize (VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1074 const tcu::Vec4 valueRamp = (m_values.coordMax - m_values.coordMin);
1077 function.matrix.setRow(0, tcu::Vec3(valueRamp.x() / w, 0.0f, m_values.coordMin.x()));
1078 function.matrix.setRow(1, tcu::Vec3(0.0f, valueRamp.y() / h, m_values.coordMin.y()));
1079 function.matrix.setRow(2, tcu::Vec3(valueRamp.z() / w, valueRamp.z() / h, m_values.coordMin.z() + m_values.coordMin.z()) / 2.0f);
1080 function.matrix.setRow(3, tcu::Vec3(-valueRamp.w() / w, -valueRamp.w() / h, m_values.coordMax.w() + m_values.coordMax.w()) / 2.0f);
1094 const tcu::Vec4 dx = ((m_values.coordMax - m_values.coordMin) / w) * xScale;
1095 const tcu::Vec4 dy = ((m_values.coordMax - m_values.coordMin) / h) * yScale;
1096 const tcu::Vec4 reference = tcu::abs(dx) + tcu::abs(dy);
1097 const tcu::Vec4 dxThreshold = getDerivateThreshold(m_definitions.precision, m_values.coordMin*xScale, m_values.coordMax*xScale, dx);
1098 const tcu::Vec4 dyThreshold = getDerivateThreshold(m_definitions.precision, m_values.coordMin*yScale, m_values.coordMax*yScale, dy);
1099 const tcu::Vec4 threshold = max(surfaceThreshold, max(dxThreshold, dyThreshold));
1111 LinearDerivateCase (tcu::TestContext& testCtx,
1130 LinearDerivateCase::LinearDerivateCase (tcu::TestContext& testCtx,
1152 const tcu::UVec2 viewportSize (VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1159 m_values.coordMin = tcu::Vec4(-97.f, 0.2f, 71.f, 74.f);
1160 m_values.coordMax = tcu::Vec4(-13.2f, -77.f, 44.f, 76.f);
1164 m_values.coordMin = tcu::Vec4(-37.0f, 47.f, -7.f, 0.0f);
1165 m_values.coordMax = tcu::Vec4(-1.0f, 12.f, 7.f, 19.f);
1169 m_values.coordMin = tcu::Vec4(0.0f, -1.0f, 0.0f, 1.0f);
1170 m_values.coordMax = tcu::Vec4(1.0f, 1.0f, -1.0f, -1.0f);
1180 m_values.derivScale = tcu::Vec4(1.0f);
1181 m_values.derivBias = tcu::Vec4(0.0f);
1186 const tcu::Vec4 dx = (m_values.coordMax - m_values.coordMin) / tcu::Vec4(w, w, w*0.5f, -w*0.5f);
1187 const tcu::Vec4 dy = (m_values.coordMax - m_values.coordMin) / tcu::Vec4(h, h, h*0.5f, -h*0.5f);
1194 m_values.derivScale = 0.5f / (tcu::abs(dx) + tcu::abs(dy));
1198 m_values.derivBias = tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f);
1241 std::string fragmentSrc = tcu::StringTemplate(m_fragmentTmpl).specialize(fragmentParams);
1258 virtual bool verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask);
1272 de::MovePtr<tcu::Texture2D> texture;
1276 const tcu::UVec2 viewportSize (VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1277 const tcu::TextureFormat format = glu::mapGLInternalFormat(m_definitions.precision == glu::PRECISION_HIGHP ? GL_RGBA32F : GL_RGBA16F);
1279 texture = de::MovePtr<tcu::Texture2D>(new tcu::Texture2D(format, viewportSize.x(), viewportSize.y()));
1285 const tcu::PixelBufferAccess level0 = texture->getLevel(0);
1292 const tcu::Vec4 s = tcu::Vec4(xf, yf, (xf+yf)/2.0f, 1.0f - (xf+yf)/2.0f);
1300 tcu::Sampler(tcu::Sampler::CLAMP_TO_EDGE,
1301 tcu::Sampler::CLAMP_TO_EDGE,
1302 tcu::Sampler::CLAMP_TO_EDGE,
1303 tcu::Sampler::NEAREST,
1304 tcu::Sampler::NEAREST,
1307 tcu::Sampler::COMPAREMODE_NONE,
1309 tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),
1318 bool TextureDerivateCaseInstance::verify (const tcu::ConstPixelBufferAccess& result, const tcu::PixelBufferAccess& errorMask)
1322 throw tcu::NotSupportedError("Too small viewport");
1324 tcu::ConstPixelBufferAccess compareArea = tcu::getSubregion(result, 1, 1, result.getWidth()-2, result.getHeight()-2);
1325 tcu::PixelBufferAccess maskArea = tcu::getSubregion(errorMask, 1, 1, errorMask.getWidth()-2, errorMask.getHeight()-2);
1326 const tcu::Vec4 xScale = tcu::Vec4(1.0f, 0.0f, 0.5f, -0.5f);
1327 const tcu::Vec4 yScale = tcu::Vec4(0.0f, 1.0f, 0.5f, -0.5f);
1331 const tcu::Vec4 surfaceThreshold = getSurfaceThreshold() / abs(m_values.derivScale);
1337 const tcu::Vec4 scale = isX ? xScale : yScale;
1338 tcu::Vec4 reference = ((m_textureValues.texValueMax - m_textureValues.texValueMin) / div);
1339 const tcu::Vec4 opThreshold = getDerivateThreshold(m_definitions.precision, m_textureValues.texValueMin, m_textureValues.texValueMax, reference);
1340 const tcu::Vec4 threshold = max(surfaceThreshold, opThreshold);
1347 << tcu::TestLog::Message
1350 << tcu::TestLog::EndMessage;
1359 << tcu::TestLog::Message
1361 << tcu::TestLog::EndMessage;
1370 << tcu::TestLog::Message
1373 << tcu::TestLog::EndMessage;
1376 const tcu::Vec4 valueRamp = (m_textureValues.texValueMax - m_textureValues.texValueMin);
1379 function.matrix.setRow(0, tcu::Vec3(valueRamp.x() / w, 0.0f, m_textureValues.texValueMin.x()));
1380 function.matrix.setRow(1, tcu::Vec3(0.0f, valueRamp.y() / h, m_textureValues.texValueMin.y()));
1381 function.matrix.setRow(2, tcu::Vec3(valueRamp.z() / w, valueRamp.z() / h, m_textureValues.texValueMin.z() + m_textureValues.texValueMin.z()) / 2.0f);
1382 function.matrix.setRow(3, tcu::Vec3(-valueRamp.w() / w, -valueRamp.w() / h, m_textureValues.texValueMax.w() + m_textureValues.texValueMax.w()) / 2.0f);
1393 const tcu::Vec4 dx = ((m_textureValues.texValueMax - m_textureValues.texValueMin) / w) * xScale;
1394 const tcu::Vec4 dy = ((m_textureValues.texValueMax - m_textureValues.texValueMin) / h) * yScale;
1395 const tcu::Vec4 reference = tcu::abs(dx) + tcu::abs(dy);
1396 const tcu::Vec4 dxThreshold = getDerivateThreshold(m_definitions.precision, m_textureValues.texValueMin*xScale, m_textureValues.texValueMax*xScale, dx);
1397 const tcu::Vec4 dyThreshold = getDerivateThreshold(m_definitions.precision, m_textureValues.texValueMin*yScale, m_textureValues.texValueMax*yScale, dy);
1398 const tcu::Vec4 threshold = max(surfaceThreshold, max(dxThreshold, dyThreshold));
1410 TextureDerivateCase (tcu::TestContext& testCtx,
1426 TextureDerivateCase::TextureDerivateCase (tcu::TestContext& testCtx,
1451 m_textureValues.texValueMin = tcu::Vec4(-97.f, 0.2f, 71.f, 74.f);
1452 m_textureValues.texValueMax = tcu::Vec4(-13.2f, -77.f, 44.f, 76.f);
1456 m_textureValues.texValueMin = tcu::Vec4(-37.0f, 47.f, -7.f, 0.0f);
1457 m_textureValues.texValueMax = tcu::Vec4(-1.0f, 12.f, 7.f, 19.f);
1461 m_textureValues.texValueMin = tcu::Vec4(0.0f, -1.0f, 0.0f, 1.0f);
1462 m_textureValues.texValueMax = tcu::Vec4(1.0f, 1.0f, -1.0f, -1.0f);
1470 m_values.coordMin = tcu::Vec4(0.0f);
1471 m_values.coordMax = tcu::Vec4(1.0f);
1476 m_values.derivScale = tcu::Vec4(1.0f);
1477 m_values.derivBias = tcu::Vec4(0.0f);
1482 const tcu::UVec2 viewportSize (VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
1485 const tcu::Vec4 dx = (m_textureValues.texValueMax - m_textureValues.texValueMin) / tcu::Vec4(w, w, w*0.5f, -w*0.5f);
1486 const tcu::Vec4 dy = (m_textureValues.texValueMax - m_textureValues.texValueMin) / tcu::Vec4(h, h, h*0.5f, -h*0.5f);
1493 m_values.derivScale = 0.5f / (tcu::abs(dx) + tcu::abs(dy));
1497 m_values.derivBias = tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f);
1557 std::string fragmentSrc = tcu::StringTemplate(fragmentTmpl).specialize(fragmentParams);
1565 class ShaderDerivateTests : public tcu::TestCaseGroup
1568 ShaderDerivateTests (tcu::TestContext& testCtx);
1578 ShaderDerivateTests::ShaderDerivateTests (tcu::TestContext& testCtx)
1963 de::MovePtr<tcu::TestCaseGroup> functionGroup (new tcu::TestCaseGroup(m_testCtx, getDerivateFuncCaseName(function)));
1969 de::MovePtr<tcu::TestCaseGroup> constantGroup (new tcu::TestCaseGroup(m_testCtx, "constant"));
1985 de::MovePtr<tcu::TestCaseGroup> linearCaseGroup (new tcu::TestCaseGroup(m_testCtx, s_linearDerivateCases[caseNdx].name));
2014 de::MovePtr<tcu::TestCaseGroup> fboGroup (new tcu::TestCaseGroup(m_testCtx, s_fboConfigs[caseNdx].name, "Derivate usage when rendering into FBO"));
2045 de::MovePtr<tcu::TestCaseGroup> textureGroup (new tcu::TestCaseGroup(m_testCtx, "texture", "Derivate of texture lookup result"));
2049 de::MovePtr<tcu::TestCaseGroup> caseGroup (new tcu::TestCaseGroup(m_testCtx, s_textureConfigs[texCaseNdx].name));
2082 tcu::TestCaseGroup* createDerivateTests (tcu::TestContext& testCtx)