함수
이름 175개
셰이더에서 부르는 함수를 계열별로 묶고, 백엔드가 내는 코드를 함께 실었습니다.
이름마다 붙은 시그니처와 설명은 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
수학
exp2- Returns
2raised to the power ofx, componentwise over vectors. saturate- Clamps
xto the range [0, 1], componentwise over vectors. ldexp- Returns
x * 2^e: anf32or float vectorxwith ani32or integer vector exponenteof the same shape. quantizeToF16- Rounds
eto what an IEEE-754 binary16 can hold and returns it as anf32, so a shader can see the precision an f16 pipeline would give it without theshader-f16extension. 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 ofany(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
trueValuewherecondis true andfalseValuewhere 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
xraised to the power ofy, 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) timesLOG10E), forf32scalars only. log1p- Returns the natural logarithm of (1 plus
x), computed aslog(x + 1), forf32scalars only. expm1- Returns e raised to the power of
xminus 1, computed asexp(x) - 1, forf32scalars only. cbrt- Returns the cube root of
x, computed aspow(x, 1/3), forf32scalars only. hypot- Returns the Euclidean length of the vector formed from 2 or 3
f32scalar arguments, computed vialength, forf32scalars only. abs- Returns the absolute value of
x, componentwise over vectors. sign- Returns -1 if
xis 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
xto the nearest integer, with halfway cases rounding to the nearest even integer, componentwise over vectors. trunc- Returns
xtruncated toward zero, componentwise over vectors. fract- Returns the fractional part of
xasxminusfloor(x), in the range [0, 1), componentwise over vectors. mod- Returns the floor-modulo remainder of
xdivided byy, with the sign ofy, componentwise over vectors. min- Returns the lesser of
aandb, componentwise over vectors. max- Returns the greater of
aandb, componentwise over vectors. clamp- Clamps
xto the range [low, high], computed asmin(max(x, low), high), componentwise over vectors. mix- Returns
a * (1 - t) + b * t. step- Returns 0 when
xis less thanedge, and 1 otherwise. smoothstep- Applies Hermite interpolation between
edge0andedge1, clamped to[0, 1]. degrees- Converts
xfrom radians to degrees, multiplying by 180/π. radians- Converts
xfrom degrees to radians, multiplying by π/180. random- Returns an
f32in the range [0, 1) hashed from anf32,vec2orvec3seed, emitted asfract(sin(dot(seed, k)) * 43758.5453123).
기하 연산
reflect- Reflects the incident vector
iabout the normaln:i - 2 * dot(n, i) * n. refract- Refracts the incident vector
ithrough a surface with normalnand ratio of indiceseta; returns the zero vector on total internal reflection. faceForward- Returns
nifdot(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
mat4as anf32. 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
aandb, computed aslength(a - b). dot- Returns the dot product of two vectors: the sum of products of corresponding components.
cross- Computes the cross product of two
vec3values, returning avec3. 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
xin both directions,abs(dpdx(x)) + abs(dpdy(x)), componentwise over vectors. dpdxCoarse- The partial derivative of
xwith respect to the window x coordinate, computed at the coarser granularity. dpdxFine- The partial derivative of
xwith respect to the window x coordinate, computed at the finer granularity. dpdyCoarse- The partial derivative of
xwith respect to the window y coordinate, computed at the coarser granularity. dpdyFine- The partial derivative of
xwith respect to the window y coordinate, computed at the finer granularity. fwidthCoarseabs(dpdxCoarse(x)) + abs(dpdyCoarse(x)).fwidthFineabs(dpdxFine(x)) + abs(dpdyFine(x)).dpdx- Returns the partial derivative of
xwith respect to the window x coordinate, componentwise over vectors. dpdy- Returns the partial derivative of
xwith respect to the window y coordinate, componentwise over vectors.
비트 연산
dot4U8Packed- Reads both
u32arguments as four UNSIGNED bytes and sums the four products into au32. dot4I8Packed- Reads both
u32arguments as four SIGNED bytes and sums the four products into ani32, wrapping at 32 bits. countOneBits- The number of 1 bits in each component of a
u32ori32(or vector of them). reverseBits- Reverses the 32 bits of each component of a
u32ori32(or vector of them). countLeadingZeros- The number of leading 0 bits in each component of a
u32ori32(32 for zero). countTrailingZeros- The number of trailing 0 bits in each component of a
u32ori32(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 ani32(-1 for 0 and -1). firstTrailingBit- The position of the least significant 1 bit of a
u32ori32, or all ones (0xffffffff / -1) for zero. extractBits- Extracts
countbits ofestarting at bitoffset, sign-extended for ani32; the offset and count are clamped to the 32 bits as WGSL specifies. insertBits- Inserts the low
countbits ofnewbitsintoeat bitoffset; the offset and count are clamped to the 32 bits as WGSL specifies.
패킹
pack4x8unorm- Packs a
vec4of values in [0, 1] into the four bytes of au32, component 0 in the low byte. pack4xU8- Packs the low byte of each component of a
vec4uinto au32, component 0 in the low byte. pack4xI8- Packs the low byte of each component of a
vec4iinto au32, four bytes in a word. pack4xU8Clamp- Packs a
vec4uinto au32as four bytes, clamping each component into [0, 255] first. pack4xI8Clamp- Packs a
vec4iinto au32as four bytes, clamping each component into [-128, 127] first. unpack4xU8- Unpacks the four bytes of a
u32into avec4u, the low byte into component 0. unpack4xI8- Unpacks the four bytes of a
u32into avec4i, sign-extending each byte, the low byte into component 0. pack4x8snorm- Packs a
vec4of values in [-1, 1] into the four bytes of au32as signed bytes, component 0 in the low byte. unpack4x8unorm- Unpacks the four bytes of a
u32into avec4of values in [0, 1], the low byte into component 0. unpack4x8snorm- Unpacks the four bytes of a
u32into avec4of values in [-1, 1], reading each as a signed byte, the low byte into component 0. pack2x16float- Packs a
vec2into two IEEE-754 binary16 halves of au32, component 0 in the low 16 bits. pack2x16unorm- Packs a
vec2of values in [0, 1] into two 16-bit halves of au32, component 0 in the low 16 bits. pack2x16snorm- Packs a
vec2of values in [-1, 1] into two signed 16-bit halves of au32, component 0 in the low 16 bits. unpack2x16float- Unpacks the two binary16 halves of a
u32into avec2, the low 16 bits into component 0. unpack2x16unorm- Unpacks the two 16-bit halves of a
u32into avec2of values in [0, 1], the low 16 bits into component 0. unpack2x16snorm- Unpacks the two signed 16-bit halves of a
u32into avec2of values in [-1, 1], the low 16 bits into component 0.
캐스트
bitcast- Reads the same 32 bits as another type:
bitcast<u32>(x)on anf32andbitcast<f32>(x)on au32. bool- Converts a numeric scalar to
bool: true wherexis not zero, spelled as the comparex != 0. f32- Casts a number to
f32single-precision floating-point by inlining a literal value rounded to 32-bit precision. i32- Casts a number to
i32signed 32-bit integer by truncating toward zero. u32- Casts a number to
u32unsigned 32-bit integer by truncating toward zero.
텍스처와 스토리지
textureSample- Samples a float texture through the sampler
smpwith the implicit level of detail, in the fragment stage only: atuvon atexture_2d, by avec3direction on atexture_cube, by avec3coordinate on atexture_3d, by onef32on atexture_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 avec4in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage. textureGatherCompare- Compares the reference depth
refagainst the four texels a linear filter would blend at the coordinate on mip level 0, through the comparison samplersmp, and returns the four results (0 or 1 each) as avec4in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage. textureSampleLevel- Samples a float texture through the sampler
smpat an explicit miplevel, in any stage; the coordinate is avec2on atexture_2dand avec3on atexture_cubeor atexture_3d. textureSampleBias- Samples a float texture through the sampler
smpwith the implicit level of detail shifted bybias, in the fragment stage only; the coordinate is avec2on atexture_2dand avec3on atexture_cubeor atexture_3d. textureSampleGrad- Samples a float texture through the sampler
smpwith the explicit gradientsddxandddy, which have the width of the coordinate, in any stage. textureLoad- Reads one texel at the integer
coordand miplevelwithout filtering, by avec2ion atexture_2d, avec3ion atexture_3dand one integer on atexture_1d; a cube texture has no texel fetch on either target. textureNumSamples- Returns the number of samples per texel of a
texture_multisampled_2dor atexture_depth_multisampled_2das au32. textureSampleCompare- Compares the reference depth
refagainst the shadow map atuvthrough the comparison samplersmp, with the implicit level of detail, in the fragment stage only; returns anf32, how much of the filter footprint passed. textureSampleCompareLevel- Compares the reference depth
refagainst the shadow map atuvthrough the comparison samplersmpat mip level 0, in any stage; returns anf32, 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 avec3uon atexture_3d, or the width alone as au32on atexture_1d. textureNumLayers- Returns the number of layers of a
texture_2d_arrayor atexture_cube_arrayas au32. arrayLength- Returns the number of elements of a runtime-sized storage array as a
u32, read from the buffer the host bound;xs.lengthon 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>oratomic<i32>location in a read-write storage binding (atomicLoad(bins[i])). atomicStore- Writes
valueto an atomic location in a read-write storage binding (atomicStore(bins[i], 0)); returns nothing. atomicAdd- Adds
valueto the atomic location as one indivisible step and returns the value it held before (atomicAdd(bins[i], 1)). atomicSub- Subtracts
valuefrom the atomic location as one indivisible step and returns the value it held before. atomicMin- Stores the smaller of the atomic location and
valueas one indivisible step and returns the value it held before. atomicMax- Stores the larger of the atomic location and
valueas one indivisible step and returns the value it held before. atomicAnd- Stores the bitwise AND of the atomic location and
valueas one indivisible step and returns the value it held before. atomicOr- Stores the bitwise OR of the atomic location and
valueas one indivisible step and returns the value it held before. atomicXor- Stores the bitwise XOR of the atomic location and
valueas one indivisible step and returns the value it held before. atomicExchange- Stores
valuein 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
f32to the emulated doublef64.
생성자
mat2x2- Builds a
mat2x2, 2 columns of 2 components in column-major order, from 2vec2columns, 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 2vec2columns, 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 2vec3columns, 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 2vec4columns, 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 3vec2columns, 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 3vec3columns, 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 3vec3columns, 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 3vec4columns, 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 4vec2columns, 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 4vec3columns, 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 4vec4columns, 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 4vec4columns, 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 asmat2x2under WGSL's predeclared alias, in the same four ways: from 2vec2columns, 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 asmat2x3under WGSL's predeclared alias, in the same four ways: from 2vec3columns, 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 asmat2x4under WGSL's predeclared alias, in the same four ways: from 2vec4columns, 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 asmat3x2under WGSL's predeclared alias, in the same four ways: from 3vec2columns, 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 asmat3x3under WGSL's predeclared alias, in the same four ways: from 3vec3columns, 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 asmat3x4under WGSL's predeclared alias, in the same four ways: from 3vec4columns, 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 asmat4x2under WGSL's predeclared alias, in the same four ways: from 4vec2columns, 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 asmat4x3under WGSL's predeclared alias, in the same four ways: from 4vec3columns, 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 asmat4x4under WGSL's predeclared alias, in the same four ways: from 4vec4columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40). vec2- Builds a
vec2from two scalars or broadcasts a single scalar to both components. vec3- Builds a
vec3from three scalars, avec2and a scalar, or broadcasts a single scalar to all three components. vec4- Builds a
vec4from four scalars, avec3and a scalar, avec2and two scalars, or broadcasts a single scalar to all four components. vec2f- A two-component vector of
f32, same type asvec2. vec3f- A three-component vector of
f32, same type asvec3. vec4f- A four-component vector of
f32, same type asvec4. vec2i- Builds a
vec2ifrom twoi32scalars, broadcasts a singlei32scalar, or converts from avec2of a different element kind. vec3i- Builds a
vec3ifrom threei32scalars, avec2iand a scalar, broadcasts a singlei32scalar, or converts from avec3of a different element kind. vec4i- Builds a
vec4ifrom fouri32scalars, avec3iand a scalar, avec2iand two scalars, broadcasts a singlei32scalar, or converts from avec4of a different element kind. vec2u- Builds a
vec2ufrom twou32scalars, broadcasts a singleu32scalar, or converts from avec2of a different element kind. vec3u- Builds a
vec3ufrom threeu32scalars, avec2uand a scalar, broadcasts a singleu32scalar, or converts from avec3of a different element kind. vec4u- Builds a
vec4ufrom fouru32scalars, avec3uand a scalar, avec2uand two scalars, broadcasts a singleu32scalar, or converts from avec4of a different element kind. vec2b- Builds a
vec2bfrom twoboolscalars, broadcasts a singlebool, or converts from avec2of a different element kind (nonzero is true). vec3b- Builds a
vec3bfrom threeboolscalars, avec2band a scalar, broadcasts a singlebool, or converts from avec3of a different element kind. vec4b- Builds a
vec4bfrom fourboolscalars, avec3band a scalar, avec2band two scalars, broadcasts a singlebool, or converts from avec4of a different element kind. vec2f64- Builds a
vec2f64from twof64scalars or broadcasts a singlef64scalar to both components; emulated in software on both GPU targets. vec3f64- Builds a
vec3f64from threef64scalars, avec2f64and a scalar, or broadcasts a singlef64scalar; emulated in software on both GPU targets. vec4f64- Builds a
vec4f64from fourf64scalars, avec3f64and a scalar, avec2f64and two scalars, or broadcasts a singlef64scalar; 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 argumentsfill<T, N>(value). uniform- Declares a uniform binding of type T; use
declare const name: uniform<T>orconst name = uniform<T>(). storage- Declares a storage binding of type T; use
declare const name: storage<T>for read-only ordeclare const name: storage<T, "read_write">for read-write access.
이 페이지의 항목은 모두 고정된 커밋의 컴파일러에서 읽어 왔고, 여기서 직접 입력한 것은 없습니다.