함수
이 페이지에서

함수

이름 175개

셰이더에서 부르는 함수를 계열별로 묶고, 백엔드가 내는 코드를 함께 실었습니다.

이름마다 붙은 시그니처와 설명은 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

수학

exp2
Returns 2 raised to the power of x, componentwise over vectors.
saturate
Clamps x to the range [0, 1], componentwise over vectors.
ldexp
Returns x * 2^e: an f32 or float vector x with an i32 or integer vector exponent e of the same shape.
quantizeToF16
Rounds e to what an IEEE-754 binary16 can hold and returns it as an f32, so a shader can see the precision an f16 pipeline would give it without the shader-f16 extension.
fma
Returns a * b + c, componentwise over vectors.
any
Whether any component of a vector of bools is true: any(a < b).
all
Whether every component of a vector of bools is true: all(a === b).
none
Whether no element of a fixed-size array passes the test: none(xs, (x) => x < 0.), the negation of any(xs, pred).
sum
The sum of the elements of a fixed-size array of numbers or vectors, sum(xs), unrolled into one addition per element.
zip
A fixed-size array built from two of one length, element by element: zip(xs, ys, (a, b) => a * b).
select
Returns trueValue where cond is true and falseValue where it is false, in WGSL's argument order: the condition comes last.
sin
Returns the sine of x (in radians), componentwise over vectors.
cos
Returns the cosine of x (in radians), componentwise over vectors.
tan
Returns the tangent of x (in radians), componentwise over vectors.
asin
Returns the arcsine of x (in radians), componentwise over vectors.
acos
Returns the arccosine of x (in radians), componentwise over vectors.
atan
Returns the arctangent of x (in radians), componentwise over vectors.
atan2
Returns the arctangent of y/x (in radians), using the signs of both arguments to determine the quadrant, taking arguments in the order (y, x).
sinh
Returns the hyperbolic sine of x, componentwise over vectors.
cosh
Returns the hyperbolic cosine of x, componentwise over vectors.
tanh
Returns the hyperbolic tangent of x, componentwise over vectors.
asinh
Returns the inverse hyperbolic sine of x, componentwise over vectors.
acosh
Returns the inverse hyperbolic cosine of x, componentwise over vectors.
atanh
Returns the inverse hyperbolic tangent of x, componentwise over vectors.
exp
Returns the exponential function (e raised to the power of x), componentwise over vectors.
log
Returns the natural logarithm of x, componentwise over vectors.
log2
Returns the base-2 logarithm of x, componentwise over vectors.
pow
Returns x raised to the power of y, componentwise over vectors.
sqrt
Returns the square root of x, componentwise over vectors.
inverseSqrt
Returns the reciprocal of the square root of x (1/sqrt(x)), componentwise over vectors.
log10
Returns the base-10 logarithm of x (log(x) times LOG10E), for f32 scalars only.
log1p
Returns the natural logarithm of (1 plus x), computed as log(x + 1), for f32 scalars only.
expm1
Returns e raised to the power of x minus 1, computed as exp(x) - 1, for f32 scalars only.
cbrt
Returns the cube root of x, computed as pow(x, 1/3), for f32 scalars only.
hypot
Returns the Euclidean length of the vector formed from 2 or 3 f32 scalar arguments, computed via length, for f32 scalars only.
abs
Returns the absolute value of x, componentwise over vectors.
sign
Returns -1 if x is negative, 1 if positive, and 0 if zero, componentwise over vectors.
floor
Returns the largest integer not greater than x, componentwise over vectors.
ceil
Returns the smallest integer not less than x, componentwise over vectors.
round
Rounds x to the nearest integer, with halfway cases rounding to the nearest even integer, componentwise over vectors.
trunc
Returns x truncated toward zero, componentwise over vectors.
fract
Returns the fractional part of x as x minus floor(x), in the range [0, 1), componentwise over vectors.
mod
Returns the floor-modulo remainder of x divided by y, with the sign of y, componentwise over vectors.
min
Returns the lesser of a and b, componentwise over vectors.
max
Returns the greater of a and b, componentwise over vectors.
clamp
Clamps x to the range [low, high], computed as min(max(x, low), high), componentwise over vectors.
mix
Returns a * (1 - t) + b * t.
step
Returns 0 when x is less than edge, and 1 otherwise.
smoothstep
Applies Hermite interpolation between edge0 and edge1, clamped to [0, 1].
degrees
Converts x from radians to degrees, multiplying by 180/π.
radians
Converts x from degrees to radians, multiplying by π/180.
random
Returns an f32 in the range [0, 1) hashed from an f32, vec2 or vec3 seed, emitted as fract(sin(dot(seed, k)) * 43758.5453123).

