Class EXTShaderSubgroupVote
- java.lang.Object
-
- org.lwjgl.vulkan.EXTShaderSubgroupVote
-
public final class EXTShaderSubgroupVote extends java.lang.Object
This extension adds support for the following SPIR-V extension in Vulkan:- SPV_KHR_subgroup_vote
This extension provides new SPIR-V instructions:
OpSubgroupAllKHR
,OpSubgroupAnyKHR
, andOpSubgroupAllEqualKHR
.
to compute the composite of a set of boolean conditions across a group of shader invocations that are running concurrently (a subgroup). These composite results may be used to execute shaders more efficiently on a
VkPhysicalDevice
.When using GLSL source-based shader languages, the following shader functions from GL_ARB_shader_group_vote can map to these SPIR-V instructions:
anyInvocationARB
() →OpSubgroupAnyKHR
,allInvocationsARB
() →OpSubgroupAllKHR
, andallInvocationsEqualARB
() →OpSubgroupAllEqualKHR
.
The subgroup across which the boolean conditions are evaluated is implementation-dependent, and this extension provides no guarantee over how individual shader invocations are assigned to subgroups. In particular, a subgroup has no necessary relationship with the compute shader local workgroup -- any pair of shader invocations in a compute local workgroup may execute in different subgroups as used by these instructions.
Compute shaders operate on an explicitly specified group of threads (a local workgroup), but many implementations will also group non-compute shader invocations and execute them concurrently. When executing code like
if (condition) { result = do_fast_path(); } else { result = do_general_path(); }
where
condition
diverges between invocations, an implementation might first executedo_fast_path
() for the invocations wherecondition
is true and leave the other invocations dormant. Oncedo_fast_path
() returns, it might calldo_general_path
() for invocations wherecondition
isfalse
and leave the other invocations dormant. In this case, the shader executes both the fast and the general path and might be better off just using the general path for all invocations.This extension provides the ability to avoid divergent execution by evaluating a condition across an entire subgroup using code like:
if (allInvocationsARB(condition)) { result = do_fast_path(); } else { result = do_general_path(); }
The built-in function
allInvocationsARB
() will return the same value for all invocations in the group, so the group will either executedo_fast_path
() ordo_general_path
(), but never both. For example, shader code might want to evaluate a complex function iteratively by starting with an approximation of the result and then refining the approximation. Some input values may require a small number of iterations to generate an accurate result (do_fast_path
) while others require a larger number (do_general_path
). In another example, shader code might want to evaluate a complex function (do_general_path
) that can be greatly simplified when assuming a specific value for one of its inputs (do_fast_path
).- Name String
VK_EXT_shader_subgroup_vote
- Extension Type
- Device extension
- Registered Extension Number
- 66
- Revision
- 1
- Extension and Version Dependencies
- Requires Vulkan 1.0
- Contact
- Daniel Koch dgkoch
- Last Modified Date
- 2016-11-28
- IP Status
- No known IP claims.
- Interactions and External Dependencies
- This extension requires the SPV_KHR_subgroup_vote SPIR-V extension.
- This extension requires the GL_ARB_shader_group_vote extension for GLSL source languages.
- Contributors
- Neil Henning, Codeplay
- Daniel Koch, NVIDIA Corporation
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME
The extension name.static int
VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION
The extension specification version.
-
-
-
Field Detail
-
VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION
public static final int VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION
The extension specification version.- See Also:
- Constant Field Values
-
VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME
public static final java.lang.String VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME
The extension name.- See Also:
- Constant Field Values
-
-