Skip to content

Intrinsics

Gustav Sterbrant edited this page Oct 14, 2024 · 2 revisions

GPULang provides a suite of intrinsics for things like math, texture sampling and more.

Texture sampling

A texture type can be of the sampled type which means it's a combined texture-sampler as provided from the client. There is a separate set of textureSample functions for them, since they don't require a sampler argument.

Name Effect
textureSample(*texture1D, *sampler, f32) Samples a texture a 1D texture
textureSample(*texture1DArray, *sampler, f32x2) Samples a texture a 1D array texture
textureSample(*texture2D, *sampler, f32x2) Samples a texture a 2D texture
textureSample(*texture2DMS, *sampler, f32x2) Samples a texture a 2D multisampled texture
textureSample(*texture2DArray, *sampler, f32x3) Samples a texture a 2D array texture
textureSample(*texture3D, *sampler, f32x3) Samples a texture a 3D texture
textureSample(*textureCube, *sampler, f32x3) Samples a texture a Cube texture
textureSample(*textureCubeArray, *sampler, f32x4) Samples a texture a Cube array texture
textureSample(*sampled texture1D, f32) Samples a sampled texture a 1D texture
textureSample(*sampled texture1DArray, f32x2) Samples a sampled texture a 1D array texture
textureSample(*sampled texture2D, f32x2) Samples a sampled texture a 2D texture
textureSample(*sampled texture2DMS, f32x2) Samples a sampled texture a 2D multisampled texture
textureSample(*sampled texture2DArray, f32x3) Samples a sampled texture a 2D array texture
textureSample(*sampled texture3D, f32x3) Samples a sampled texture a 3D texture
textureSample(*sampled textureCube, f32x3) Samples a sampled texture a Cube texture
textureSample(*sampled textureCubeArray, f32x4) Samples a sampled texture a Cube array texture

Atomics

Atomic values are always managed using a built-in enum called MemorySemantics to declare the ordering of atomic operations.

Name Effect
atomicLoad(scalar, literal MemorySemantics) scalar Loads an atomic value
atomicStore(scalar, scalar, literal MemorySemantics) scalar Stores an atomic value
Clone this wiki locally