insertBits
On this page

insertBits

Function

Inserts the low count bits of newbits into e at bit offset; the offset and count are clamped to the 32 bits as WGSL specifies.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function insertBits<V extends vec2i | vec3i | vec4i | vec2u | vec3u | vec4u>(a0: V, a1: V, a2: u32, a3: u32): V
declare function insertBits<P0 extends number, P1 extends number>(a0: P0, a1: P1, a2: u32, a3: u32): ([P0] extends [boolean] ? bool : typeof f32Tag extends keyof P0 ? f32 : typeof i32Tag extends keyof P0 ? i32 : typeof u32Tag extends keyof P0 ? u32 : typeof f64Tag extends keyof P0 ? f64 : ([P1] extends [boolean] ? bool : typeof f32Tag extends keyof P1 ? f32 : typeof i32Tag extends keyof P1 ? i32 : typeof u32Tag extends keyof P1 ? u32 : typeof f64Tag extends keyof P1 ? f64 : number))
declare function insertBits<T extends Numeric>(e: T, newbits: T, offset: number, count: number): T

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 declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.

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

Numeric
type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u

Parameters

  • e VP0T
  • newbits VP1T
  • offset u32number
  • count u32number

Return value

V([P0] extends [boolean] ? bool : typeof f32Tag extends keyof P0 ? f32 : typeof i32Tag extends keyof P0 ? i32 : typeof u32Tag extends keyof P0 ? u32 : typeof f64Tag extends keyof P0 ? f64 : ([P1] extends [boolean] ? bool : typeof f32Tag extends keyof P1 ? f32 : typeof i32Tag extends keyof P1 ? i32 : typeof u32Tag extends keyof P1 ? u32 : typeof f64Tag extends keyof P1 ? f64 : number))T

Description

A _ibits helper on GLSL ES 3.00.

Targets

WGSL
insertBits(a, b, c, d)
GLSL ES 3.00
_ibits(a, b, c, d)

Examples

See also

Edit this page Report a problem