---
title: "subgroupBallot: shader function examples and input limits"
description: "A ballot gives every lane a vec4u with one bit per lane: bit i of word i / 32 is lane i's bool."
url: https://typeshade.dev/reference/functions/subgroupBallot/
language: en
---

# `subgroupBallot`

Function

A ballot gives every lane a `vec4u` with one bit per lane: bit i of word i / 32 is lane i's bool.

## Compare examples

The fixture votes true, false, true, true: bits 0, 2 and 3, which is 13. On one lane only bit 0 can be set.

**Model assumptions**`subgroup of 4 lanes; x = [3, 1, 4, 1]; p = [true, false, true, true]`

**Example 1`subgroupBallot(p)`**

**Result**

`vec4u(13, 0, 0, 0) in every lane: bit i is lane i`

**Example 2`subgroupBallot(p)`**

**Result**

`one lane (WebGL2, CPU oracle): vec4u(u32(p), 0, 0, 0)`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it to count the lanes that voted, with `countOneBits`, or to find the first lane that did.

## Inputs and limits

Every lane must reach the call together. Bits past the subgroup's size are 0.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`subgroupAdd`](https://typeshade.dev/reference/functions/subgroupAdd/)
- [`subgroupElect`](https://typeshade.dev/reference/functions/subgroupElect/)
- [`subgroupBroadcast`](https://typeshade.dev/reference/functions/subgroupBroadcast/)
- [`subgroupShuffle`](https://typeshade.dev/reference/functions/subgroupShuffle/)

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Returns a `vec4u` bitmask with one bit per lane of the subgroup, set where `pred` is true.

## Syntax

```ts
declare function subgroupBallot(a0: bool): vec4u
```

## Parameters

A parameter named by position (`a0`, `a1`) carries a name the ambient file generates. A call passes its arguments in order and names none of them.

- `a0` `bool`

## Return value

`vec4u`

## Description

On the CPU oracle and on WebGL2 a subgroup is one invocation ([Rule 11.21](https://typeshade.dev/reference/rules/11-21/)), so it gives the lane's own value.

## Targets

**WGSL**

`subgroupBallot(a)`

**GLSL ES 3.00**

`subgroupBallot` is lowered to one lane before the GLSL writer runs (Rule 11.21)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#subgroups)
