textureDimensions
On this page

textureDimensions()

Function in Builtins

Texture extent in texels, as a vec2<u32>.

import { textureDimensions } from 'typeshade/core/ir'

This export returns an IR node. A "use typeshade" file calls the builtin itself: textureDimensions()

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

Syntax

const textureDimensions: (
tex: ReadonlyNode<TextureLoad2dKey | TextureLoadArrayKey>,
) => Node<"vec2<u32>">

Parameters

tex ReadonlyNode<TextureLoad2dKey | TextureLoadArrayKey>

Return value

Node<'vec2<u32>'>

Description

A 2D array texture reports its width and height the same way; the layer count is the separate textureNumLayers query. An integer texture is accepted too, since an extent does not depend on the texel element. On GLSL ES 3.00 the ivec3 that textureSize returns for an array is truncated to the two extent components. Bind the result with Let when it is read more than once per invocation.

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

textureDimensions(tex).

GLSL ES 3.00 (WebGL2) Supported

uvec2(textureSize(tex, 0)).

CPU oracle Stub

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.

In the guide

See also

Source

src/core/ir/node.ts, line 1929, at commit af54ddad5

Edit this page Report a problem