---
title: "dot4I8Packed: 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/dot4I8Packed/
language: en
---

# `dot4I8Packed`

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 signed 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

- [`unpack4xI8`](https://typeshade.dev/reference/functions/unpack4xI8/)
- [`pack4xI8`](https://typeshade.dev/reference/functions/pack4xI8/)
- [`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 SIGNED bytes and sums the four products into an `i32`, wrapping at 32 bits.

## Syntax

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

## Parameters

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

## Return value

`i32`

## Description

Not supported yet on the WebGL2 tier, like `dot4U8Packed`.

## Targets

**WGSL**

`dot4I8Packed(a, b)`

**GLSL ES 3.00**

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