기하 연산

reflect
Reflects the incident vector i about the normal n: i - 2 * dot(n, i) * n.
refract
Refracts the incident vector i through a surface with normal n and ratio of indices eta; returns the zero vector on total internal reflection.
faceForward
Returns n if dot(nref, i) is negative, else -n: the normal that faces the incident vector.
transpose
Returns the transpose of a mat4.
determinant
Returns the determinant of a mat4 as an f32.
length
Returns the length (magnitude) of a vector, computed as the square root of the sum of squared components.
distance
Returns the Euclidean distance between a and b, computed as length(a - b).
dot
Returns the dot product of two vectors: the sum of products of corresponding components.
cross
Computes the cross product of two vec3 values, returning a vec3.
normalize
Returns a unit vector in the same direction as the input, computed by dividing each component by the vector's length.

화면 공간 미분

fwidth
Returns the sum of the absolute screen-space derivatives of x in both directions, abs(dpdx(x)) + abs(dpdy(x)), componentwise over vectors.
dpdxCoarse
The partial derivative of x with respect to the window x coordinate, computed at the coarser granularity.
dpdxFine
The partial derivative of x with respect to the window x coordinate, computed at the finer granularity.
dpdyCoarse
The partial derivative of x with respect to the window y coordinate, computed at the coarser granularity.
dpdyFine
The partial derivative of x with respect to the window y coordinate, computed at the finer granularity.
fwidthCoarse
abs(dpdxCoarse(x)) + abs(dpdyCoarse(x)).
fwidthFine
abs(dpdxFine(x)) + abs(dpdyFine(x)).
dpdx
Returns the partial derivative of x with respect to the window x coordinate, componentwise over vectors.
dpdy
Returns the partial derivative of x with respect to the window y coordinate, componentwise over vectors.

비트 연산

dot4U8Packed
Reads both u32 arguments as four UNSIGNED bytes and sums the four products into a u32.
dot4I8Packed
Reads both u32 arguments as four SIGNED bytes and sums the four products into an i32, wrapping at 32 bits.
countOneBits
The number of 1 bits in each component of a u32 or i32 (or vector of them).
reverseBits
Reverses the 32 bits of each component of a u32 or i32 (or vector of them).
countLeadingZeros
The number of leading 0 bits in each component of a u32 or i32 (32 for zero).
countTrailingZeros
The number of trailing 0 bits in each component of a u32 or i32 (32 for zero).
firstLeadingBit
The position of the most significant 1 bit of a u32 (0xffffffff for zero), or of the most significant bit that differs from the sign bit of an i32 (-1 for 0 and -1).
firstTrailingBit
The position of the least significant 1 bit of a u32 or i32, or all ones (0xffffffff / -1) for zero.
extractBits
Extracts count bits of e starting at bit offset, sign-extended for an i32; the offset and count are clamped to the 32 bits as WGSL specifies.
insertBits
Inserts the low count bits of newbits into e at bit offset; the offset and count are clamped to the 32 bits as WGSL specifies.

패킹

