textureNumLayers
이 페이지에서

textureNumLayers

함수

텍스처 배열은 독립적으로 선택할 수 있는 이미지 레이어를 담습니다. 이 함수는 레이어 수를 구합니다.

예제 비교

반환값은 배열의 레이어 수입니다. 큐브 배열에서는 개별 면이 아니라 큐브 수를 셉니다.

예제 1texture_2d_array: layers = 1
결과
1
예제 2texture_2d_array: layers = 4
결과
4
예제 3texture_cube_array: cubes = 3
결과
3

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

활용

레이어 선택자의 범위를 정하거나 이미지 배열을 순회할 때 사용합니다.

입력 범위와 주의사항

배열 텍스처가 필요합니다. 마지막 유효 레이어 인덱스는 레이어 수보다 하나 작습니다.

셰이더의 입력 규칙과 정밀도는 WGSL과 GLSL ES 3.00에서 규정합니다.

WGSL
textureNumLayers(a)
GLSL ES 3.00
uint(textureSize(a, 0).z)

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

Returns the number of layers of a texture_2d_array or a texture_cube_array as a u32.

구문

declare function textureNumLayers<E extends TextureElem = f32>(tex: texture_cube_array<E>): u32
declare function textureNumLayers(tex: texture_depth_cube_array): u32
declare function textureNumLayers(tex: texture_depth_2d_array): u32
declare function textureNumLayers<E extends TextureElem = f32>(tex: texture_2d_array<E>): u32
declare function textureNumLayers<F extends StorageFormat, A extends StorageAccess>(
tex: texture_storage_2d_array<F, A>,
): u32

시그니처에는 앰비언트 파일이 스스로 쓰려고 선언한 타입이 나올 수 있습니다. 아래가 그 선언입니다.

TextureElem
type TextureElem = f32 | i32 | u32
StorageFormat
type StorageFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm'
StorageAccess
type StorageAccess = 'write' | 'read' | 'read_write'

매개변수

반환값

u32

설명

A texture with no layers is refused.

대상별 출력

WGSL
textureNumLayers(a)
GLSL ES 3.00
uint(textureSize(a, 0).z)

예제

함께 보기

이 페이지 편집 문제 보고