---
title: "subgroupShuffleUp: shader function examples and input limits"
description: "A shuffle gives each lane the value of the lane delta below it. Use it for a neighbour read from the lane before. A lane below 0 gives an indeterminate value."
url: https://typeshade.dev/reference/functions/subgroupShuffleUp/
language: en
---

# `subgroupShuffleUp`

Function

A shuffle gives each lane the value of the lane delta below it.

## Compare examples

With delta 1 each lane reads the previous lane; lane 0 names a lane below the subgroup, shown as ?. On one lane the call gives the lane's own value.

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

**Example 1`subgroupShuffleUp(x, 1)`**

**Result**

`[?, 3, 1, 4] by lane`

**Example 2`subgroupShuffleUp(x, 1)`**

**Result**

`one lane (WebGL2, CPU oracle): x`

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 for a neighbour read from the lane before.

## Inputs and limits

A lane below 0 gives an indeterminate value. A read of another lane is a target row of the determinism report on WebGL2 and the oracle.

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/)
- [`subgroupBallot`](https://typeshade.dev/reference/functions/subgroupBallot/)
- [`subgroupBroadcast`](https://typeshade.dev/reference/functions/subgroupBroadcast/)

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

Returns `e` from the lane `delta` below this one in the subgroup.

## Syntax

```ts
declare function subgroupShuffleUp<V extends vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u>(value: V, delta: u32): V
declare function subgroupShuffleUp<P0 extends number>(value: P0, delta: u32): ScalarOf<P0>
```

A `number` in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

`type f32 = number & { readonly [f32Tag]?: true }`

A `number` you write as a type is inferred from its uses, and `f32`, `i32` and `u32` fix a width; [the TypeScript constructs page](https://typeshade.dev/guide/language/from-typescript/) carries that row with the compiler's emit.

A signature may name a type the ambient file declares for its own use. These are those declarations.

**`ScalarOf`**

`type ScalarOf<A, B = unknown, C = unknown> = unknown extends A ? number : [A] extends [boolean] ? bool : typeof f32Tag extends keyof A ? f32 : typeof i32Tag extends keyof A ? i32 : typeof u32Tag extends keyof A ? u32 : typeof f64Tag extends keyof A ? f64 : ScalarOf<B, C>`

## Parameters

- `value` `V``P0`
- `delta` `u32`

## Return value

`V``ScalarOf<P0>`

## 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**

`subgroupShuffleUp(a, b)`

**GLSL ES 3.00**

`subgroupShuffleUp` 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)
