---
title: "dot4U8Packed: shader function examples and input limits"
description: "A packed dot product reads byte-sized lanes from two words and sums their pairwise products."
url: https://typeshade.dev/reference/functions/dot4U8Packed/
language: en
---

# `dot4U8Packed`

Function

A packed dot product reads byte-sized lanes from two words and sums their pairwise products.

## Compare examples

Compare the unpacked lanes with the sum of products. Each lane has its own signedness.

**Example 1`a = [1,2,3,4]; b = [4,3,2,1]`**

**Result**

`(1 × 4) + (2 × 3) + (3 × 2) + (4 × 1) = 20`

**Example 2`a = [0,0,0,0]; b = [1,1,1,1]`**

**Result**

`(0 × 1) + (0 × 1) + (0 × 1) + (0 × 1) = 0`

**Example 3`a = [2,2,2,2]; b = [2,2,2,2]`**

**Result**

`(2 × 2) + (2 × 2) + (2 × 2) + (2 × 2) = 16`

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 compact integer-vector arithmetic, including quantized inference.

## Inputs and limits

This example uses unsigned bytes. The compiler requires WebGPU and the packed integer dot-product language feature.

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

- [`unpack4xU8`](https://typeshade.dev/reference/functions/unpack4xU8/)
- [`pack4xU8`](https://typeshade.dev/reference/functions/pack4xU8/)
- [`dot`](https://typeshade.dev/reference/functions/dot/)

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

Reads both `u32` arguments as four UNSIGNED bytes and sums the four products into a `u32`.

## Syntax

```ts
declare function dot4U8Packed(a0: u32, a1: u32): u32
declare function dot4U8Packed(a: u32, b: u32): u32
```

## Parameters

- `a` `u32`
- `b` `u32`

## Return value

`u32`

## Description

Not supported yet on the WebGL2 tier: TypeShade emits no GLSL ES 3.00 form of it, so a module using it emits WGSL alone. The host should check `navigator.gpu.wgslLanguageFeatures` for `packed_4x8_integer_dot_product`, which `reflect().requiredLanguageFeatures` reports.

## Targets

**WGSL**

`dot4U8Packed(a, b)`

**GLSL ES 3.00**

`dot4U8Packed` is not supported yet on the WebGL2 tier

## Examples

- [`gallery/packed-bytes/packed-bytes.shade.ts`](https://typeshade.dev/guide/examples/packed-bytes/)

## See also

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