Avoid undefined behaviour when calculating subgroup ballot masks
authorDae Kim <dae.kim@imgtec.com>
Fri, 13 Dec 2019 09:26:05 +0000 (09:26 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 20 Dec 2019 12:47:19 +0000 (07:47 -0500)
The affected tests are shifting the bits of the last component of the
computed ballot masks by 32. However, the SPIR-V specification
establishes that the result of OpShift* is undefined if `Shift` is
greater than *or equal* to the bit width of the components of `Base`.

Affects:

dEQP-VK.subgroups.ballot_other.*

Components: Vulkan

VK-GL-CTS issue: 2083

Change-Id: I8c9b4373f1429669a40741986916e8d71b7eb573

external/vulkancts/modules/vulkan/subgroups/vktSubgroupsBallotOtherTests.cpp

index f3f66f6..ebb0586 100755 (executable)
@@ -103,12 +103,12 @@ std::string getBodySource(CaseDefinition caseDef)
                << "i >= 32 ? 0 : (0xFFFFFFFF << i), "
                << "i >= 64 ? 0 : (0xFFFFFFFF << ((i < 32) ? 0 : (i - 32))), "
                << "i >= 96 ? 0 : (0xFFFFFFFF << ((i < 64) ? 0 : (i - 64))), "
-               << " 0xFFFFFFFF << ((i < 96) ? 0 : (i - 96)))\n"
+               << "i >= 128 ? 0 : (0xFFFFFFFF << ((i < 96) ? 0 : (i - 96))))\n"
                << "#define MAKE_SINGLE_BIT_BALLOT_RESULT(i) uvec4("
                << "i >= 32 ? 0 : 0x1 << i, "
                << "i < 32 || i >= 64 ? 0 : 0x1 << (i - 32), "
                << "i < 64 || i >= 96 ? 0 : 0x1 << (i - 64), "
-               << "i < 96 ? 0 : 0x1 << (i - 96))\n";
+               << "i < 96 || i >= 128 ? 0 : 0x1 << (i - 96))\n";
 
        switch (caseDef.opType)
        {