---
title: "compute: TypeShade 언어 참조에 실린 어트리뷰트 이름과 그 시그니처"
description: "compute (어트리뷰트), TypeShade 언어 참조 항목입니다. Marks a compute-stage entry point with its workgroup size, one to three extents…"
url: https://typeshade.dev/ko/reference/attributes/compute/
language: ko
---

# `@compute`

어트리뷰트

Marks a compute-stage entry point with its workgroup size, one to three extents, on the function declaration: `@compute([64]) export function main(…) { … }`.

`@compute([x, y?, z?])`는 표시한 함수를 컴퓨트 진입점으로 만들고, 워크그룹 크기를 한 개에서 세 개의 축 크기로 정합니다.

## 예제 비교

디스패치 하나의 인보케이션 세 개를 비교합니다. 저마다 자신의 `global_invocation_id`를 읽고 자신의 원소에 씁니다.

**예제 프로그램**`declare const out: storage<array<u32>, "read_write">; @compute([64]) export function main(gid: builtin<"global_invocation_id">): void { out[gid.x] = gid.x; }`

**예제 1`gid.x = 0`**

**결과**

`워크그룹 0, 레인 0`

**예제 2`gid.x = 63`**

**결과**

`워크그룹 0, 레인 63`

**예제 3`gid.x = 64`**

**결과**

`워크그룹 1, 레인 0`

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

## 활용

드로와 무관하게 버퍼와 텍스처를 다루는 일반 GPU 작업에 사용합니다.

## 입력 범위와 주의사항

크기는 속성의 인자이며, 인자 없이 쓴 `@compute`는 64를 씁니다. 디스패치가 워크그룹을 몇 개 실행할지는 호스트가 정하고, 크기는 워크그룹 하나에 인보케이션이 몇 개 있는지를 정합니다.

셰이더의 입력 규칙과 정밀도는 [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)에서 규정합니다.

## 관련 속성

- [`@workgroup_size`](https://typeshade.dev/ko/reference/attributes/workgroup_size/)
- [`@vertex`](https://typeshade.dev/ko/reference/attributes/vertex/)
- [`@fragment`](https://typeshade.dev/ko/reference/attributes/fragment/)

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

## 구문

```ts
declare function compute(workgroupSize: readonly number[]): (target: Function, context?: unknown) => void
declare function compute(target: Function, context?: unknown): void
```

## 매개변수

- `workgroupSize` `readonly number[]`

인자 없이 그대로 붙이는 형태도 있습니다.

선언에는 TypeScript 데코레이터 런타임이 넘겨주는 `target`과 `context`도 적혀 있습니다. 호출에서는 둘 다 쓰지 않습니다.

## 설명

A bare `@compute` takes 64.

## 예제

- [`path/double-array/double-array.shade.ts`](https://typeshade.dev/ko/guide/examples/double-array/)
- [`path/image-blur/image-blur.shade.ts`](https://typeshade.dev/ko/guide/examples/image-blur/)
- [`path/parallel-sum/parallel-sum.shade.ts`](https://typeshade.dev/ko/guide/examples/parallel-sum/)
- [`path/histogram/histogram.shade.ts`](https://typeshade.dev/ko/guide/examples/histogram/)
- [`gallery/array-length/array-length.shade.ts`](https://typeshade.dev/ko/guide/examples/array-length/)
- [`gallery/atomic-histogram/atomic-histogram.shade.ts`](https://typeshade.dev/ko/guide/examples/atomic-histogram/)
- [`gallery/compute-reduction-twin/compute-reduction-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/compute-reduction-twin/)
- [`gallery/compute-sync/compute-sync.shade.ts`](https://typeshade.dev/ko/guide/examples/compute-sync/)
- [`gallery/gpu-console/gpu-console.shade.ts`](https://typeshade.dev/ko/guide/examples/gpu-console/)
- [`gallery/particle-step/particle-step.shade.ts`](https://typeshade.dev/ko/guide/examples/particle-step/)
- [`gallery/storage-texture/storage-texture.shade.ts`](https://typeshade.dev/ko/guide/examples/storage-texture/)
- [`gallery/subgroup-reduce/subgroup-reduce.shade.ts`](https://typeshade.dev/ko/guide/examples/subgroup-reduce/)
- [`gallery/workgroup-override/workgroup-override.shade.ts`](https://typeshade.dev/ko/guide/examples/workgroup-override/)
- [`gallery/workgroup-reduce/workgroup-reduce.shade.ts`](https://typeshade.dev/ko/guide/examples/workgroup-reduce/)
- [`gallery/workgroup-scratch/workgroup-scratch.shade.ts`](https://typeshade.dev/ko/guide/examples/workgroup-scratch/)
- [`gallery/workgroup-tile-2d/workgroup-tile-2d.shade.ts`](https://typeshade.dev/ko/guide/examples/workgroup-tile-2d/)

## 함께 보기

- [어트리뷰트](https://typeshade.dev/ko/reference/attributes/)