pack4x8unorm
Packs a vec4 of values in [0, 1] into the four bytes of a u32, component 0 in the low byte.
pack4xU8
Packs the low byte of each component of a vec4u into a u32, component 0 in the low byte.
pack4xI8
Packs the low byte of each component of a vec4i into a u32, four bytes in a word.
pack4xU8Clamp
Packs a vec4u into a u32 as four bytes, clamping each component into [0, 255] first.
pack4xI8Clamp
Packs a vec4i into a u32 as four bytes, clamping each component into [-128, 127] first.
unpack4xU8
Unpacks the four bytes of a u32 into a vec4u, the low byte into component 0.
unpack4xI8
Unpacks the four bytes of a u32 into a vec4i, sign-extending each byte, the low byte into component 0.
pack4x8snorm
Packs a vec4 of values in [-1, 1] into the four bytes of a u32 as signed bytes, component 0 in the low byte.
unpack4x8unorm
Unpacks the four bytes of a u32 into a vec4 of values in [0, 1], the low byte into component 0.
unpack4x8snorm
Unpacks the four bytes of a u32 into a vec4 of values in [-1, 1], reading each as a signed byte, the low byte into component 0.
pack2x16float
Packs a vec2 into two IEEE-754 binary16 halves of a u32, component 0 in the low 16 bits.
pack2x16unorm
Packs a vec2 of values in [0, 1] into two 16-bit halves of a u32, component 0 in the low 16 bits.
pack2x16snorm
Packs a vec2 of values in [-1, 1] into two signed 16-bit halves of a u32, component 0 in the low 16 bits.
unpack2x16float
Unpacks the two binary16 halves of a u32 into a vec2, the low 16 bits into component 0.
unpack2x16unorm
Unpacks the two 16-bit halves of a u32 into a vec2 of values in [0, 1], the low 16 bits into component 0.
unpack2x16snorm
Unpacks the two signed 16-bit halves of a u32 into a vec2 of values in [-1, 1], the low 16 bits into component 0.

캐스트

bitcast
Reads the same 32 bits as another type: bitcast<u32>(x) on an f32 and bitcast<f32>(x) on a u32.
bool
Converts a numeric scalar to bool: true where x is not zero, spelled as the compare x != 0.
f32
Casts a number to f32 single-precision floating-point by inlining a literal value rounded to 32-bit precision.
i32
Casts a number to i32 signed 32-bit integer by truncating toward zero.
u32
Casts a number to u32 unsigned 32-bit integer by truncating toward zero.

텍스처와 스토리지

textureSample
Samples a float texture through the sampler smp with the implicit level of detail, in the fragment stage only: at uv on a texture_2d, by a vec3 direction on a texture_cube, by a vec3 coordinate on a texture_3d, by one f32 on a texture_1d, and on an array texture the argument after the coordinate picks the layer.
textureGather
Reads one channel from the four texels a linear filter would blend at the coordinate on mip level 0, through the sampler smp, and returns them as a vec4 in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.
textureGatherCompare
Compares the reference depth ref against the four texels a linear filter would blend at the coordinate on mip level 0, through the comparison sampler smp, and returns the four results (0 or 1 each) as a vec4 in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.
textureSampleLevel
Samples a float texture through the sampler smp at an explicit mip level, in any stage; the coordinate is a vec2 on a texture_2d and a vec3 on a texture_cube or a texture_3d.
textureSampleBias
Samples a float texture through the sampler smp with the implicit level of detail shifted by bias, in the fragment stage only; the coordinate is a vec2 on a texture_2d and a vec3 on a texture_cube or a texture_3d.
textureSampleGrad
Samples a float texture through the sampler smp with the explicit gradients ddx and ddy, which have the width of the coordinate, in any stage.
textureLoad
Reads one texel at the integer coord and mip level without filtering, by a vec2i on a texture_2d, a vec3i on a texture_3d and one integer on a texture_1d; a cube texture has no texel fetch on either target.
textureNumSamples
Returns the number of samples per texel of a texture_multisampled_2d or a texture_depth_multisampled_2d as a u32.
textureSampleCompare
Compares the reference depth ref against the shadow map at uv through the comparison sampler smp, with the implicit level of detail, in the fragment stage only; returns an f32, how much of the filter footprint passed.
textureSampleCompareLevel
Compares the reference depth ref against the shadow map at uv through the comparison sampler smp at mip level 0, in any stage; returns an f32, how much of the filter footprint passed.
textureStore
Writes one texel to a storage texture at the integer coord, on a binding declared "write" or "read_write"; returns nothing.
textureDimensions
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.
textureNumLayers
Returns the number of layers of a texture_2d_array or a texture_cube_array as a u32.
arrayLength
Returns the number of elements of a runtime-sized storage array as a u32, read from the buffer the host bound; xs.length on such an array reads the same thing.

