---
title: "dot4U8Packed: 셰이더 함수 뜻과 사용법, 계산 예제와 입력 범위 및 주의점"
description: "두 정수의 바이트 단위 성분을 읽어 같은 위치끼리 곱한 뒤 더합니다. 양자화 추론처럼 압축된 정수 벡터를 계산할 때 사용합니다. 예제는 부호 없는 바이트를 사용합니다. 이 컴파일러에서는 WebGPU와 압축 정수 내적 언어 기능이 필요합니다."
url: https://typeshade.dev/ko/reference/functions/dot4U8Packed/
language: ko
---

# `dot4U8Packed`

함수

두 정수의 바이트 단위 성분을 읽어 같은 위치끼리 곱한 뒤 더합니다.

## 예제 비교

각 바이트를 부호 없는 성분으로 해석해 같은 위치끼리 곱한 뒤 더합니다. 한쪽 벡터가 영이면 내적도 영입니다.

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

**결과**

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

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

**결과**

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

**예제 3`a = [2,2,2,2]; b = [2,2,2,2]`**

**결과**

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

예제는 설명용 계산 모델이며 GPU를 실행하지 않습니다. 정확한 호출 형식은 아래 컴파일러 참고 자료에서 설명합니다. 소수 결과는 표시할 때 반올림했습니다. 각 예제는 명시한 전제를 따릅니다. 실제 셰이더의 결과는 대상 언어의 정밀도와 실행 규칙에 따릅니다.

## 활용

양자화 추론처럼 압축된 정수 벡터를 계산할 때 사용합니다.

## 입력 범위와 주의사항

예제는 부호 없는 바이트를 사용합니다. 이 컴파일러에서는 WebGPU와 압축 정수 내적 언어 기능이 필요합니다.

셰이더의 입력 규칙과 정밀도는 [WGSL](https://www.w3.org/TR/WGSL/)과 [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)에서 규정합니다.

## 관련 함수

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

시그니처와 이름 아래 문장, 컴파일러 메시지는 커밋 af54ddad5의 컴파일러가 쓴 영어 원문입니다.

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

## 구문

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

## 매개변수

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

## 반환값

`u32`

## 설명

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.

## 대상별 출력

**WGSL**

`dot4U8Packed(a, b)`

**GLSL ES 3.00**

`dot4U8Packed` is not supported yet on the WebGL2 tier

## 예제

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

## 함께 보기

- [함수](https://typeshade.dev/ko/reference/functions/)
- [내장 함수 표](https://typeshade.dev/ko/guide/language/builtins/#bits)
