1// Copyright 2016-2024 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5include::{generated}/meta/{refprefix}VK_EXT_shader_subgroup_ballot.adoc[]
6
7=== Other Extension Metadata
8
9*Last Modified Date*::
10    2016-11-28
11*IP Status*::
12    No known IP claims.
13*Interactions and External Dependencies*::
14  - This extension provides API support for
15    {GLregistry}/ARB/ARB_shader_ballot.txt[`GL_ARB_shader_ballot`]
16*Contributors*::
17  - Jeff Bolz, NVIDIA
18  - Neil Henning, Codeplay
19  - Daniel Koch, NVIDIA Corporation
20
21=== Description
22
23This extension adds support for the following SPIR-V extension in Vulkan:
24
25  * `SPV_KHR_shader_ballot`
26
27This extension provides the ability for a group of invocations, which
28execute in parallel, to do limited forms of cross-invocation communication
29via a group broadcast of a invocation value, or broadcast of a bitarray
30representing a predicate value from each invocation in the group.
31
32This extension provides access to a number of additional built-in shader
33variables in Vulkan:
34
35  * code:SubgroupEqMaskKHR, containing the subgroup mask of the current
36    subgroup invocation,
37  * code:SubgroupGeMaskKHR, containing the subgroup mask of the invocations
38    greater than or equal to the current invocation,
39  * code:SubgroupGtMaskKHR, containing the subgroup mask of the invocations
40    greater than the current invocation,
41  * code:SubgroupLeMaskKHR, containing the subgroup mask of the invocations
42    less than or equal to the current invocation,
43  * code:SubgroupLtMaskKHR, containing the subgroup mask of the invocations
44    less than the current invocation,
45  * code:SubgroupLocalInvocationId, containing the index of an invocation
46    within a subgroup, and
47  * code:SubgroupSize, containing the maximum number of invocations in a
48    subgroup.
49
50Additionally, this extension provides access to the new SPIR-V instructions:
51
52  * code:OpSubgroupBallotKHR,
53  * code:OpSubgroupFirstInvocationKHR, and
54  * code:OpSubgroupReadInvocationKHR,
55
56When using GLSL source-based shader languages, the following variables and
57shader functions from GL_ARB_shader_ballot can map to these SPIR-V built-in
58decorations and instructions:
59
60  * `in uint64_t gl_SubGroupEqMaskARB;` -> code:SubgroupEqMaskKHR,
61  * `in uint64_t gl_SubGroupGeMaskARB;` -> code:SubgroupGeMaskKHR,
62  * `in uint64_t gl_SubGroupGtMaskARB;` -> code:SubgroupGtMaskKHR,
63  * `in uint64_t gl_SubGroupLeMaskARB;` -> code:SubgroupLeMaskKHR,
64  * `in uint64_t gl_SubGroupLtMaskARB;` -> code:SubgroupLtMaskKHR,
65  * `in uint gl_SubGroupInvocationARB;` -> code:SubgroupLocalInvocationId,
66  * `uniform uint gl_SubGroupSizeARB;` -> code:SubgroupSize,
67  * code:ballotARB() -> code:OpSubgroupBallotKHR,
68  * code:readFirstInvocationARB() -> code:OpSubgroupFirstInvocationKHR, and
69  * code:readInvocationARB() -> code:OpSubgroupReadInvocationKHR.
70
71=== Deprecated by Vulkan 1.2
72
73Most of the functionality in this extension is superseded by the core Vulkan
741.1 <<VkPhysicalDeviceSubgroupProperties, subgroup operations>>.
75However, Vulkan 1.1 required the code:OpGroupNonUniformBroadcast "`Id`" to
76be constant.
77This restriction was removed in Vulkan 1.2 with the addition of the
78<<features-subgroupBroadcastDynamicId, pname:subgroupBroadcastDynamicId>>
79feature.
80
81include::{generated}/interfaces/VK_EXT_shader_subgroup_ballot.adoc[]
82
83=== New Built-In Variables
84
85  * <<interfaces-builtin-variables-sgeq,code:SubgroupEqMaskKHR>>
86  * <<interfaces-builtin-variables-sgge,code:SubgroupGeMaskKHR>>
87  * <<interfaces-builtin-variables-sggt,code:SubgroupGtMaskKHR>>
88  * <<interfaces-builtin-variables-sgle,code:SubgroupLeMaskKHR>>
89  * <<interfaces-builtin-variables-sglt,code:SubgroupLtMaskKHR>>
90  * <<interfaces-builtin-variables-sgli,code:SubgroupLocalInvocationId>>
91  * <<interfaces-builtin-variables-sgs,code:SubgroupSize>>
92
93=== New SPIR-V Capabilities
94
95  * <<spirvenv-capabilities-table-SubgroupBallotKHR,
96    code:SubgroupBallotKHR>>
97
98=== Version History
99
100  * Revision 1, 2016-11-28 (Daniel Koch)
101  ** Initial draft
102