Provide a highp variable to MAKE_HIGH_BALLOT_RESULT
authorHsin-Hsiao Lin <hsin-hsiao.lin@arm.com>
Thu, 25 Jul 2019 07:13:34 +0000 (09:13 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 14 Aug 2019 11:42:07 +0000 (07:42 -0400)
The MAKE_HIGH_BALLOT_RESULT macro assumes the input is 32bit.
Given a mediump variable, ex: gl_SubgroupSize, would produce an
undefined result when the input value is >= 16 and the computation
is in 16 bits.
Provide a highp input would ensure the computation is in 32 bits.

Affects:
  dEQP-VK.subgroups.ballot_other.*

Components: vulkan

VK-GL-CTS issue: 1894

Change-Id: I22987f20be3d08444c52cb722fc23494777a5636

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

index c16cbe0..b9353e0 100755 (executable)
@@ -133,10 +133,12 @@ std::string getBodySource(CaseDefinition caseDef)
                                << "  }\n";
                        break;
                case OPTYPE_BALLOT_BIT_COUNT:
-                       bdy << "  tempResult |= gl_SubgroupSize == subgroupBallotBitCount(allOnes) ? 0x1 : 0;\n"
+                       bdy << "  /* To ensure a 32-bit computation, use a variable with default highp precision. */\n"
+                               << "  uint SubgroupSize = gl_SubgroupSize;\n"
+                               << "  tempResult |= SubgroupSize == subgroupBallotBitCount(allOnes) ? 0x1 : 0;\n"
                                << "  tempResult |= 0 == subgroupBallotBitCount(allZeros) ? 0x2 : 0;\n"
                                << "  tempResult |= 0 < subgroupBallotBitCount(subgroupBallot(true)) ? 0x4 : 0;\n"
-                               << "  tempResult |= 0 == subgroupBallotBitCount(MAKE_HIGH_BALLOT_RESULT(gl_SubgroupSize)) ? 0x8 : 0;\n";
+                               << "  tempResult |= 0 == subgroupBallotBitCount(MAKE_HIGH_BALLOT_RESULT(SubgroupSize)) ? 0x8 : 0;\n";
                        break;
                case OPTYPE_BALLOT_INCLUSIVE_BIT_COUNT:
                        bdy << "  uint inclusiveOffset = gl_SubgroupInvocationID + 1;\n"
@@ -444,6 +446,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        "#version 450\n"
                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
                        "layout(location = 0) out uint result;\n"
+                       "precision highp int;\n"
                        "void main (void)\n"
                        "{\n"
                        + bdyStr +