textureNumLayers
이 페이지에서

textureNumLayers()

함수, 내장 함수 분류

How many layers a 2D array texture has, as a u32.

import { textureNumLayers } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

const textureNumLayers: (
tex: ReadonlyNode<TextureLoadArrayKey>,
) => Node<"u32">

매개변수

tex ReadonlyNode<TextureLoadArrayKey>

the array-texture binding to measure.

반환값

Node<'u32'>

the layer count.

설명

textureDimensions reports the width and height only, vec2<u32>, for an array texture as much as for a plain one, so the layer count is this separate query. Wrap the result in toF32 for float arithmetic.

It accepts an array key only: a plain 2D or multisampled texture has no layer count, and passing one is a tsc error. An integer array texture is accepted, since the count is a property of the view and not of the texel element.

The targets spell it differently, which is why it carries its own id instead of overloading textureDimensions. WGSL has the dedicated textureNumLayers(t). GLSL ES 3.00 has no such function and reads the third component of textureSize(t, 0), exactly the component the uvec2() constructor behind textureDimensions drops. The lod argument is required there, and the layer count does not vary with lod, so 0 is always right.

The CPU evaluation (compileModule) has no way to query a texture and returns a placeholder under its gpuStubs option.

예제

예제

import { resource, textureNumLayers, toF32, texture2dArrayfT } from 'typeshade'
const atlas = resource('atlas', texture2dArrayfT, { group: 0, binding: 1 })
const layers = toF32(textureNumLayers(atlas.node))

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

textureNumLayers(tex).

GLSL ES 3.00 (WebGL2) 지원

uint(textureSize(tex, 0).z).

CPU 오라클 스텁

The oracle has no texture memory and no neighbouring fragments. The call throws unless the module was compiled with { gpuStubs: true }, which returns a placeholder.

관련 가이드

함께 보기

소스

src/core/ir/node.ts, 2231행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고