---
title: "textureBarrier: 셰이더 함수 뜻과 사용법, 계산 예제와 입력 범위 및 주의점"
description: "한 워크그룹의 호출들이 도착할 때까지 기다리고 텍스처 메모리 접근의 순서를 맞춥니다. 텍스처 메모리에 함께 기록하는 단계와 그 값을 읽는 단계 사이에 사용합니다. 워크그룹의 모든 호출이 균일한 제어 흐름에서 배리어에 도착해야 합니다."
url: https://typeshade.dev/ko/reference/functions/textureBarrier/
language: ko
---

# `textureBarrier`

함수

한 워크그룹의 호출들이 도착할 때까지 기다리고 텍스처 메모리 접근의 순서를 맞춥니다.

## 예제 비교

같은 워크그룹에서는 배리어 전의 텍스처 메모리 쓰기가 배리어 후의 읽기보다 앞섭니다. 다른 워크그룹 사이에는 이 순서가 성립하지 않습니다.

**모델의 전제**`A, B ∈ workgroup W; C ∈ workgroup V; W ≠ V`

**예제 1`W: A.write → textureBarrier() → B.read`**

**결과**

`A.write ≺ B.read`

**예제 2`W: A.write → textureBarrier() → A.read`**

**결과**

`A.write ≺ A.read`

**예제 3`W.textureBarrier(); V.textureBarrier()`**

**결과**

`scope(W) ≠ scope(V)`

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

## 관련 함수

- [`workgroupBarrier`](https://typeshade.dev/ko/reference/functions/workgroupBarrier/)
- [`storageBarrier`](https://typeshade.dev/ko/reference/functions/storageBarrier/)
- [`workgroupUniformLoad`](https://typeshade.dev/ko/reference/functions/workgroupUniformLoad/)

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

Holds every invocation of the workgroup until all have arrived, ordering their writes to the TEXTURE address space.

## 구문

```ts
declare function textureBarrier(): void
```

## 반환값

`void`

## 설명

A statement, in a compute entry or a function it calls, in uniform control flow; not supported yet on the WebGL2 tier, where an entry that reaches a texture does not run as the pass program ([Rule 8.24](https://typeshade.dev/ko/reference/rules/8-24/)). Part of the `readonly_and_readwrite_storage_textures` WGSL language feature that `reflect().requiredLanguageFeatures` reports.

## 대상별 출력

**WGSL**

`textureBarrier()`

**GLSL ES 3.00**

`textureBarrier` is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)

## 예제

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

## 함께 보기

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