textureNumSamples
Function
Multisampling stores several coverage samples in each texel. This query returns that sample count.
Compare examples
Textures can have different width and height but return the same sample count.
Example 1texture_multisampled_2d: 8 × 8; samples = 4
- Result
4
Example 2texture_multisampled_2d: 64 × 32; samples = 4
- Result
4
Example 3texture_depth_multisampled_2d: 8 × 8; samples = 4
- Result
4
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it when resolving a multisampled image by reading its individual samples.
Inputs and limits
This query requires a multisampled texture. Sample indices start at zero. The compiler has no GLSL ES multisample form.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Returns the number of samples per texel of a texture_multisampled_2d or a texture_depth_multisampled_2d as a u32.
Syntax
declare function textureNumSamples<E extends TextureElem = f32>( tex: texture_multisampled_2d<E> | texture_depth_multisampled_2d,): u32A signature may name a type the ambient file declares for its own use. These are those declarations.
TextureElemtype TextureElem = f32 | i32 | u32
Parameters
Return value
Description
A single-sample texture is refused. Compiles to textureNumSamples on WGSL; its GLSL lowering is not supported yet (Rule 10.5), so a module using it emits WGSL alone.
Targets
- WGSL
-
textureNumSamples(a) - GLSL ES 3.00
-
textureNumSamplesis not supported yet on the WebGL2 tier (Rule 10.5)