Fixes VS num instances assumption
authorMatthew Netsch <quic_mnetsch@quicinc.com>
Mon, 21 Oct 2019 15:58:29 +0000 (11:58 -0400)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Mon, 21 Oct 2019 15:58:29 +0000 (11:58 -0400)
Components: Vulkan
VK-GL-CTS Issue: 2022

Affects:
dEQP-VK.spirv_assembly.instruction.*

Change-Id: Ibb0a17d8843c03cd1cf15d2c5af1f547481e8452

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

index 92c1edd..ab2292e 100644 (file)
@@ -4070,7 +4070,33 @@ TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instan
                        expected->getBytes(expectedBytes);
 
                        if (deMemCmp(&expectedBytes.front(), outResourceMemories[outputNdx]->getHostPtr(), expectedBytes.size()))
-                               return tcu::TestStatus::fail("Resource returned doesn't match bitwisely with expected");
+                       {
+                               // Some *variable_pointers* tests store counters in buffer
+                               // whose value may vary if the same vertex shader may be executed for multiple times
+                               // in this case the output value can be expected value + non-negative integer N
+                               if (instance.customizedStages == VK_SHADER_STAGE_VERTEX_BIT)
+                               {
+                                       const size_t    numExpectedEntries      = expectedBytes.size() / sizeof(float);
+                                       const float*    expectedFloats          = reinterpret_cast<const float*>(&expectedBytes.front());
+                                       const float*    outputFloats            = reinterpret_cast<const float*>(outResourceMemories[outputNdx]->getHostPtr());
+                                       float                   diff                            = 0.0f;
+
+                                       for (size_t expectedNdx = 0; expectedNdx < numExpectedEntries; ++expectedNdx)
+                                       {
+                                               if (deFloatIsInf(outputFloats[expectedNdx]) || deFloatIsNaN(outputFloats[expectedNdx]))
+                                                       return tcu::TestStatus::fail("Value returned is invalid");
+
+                                               diff = outputFloats[expectedNdx] - expectedFloats[expectedNdx];
+
+                                               if ((diff < 0.0f) || (deFloatFloor(diff) != diff))
+                                                       return tcu::TestStatus::fail("Value returned should be equal to expected value plus non-negative integer");
+                                       }
+                               }
+                               else
+                               {
+                                       return tcu::TestStatus::fail("Resource returned doesn't match bitwisely with expected");
+                               }
+                       }
 
                }
        }