textureDimensions
Function
Returns the size of the texture's base mip level: width and height as a vec2u, width, height and depth as a vec3u on a texture_3d, or the width alone as a u32 on a texture_1d.
The signature and the sentence under each name are the compiler's own text at commit 26de7be8.
Syntax
declare function textureDimensions<E extends TextureElem = f32>( tex: texture_2d<E> | texture_2d_array<E>, level?: number,): vec2udeclare function textureDimensions<E extends TextureElem = f32>( tex: texture_cube<E> | texture_cube_array<E>, level?: number,): vec2udeclare function textureDimensions<E extends TextureElem = f32>( tex: texture_3d<E>, level?: number,): vec3udeclare function textureDimensions<E extends TextureElem = f32>(tex: texture_1d<E>, level?: number): u32declare function textureDimensions<E extends TextureElem = f32>(tex: texture_multisampled_2d<E>): vec2udeclare function textureDimensions( tex: | texture_depth_2d | texture_depth_2d_array | texture_depth_cube | texture_depth_cube_array | texture_depth_multisampled_2d, level?: number,): vec2udeclare function textureDimensions<F extends StorageFormat, A extends StorageAccess>( tex: texture_storage_2d<F, A> | texture_storage_2d_array<F, A>,): vec2uA number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.
type f32 = number & { readonly [f32Tag]?: true }
A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.
A signature may name a type the ambient file declares for its own use. These are those declarations.
TextureElemtype TextureElem = f32 | i32 | u32StorageFormattype StorageFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm'StorageAccesstype StorageAccess = 'write' | 'read' | 'read_write'
Parameters
-
textexture_2d<E> | texture_2d_array<E>texture_cube<E> | texture_cube_array<E>texture_3d<E>texture_1d<E>texture_multisampled_2d<E>| texture_depth_2d | texture_depth_2d_array | texture_depth_cube | texture_depth_cube_array | texture_depth_multisampled_2dtexture_storage_2d<F, A> | texture_storage_2d_array<F, A> -
leveloptionalnumber
Return value
Description
On a cube texture it is the size of one face.
Targets
- WGSL
-
textureDimensions(a) - GLSL ES 3.00
-
uvec2(textureSize(a, 0))