Fix SpvWorkgroupMemoryTests float32 result check
authorLiam Middlebrook <lmiddlebrook@nvidia.com>
Fri, 22 Feb 2019 21:22:24 +0000 (13:22 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 28 Feb 2019 14:18:21 +0000 (09:18 -0500)
Fix a bug in spirv_assembly.instruction.compute.workgroup_memory.float32
where the output values were being compared on a byte-level and not
compared as floating-point values.

Affects:
dEQP-VK.spirv_assembly.instruction.compute.workgroup_memory.float32

Components: Vulkan
VK-GL-CTS Issue: 1625

Change-Id: Ia274e5f08796ebf8e4a6fa78e7df377a80e5a25f

external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmWorkgroupMemoryTests.cpp

index f11a363..998ea35 100644 (file)
@@ -40,6 +40,7 @@ using tcu::IVec3;
 using tcu::Vec4;
 using tcu::StringTemplate;
 using tcu::Float16;
+using tcu::Float32;
 
 namespace
 {
@@ -79,6 +80,35 @@ bool checkResultsFloat16 (const vector<Resource>&            inputs,
        return true;
 }
 
+
+bool checkResultsFloat32 (const vector<Resource>&              inputs,
+                                                 const vector<AllocationSp>&   outputAllocs,
+                                                 const vector<Resource>&               expectedOutputs,
+                                                 tcu::TestLog&                                 log)
+{
+       DE_UNREF(inputs);
+       DE_UNREF(log);
+
+       std::vector<deUint8> expectedBytes;
+       expectedOutputs.front().getBuffer()->getPackedBytes(expectedBytes);
+
+       const deUint32* results         = reinterpret_cast<const deUint32*>(outputAllocs.front()->getHostPtr());
+       const deUint32* expected        = reinterpret_cast<const deUint32*>(&expectedBytes[0]);
+
+       for (size_t i = 0; i < expectedBytes.size() / sizeof (deUint32); i++)
+       {
+               if (results[i] == expected[i])
+                       continue;
+
+               if (Float32(results[i]).isNaN() && Float32(expected[i]).isNaN())
+                       continue;
+
+               return false;
+       }
+
+       return true;
+}
+
 bool isNanFloat64 (deUint64 f)
 {
        // NaN has full exponent bits and non-zero mantissa.
@@ -286,6 +316,7 @@ void addComputeWorkgroupMemoryTests (tcu::TestCaseGroup* group)
 
                spec.assembly           = shaderSource.specialize(shaderSpec);
                spec.numWorkGroups      = IVec3(1, 1, 1);
+               spec.verifyIO           = checkResultsFloat32;
 
                spec.inputs.push_back(Resource(BufferSp(new Float32Buffer(inputData)), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER));
                spec.outputs.push_back(Resource(BufferSp(new Float32Buffer(outputData)), VK_DESCRIPTOR_TYPE_STORAGE_BUFFER));