From: Graeme Leese Date: Tue, 11 Jun 2019 12:41:23 +0000 (+0100) Subject: Remove duplicated code from isinf/isnan tests X-Git-Tag: upstream/1.3.5~1486 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4574d7f24536921dcabe74e0840e133b7b6c002b;p=platform%2Fupstream%2FVK-GL-CTS.git Remove duplicated code from isinf/isnan tests Most of the checking code for IsNan and IsInf was written out twice, once for each precision. Remove one of the copies. Components: Vulkan Affects: dEQP-VK.glsl.builtin.function.common.isinf.* dEQP-VK.glsl.builtin.function.common.isnan.* Change-Id: I5c00e1757086b204a6797424c0d35eb84b3f99a8 --- diff --git a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp index c777ccd..28b304a 100644 --- a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp +++ b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp @@ -576,36 +576,23 @@ public: const glu::Precision precision = m_spec.inputs[0].varType.getPrecision(); const int scalarSize = glu::getDataTypeScalarSize(type); - if (precision == glu::PRECISION_HIGHP) - { - // Only highp is required to support inf/nan - for (int compNdx = 0; compNdx < scalarSize; compNdx++) - { - const float in0 = ((const float*)inputs[0])[compNdx]; - const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; - const bool ref = tcu::Float32(in0).isNaN(); - - if (out0 != ref) - { - m_failMsg << "Expected [" << compNdx << "] = " << (ref ? "true" : "false"); - return false; - } - } - } - else if (precision == glu::PRECISION_MEDIUMP || precision == glu::PRECISION_LOWP) + for (int compNdx = 0; compNdx < scalarSize; compNdx++) { - // NaN support is optional, check that inputs that are not NaN don't result in true. - for (int compNdx = 0; compNdx < scalarSize; compNdx++) + const float in0 = ((const float*)inputs[0])[compNdx]; + const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; + const bool ref = tcu::Float32(in0).isNaN(); + bool ok; + + // NaN support only required for highp. Otherwise just check for false positives. + if (precision == glu::PRECISION_HIGHP) + ok = (out0 == ref); + else + ok = ref || !out0; + + if (!ok) { - const float in0 = ((const float*)inputs[0])[compNdx]; - const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; - const bool ref = tcu::Float32(in0).isNaN(); - - if (!ref && out0) - { - m_failMsg << "Expected [" << compNdx << "] = " << (ref ? "true" : "false"); - return false; - } + m_failMsg << "Expected [" << compNdx << "] = " << (ref ? "true" : "false"); + return false; } } @@ -654,39 +641,30 @@ public: const glu::Precision precision = m_spec.inputs[0].varType.getPrecision(); const int scalarSize = glu::getDataTypeScalarSize(type); - if (precision == glu::PRECISION_HIGHP) + for (int compNdx = 0; compNdx < scalarSize; compNdx++) { - // Only highp is required to support inf/nan - for (int compNdx = 0; compNdx < scalarSize; compNdx++) + const float in0 = ((const float*)inputs[0])[compNdx]; + const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; + bool ref; + bool ok; + if (precision == glu::PRECISION_HIGHP) { - const float in0 = ((const float*)inputs[0])[compNdx]; - const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; - const bool ref = tcu::Float32(in0).isInf(); - - if (out0 != ref) - { - m_failMsg << "Expected [" << compNdx << "] = " << HexBool(ref); - return false; - } + // Only highp is required to support inf/nan + ref = tcu::Float32(in0).isInf(); + ok = (out0 == ref); } - } - else if (precision == glu::PRECISION_MEDIUMP) - { - // Inf support is optional, check that inputs that are not Inf in mediump don't result in true. - for (int compNdx = 0; compNdx < scalarSize; compNdx++) + else { - const float in0 = ((const float*)inputs[0])[compNdx]; - const bool out0 = ((const deUint32*)outputs[0])[compNdx] != 0; - const bool ref = tcu::Float16(in0).isInf(); - - if (!ref && out0) - { - m_failMsg << "Expected [" << compNdx << "] = " << (ref ? "true" : "false"); - return false; - } + // Inf support is optional, check that inputs that are not Inf in mediump don't result in true. + ref = tcu::Float16(in0).isInf(); + ok = (out0 || !ref); + } + if (!ok) + { + m_failMsg << "Expected [" << compNdx << "] = " << HexBool(ref); + return false; } } - // else: no verification can be performed return true; }