원자적 연산

atomicCompareExchangeWeak
Stores the third argument into the atomic location only when it holds the second, as one indivisible step.
atomicLoad
Reads the value of an atomic<u32> or atomic<i32> location in a read-write storage binding (atomicLoad(bins[i])).
atomicStore
Writes value to an atomic location in a read-write storage binding (atomicStore(bins[i], 0)); returns nothing.
atomicAdd
Adds value to the atomic location as one indivisible step and returns the value it held before (atomicAdd(bins[i], 1)).
atomicSub
Subtracts value from the atomic location as one indivisible step and returns the value it held before.
atomicMin
Stores the smaller of the atomic location and value as one indivisible step and returns the value it held before.
atomicMax
Stores the larger of the atomic location and value as one indivisible step and returns the value it held before.
atomicAnd
Stores the bitwise AND of the atomic location and value as one indivisible step and returns the value it held before.
atomicOr
Stores the bitwise OR of the atomic location and value as one indivisible step and returns the value it held before.
atomicXor
Stores the bitwise XOR of the atomic location and value as one indivisible step and returns the value it held before.
atomicExchange
Stores value in the atomic location as one indivisible step and returns the value it held before.

배리어

textureBarrier
Holds every invocation of the workgroup until all have arrived, ordering their writes to the TEXTURE address space.
workgroupUniformLoad
Reads one value out of workgroup memory with a barrier on each side, so every invocation of the workgroup gets the same one.
workgroupBarrier
Waits until every invocation of the workgroup has reached this line, and makes every write to workgroup memory before it visible to every invocation after it.
storageBarrier
Waits until every invocation of the workgroup has reached this line, and makes every write to storage before it visible to every invocation after it.

에뮬레이션 배정밀도

f64
Widens an f32 to the emulated double f64.

생성자

