---
title: "atomicLoad: 셰이더 함수 뜻과 사용법, 계산 예제와 입력 범위 및 주의점"
description: "공유 정수 하나를 원자적으로 읽습니다. 값의 일부만 읽는 일이 없습니다. 공유 카운터의 값을 읽을 때 사용합니다. 모델은 부호 없는 정수에 연산 하나를 순서대로 적용합니다. 실제 호출 순서는 정해져 있지 않습니다."
url: https://typeshade.dev/ko/reference/functions/atomicLoad/
language: ko
---

# `atomicLoad`

함수

공유 정수 하나를 원자적으로 읽습니다. 값의 일부만 읽는 일이 없습니다.

## 예제 비교

반환값은 읽은 정수입니다. 저장값은 바뀌지 않으며, 각 예제는 독립된 초기 상태에서 시작합니다.

**모델의 전제**`location: atomic<u32>`

**예제 1`atomicLoad(location)`**

**연산 전 저장값**

`5`

**반환값**

`5`

**연산 후 저장값**

`5`

**예제 2`atomicLoad(location)`**

**연산 전 저장값**

`0`

**반환값**

`0`

**연산 후 저장값**

`0`

**예제 3`atomicLoad(location)`**

**연산 전 저장값**

`4294967295`

**반환값**

`4294967295`

**연산 후 저장값**

`4294967295`

예제는 설명용 계산 모델이며 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)에서 규정합니다.

## 관련 함수

- [`atomicStore`](https://typeshade.dev/ko/reference/functions/atomicStore/)
- [`atomicAdd`](https://typeshade.dev/ko/reference/functions/atomicAdd/)
- [`atomicSub`](https://typeshade.dev/ko/reference/functions/atomicSub/)
- [`atomicMin`](https://typeshade.dev/ko/reference/functions/atomicMin/)
- [`atomicMax`](https://typeshade.dev/ko/reference/functions/atomicMax/)

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

Reads the value of an `atomic<u32>` or `atomic<i32>` location in a read-write storage binding (`atomicLoad(bins[i])`).

## 구문

```ts
declare function atomicLoad<T extends u32 | i32>(location: atomic<T>): T
```

## 매개변수

- `location` `atomic<T>`

## 반환값

`T`

## 설명

Compiles to `atomicLoad(&bins[i])` on WGSL; its GLSL lowering is not supported yet ([Rule 10.5](https://typeshade.dev/ko/reference/rules/10-5/)), so a module using it emits WGSL alone. The CPU oracle runs invocations in order and reads the location.

## 대상별 출력

**WGSL**

`atomicLoad(&a)`

**GLSL ES 3.00**

`atomicLoad` is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a `@compute` entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)

## 함께 보기

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