mat2x2
Builds a mat2x2, 2 columns of 2 components in column-major order, from 2 vec2 columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2
Builds a mat2x2, 2 columns of 2 components in column-major order, from 2 vec2 columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2x3
Builds a mat2x3, 2 columns of 3 components in column-major order, from 2 vec3 columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2x4
Builds a mat2x4, 2 columns of 4 components in column-major order, from 2 vec4 columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x2
Builds a mat3x2, 3 columns of 2 components in column-major order, from 3 vec2 columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x3
Builds a mat3x3, 3 columns of 3 components in column-major order, from 3 vec3 columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3
Builds a mat3x3, 3 columns of 3 components in column-major order, from 3 vec3 columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x4
Builds a mat3x4, 3 columns of 4 components in column-major order, from 3 vec4 columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x2
Builds a mat4x2, 4 columns of 2 components in column-major order, from 4 vec2 columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x3
Builds a mat4x3, 4 columns of 3 components in column-major order, from 4 vec3 columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x4
Builds a mat4x4, 4 columns of 4 components in column-major order, from 4 vec4 columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4
Builds a mat4x4, 4 columns of 4 components in column-major order, from 4 vec4 columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2x2f
Builds a mat2x2f, the same type as mat2x2 under WGSL's predeclared alias, in the same four ways: from 2 vec2 columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2x3f
Builds a mat2x3f, the same type as mat2x3 under WGSL's predeclared alias, in the same four ways: from 2 vec3 columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat2x4f
Builds a mat2x4f, the same type as mat2x4 under WGSL's predeclared alias, in the same four ways: from 2 vec4 columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x2f
Builds a mat3x2f, the same type as mat3x2 under WGSL's predeclared alias, in the same four ways: from 3 vec2 columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x3f
Builds a mat3x3f, the same type as mat3x3 under WGSL's predeclared alias, in the same four ways: from 3 vec3 columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat3x4f
Builds a mat3x4f, the same type as mat3x4 under WGSL's predeclared alias, in the same four ways: from 3 vec4 columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x2f
Builds a mat4x2f, the same type as mat4x2 under WGSL's predeclared alias, in the same four ways: from 4 vec2 columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x3f
Builds a mat4x3f, the same type as mat4x3 under WGSL's predeclared alias, in the same four ways: from 4 vec3 columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
mat4x4f
Builds a mat4x4f, the same type as mat4x4 under WGSL's predeclared alias, in the same four ways: from 4 vec4 columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
vec2
Builds a vec2 from two scalars or broadcasts a single scalar to both components.
vec3
Builds a vec3 from three scalars, a vec2 and a scalar, or broadcasts a single scalar to all three components.
vec4
Builds a vec4 from four scalars, a vec3 and a scalar, a vec2 and two scalars, or broadcasts a single scalar to all four components.
vec2f
A two-component vector of f32, same type as vec2.
vec3f
A three-component vector of f32, same type as vec3.
vec4f
A four-component vector of f32, same type as vec4.
vec2i
Builds a vec2i from two i32 scalars, broadcasts a single i32 scalar, or converts from a vec2 of a different element kind.
vec3i
Builds a vec3i from three i32 scalars, a vec2i and a scalar, broadcasts a single i32 scalar, or converts from a vec3 of a different element kind.
vec4i
Builds a vec4i from four i32 scalars, a vec3i and a scalar, a vec2i and two scalars, broadcasts a single i32 scalar, or converts from a vec4 of a different element kind.
vec2u
Builds a vec2u from two u32 scalars, broadcasts a single u32 scalar, or converts from a vec2 of a different element kind.
vec3u
Builds a vec3u from three u32 scalars, a vec2u and a scalar, broadcasts a single u32 scalar, or converts from a vec3 of a different element kind.
vec4u
Builds a vec4u from four u32 scalars, a vec3u and a scalar, a vec2u and two scalars, broadcasts a single u32 scalar, or converts from a vec4 of a different element kind.
vec2b
Builds a vec2b from two bool scalars, broadcasts a single bool, or converts from a vec2 of a different element kind (nonzero is true).
vec3b
Builds a vec3b from three bool scalars, a vec2b and a scalar, broadcasts a single bool, or converts from a vec3 of a different element kind.
vec4b
Builds a vec4b from four bool scalars, a vec3b and a scalar, a vec2b and two scalars, broadcasts a single bool, or converts from a vec4 of a different element kind.
vec2f64
Builds a vec2f64 from two f64 scalars or broadcasts a single f64 scalar to both components; emulated in software on both GPU targets.
vec3f64
Builds a vec3f64 from three f64 scalars, a vec2f64 and a scalar, or broadcasts a single f64 scalar; emulated in software on both GPU targets.
vec4f64
Builds a vec4f64 from four f64 scalars, a vec3f64 and a scalar, a vec2f64 and two scalars, or broadcasts a single f64 scalar; emulated in software on both GPU targets.

배열과 바인딩

array
Builds an array<T, N> from exactly N values of type T.
fill
Creates an array<T, N> where every element is the given value; requires type arguments fill<T, N>(value).
uniform
Declares a uniform binding of type T; use declare const name: uniform<T> or const name = uniform<T>().
storage
Declares a storage binding of type T; use declare const name: storage<T> for read-only or declare const name: storage<T, "read_write"> for read-write access.

이 페이지의 항목은 모두 고정된 커밋의 컴파일러에서 읽어 왔고, 여기서 직접 입력한 것은 없습니다.

이 페이지 편집 문제 보고