내장 함수
이 페이지에서

내장 함수

내장 함수는 GPU에 이미 들어 있는 함수입니다. 호출은 컴파일러 안에서 중립 이름 하나로 다니고, 백엔드가 타깃마다 자기 표기를 씁니다. 그래서 한 번 작성한 호출이 두 벌로 생성됩니다. 레지스트리에 담긴 이름은 163개입니다.

한 행을 읽는 법

첫째 칸은 호출이 달고 다니는 이름이며, 인자가 들어갈 자리마다 플레이스홀더를 하나씩 넣었습니다. 다음 두 칸은 WGSL 백엔드와 GLSL ES 3.00 백엔드가 그 호출에 대해 쓰는 코드로, 고정된 커밋의 컴파일러 표기표를 그대로 실행해 얻었습니다. 이 가운데 44개는 두 타깃에서 표기가 같고, 43개는 GLSL ES 3.00에 형태가 아예 없어 그 칸에 컴파일러가 낸 메시지를 싣습니다. 27개는 Math. 이름으로도 부를 수 있으며, 수학과 캐스트 표의 마지막 칸이 그 이름을 보여 줍니다.

이 이름 가운데 몇 개는 컴파일러가 고르는 것이라 손으로 적지 않습니다. 레이어 텍스처 읽기, 깊이 비교, 스토리지 fetch, 부호 없는 좌표로 하는 텍셀 읽기는 저마다 자기 이름을 받습니다. 그래야 호출의 인자 순서가 어떤 텍스처에 쓰였는지에 따라 달라지지 않습니다. 부호 없는 값의 abs와 정수 dot도 따로 이름을 받습니다. GLSL ES 3.00에는 둘 다 그 타입의 오버로드가 없기 때문입니다.

파일이 직접 선언한 이름

파일이 선언한 함수가 같은 이름의 내장 함수를 이깁니다. 그런 이름은 내장 함수가 되기 전에는 작성자의 함수를 가리켰고, 기능을 더한다고 해서 이미 돌아가던 프로그램의 뜻이 바뀌면 안 되기 때문입니다.

수학

TypeShadeWGSLGLSL ES 3.00Math 이름
abs(a)
abs(a)
Math.abs
absU(a)
abs(a)
a
acos(a)
acos(a)
Math.acos
acosh(a)
acosh(a)
Math.acosh
all(a)
all(a)
any(a)
any(a)
asin(a)
asin(a)
Math.asin
asinh(a)
asinh(a)
Math.asinh
atan(a)
atan(a)
Math.atan
atan2(a, b)
atan(a, b)
Math.atan2
atanh(a)
atanh(a)
Math.atanh
ceil(a)
ceil(a)
Math.ceil
clamp(a, b, c)
clamp(a, b, c)
cos(a)
cos(a)
Math.cos
cosh(a)
cosh(a)
Math.cosh
degrees(a)
degrees(a)
exp(a)
exp(a)
Math.exp
exp2(a)
exp2(a)
floor(a)
floor(a)
Math.floor
fma(a, b, c)
((a) * (b) + (c))
fract(a)
fract(a)
inverseSqrt(a)
inversesqrt(a)
ldexp(a, b)
(a * intBitsToFloat(((b >> 1) + 127) << 23) * intBitsToFloat(((b - (b >> 1)) + 127) << 23))
log(a)
log(a)
Math.log
log2(a)
log2(a)
Math.log2
max(a, b)
max(a, b)
Math.max
min(a, b)
min(a, b)
Math.min
mix(a, b, c)
mix(a, b, c)
(a - b * floor(a / b))
mod(a, b)
pow(a, b)
pow(a, b)
Math.pow
quantizeToF16(a)
unpackHalf2x16(packHalf2x16(vec2(a, 0.0))).x
quantizeToF16Vec2(a)
quantizeToF16(a)
vec2(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x)
quantizeToF16Vec3(a)
quantizeToF16(a)
vec3(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.z, 0.0))).x)
quantizeToF16Vec4(a)
quantizeToF16(a)
vec4(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.z, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.w, 0.0))).x)
radians(a)
radians(a)
round(a)
roundEven(a)
Math.round
saturate(a)
clamp(a, 0.0, 1.0)
select(a, b, c)
(c ? b : a)
sign(a)
sign(a)
Math.sign
sin(a)
sin(a)
Math.sin
sinh(a)
sinh(a)
Math.sinh
smoothstep(a, b, c)
smoothstep(a, b, c)
sqrt(a)
sqrt(a)
Math.sqrt
step(a, b)
step(a, b)
tan(a)
tan(a)
Math.tan
tanh(a)
tanh(a)
Math.tanh
trunc(a)
trunc(a)
Math.trunc

기하 연산

TypeShadeWGSLGLSL ES 3.00
cross(a, b)
cross(a, b)
determinant(a)
determinant(a)
distance(a, b)
distance(a, b)
dot(a, b)
dot(a, b)
dotI(a, b)
dot(a, b)
_idot(a, b)
dotU(a, b)
dot(a, b)
_idot(a, b)
faceForward(a, b, c)
faceforward(a, b, c)
length(a)
length(a)
normalize(a)
normalize(a)
reflect(a, b)
reflect(a, b)
refract(a, b, c)
refract(a, b, c)
transpose(a)
transpose(a)

화면 공간 미분

TypeShadeWGSLGLSL ES 3.00
dpdx(a)
dFdx(a)
dpdxCoarse(a)
dFdx(a)
dpdxFine(a)
dFdx(a)
dpdy(a)
dFdy(a)
dpdyCoarse(a)
dFdy(a)
dpdyFine(a)
dFdy(a)
fwidth(a)
fwidth(a)
fwidthCoarse(a)
fwidth(a)
fwidthFine(a)
fwidth(a)

비트 연산

TypeShadeWGSLGLSL ES 3.00
countLeadingZeros(a)
_clz(a)
countOneBits(a)
_popcnt(a)
countTrailingZeros(a)
_ctz(a)
dot4I8Packed(a, b)

dot4I8Packed has no GLSL ES 3.00 form

dot4U8Packed(a, b)

dot4U8Packed has no GLSL ES 3.00 form

extractBits(a, b, c)
_xbits(a, b, c)
firstLeadingBit(a)
_msb(a)
firstTrailingBit(a)
_lsb(a)
insertBits(a, b, c, d)
_ibits(a, b, c, d)
reverseBits(a)
_brev(a)

GLSL ES 3.00에는 비트 내장 함수가 하나도 없습니다. 그래서 위 칸은 GLSL 생성기가 정의하는 작은 함수를 부릅니다. 그 정의는 해당 타깃에 있는 시프트와 마스크, 비교만으로 쓰여 있습니다. 하나도 부르지 않는 모듈은 정의도 싣지 않습니다.

패킹

TypeShadeWGSLGLSL ES 3.00
pack2x16float(a)
packHalf2x16(a)
pack2x16snorm(a)
packSnorm2x16(a)
pack2x16unorm(a)
packUnorm2x16(a)
pack4x8snorm(a)
(uint(int(floor(0.5 + clamp(a.x, -1.0, 1.0) * 127.0)) & 0xFF) | (uint(int(floor(0.5 + clamp(a.y, -1.0, 1.0) * 127.0)) & 0xFF) << 8) | (uint(int(floor(0.5 + clamp(a.z, -1.0, 1.0) * 127.0)) & 0xFF) << 16) | (uint(int(floor(0.5 + clamp(a.w, -1.0, 1.0) * 127.0)) & 0xFF) << 24))
pack4x8unorm(a)
(uint(floor(0.5 + clamp(a.x, 0.0, 1.0) * 255.0)) | (uint(floor(0.5 + clamp(a.y, 0.0, 1.0) * 255.0)) << 8) | (uint(floor(0.5 + clamp(a.z, 0.0, 1.0) * 255.0)) << 16) | (uint(floor(0.5 + clamp(a.w, 0.0, 1.0) * 255.0)) << 24))
pack4xI8(a)

pack4xI8 has no GLSL ES 3.00 form

pack4xI8Clamp(a)

pack4xI8Clamp has no GLSL ES 3.00 form

pack4xU8(a)

pack4xU8 has no GLSL ES 3.00 form

pack4xU8Clamp(a)

pack4xU8Clamp has no GLSL ES 3.00 form

unpack2x16float(a)
unpackHalf2x16(a)
unpack2x16snorm(a)
unpackSnorm2x16(a)
unpack2x16unorm(a)
unpackUnorm2x16(a)
unpack4x8snorm(a)
max(vec4(ivec4(uvec4(a, a >> 8, a >> 16, a >> 24) << 24) >> 24) / 127.0, vec4(-1.0))
unpack4x8unorm(a)
(vec4(uvec4(a, a >> 8, a >> 16, a >> 24) & 0xFFu) / 255.0)
unpack4xI8(a)

unpack4xI8 has no GLSL ES 3.00 form

unpack4xU8(a)

unpack4xU8 has no GLSL ES 3.00 form

캐스트

TypeShadeWGSLGLSL ES 3.00Math 이름
bitcast<f32>(a)
uintBitsToFloat(a)
bitcast<u32>(a)
floatBitsToUint(a)
f32(a)
float(a)
Math.fround
i32(a)
int(a)
u32(a)
uint(a)

텍스처와 스토리지

TypeShadeWGSLGLSL ES 3.00
arrayLength(&a)

arrayLength has no GLSL ES 3.00 spelling (no storage buffers, no runtime-sized arrays)

storageFetchF32(a, b)
storageFetchF32(a, b)
_sfetch(a, int(b))
storageFetchI32(a, b)
storageFetchI32(a, b)
_sfetchI(a, int(b))
storageFetchU32(a, b)
storageFetchU32(a, b)
_sfetchU(a, int(b))
textureDimensions(a)
uvec2(textureSize(a, 0))
textureDimensions1d(a)
textureDimensions(a)

textureDimensions on a texture_1d has no GLSL ES 3.00 spelling

textureDimensions3d(a)
textureDimensions(a)
uvec3(textureSize(a, 0))
textureDimensionsMs(a)
textureDimensions(a)

textureDimensions on a multisampled texture has no GLSL ES 3.00 spelling

textureGather(a, b, c, d)

textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureGatherArray(a, b, c, d, e)
textureGather(a, b, c, d, e)

textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureGatherCompare(a, b, c, d)

textureGatherCompare has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureGatherCompareArray(a, b, c, d, e)
textureGatherCompare(a, b, c, d, e)

textureGatherCompare has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureGatherDepth(a, b, c)
textureGather(a, b, c)

textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureGatherDepthArray(a, b, c, d)
textureGather(a, b, c, d)

textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

textureLoad(a, b, c)
texelFetch(a, b, int(c))
textureLoad3dU(a, b, c)
textureLoad(a, b, c)
texelFetch(a, ivec3(b), int(c))
textureLoadArray(a, b, c, d)
textureLoad(a, b, c, d)
texelFetch(a, ivec3(b, int(c)), int(d))
textureLoadArrayU(a, b, c, d)
textureLoad(a, b, c, d)
texelFetch(a, ivec3(ivec2(b), int(c)), int(d))
textureLoadDepthMs(a, b, c)
textureLoad(a, b, c)

a multisampled depth load has no GLSL ES 3.00 spelling (sampler2DMS is ES 3.10)

textureLoadMs(a, b, c)
textureLoad(a, b, c)

a multisampled load has no GLSL ES 3.00 spelling (sampler2DMS is ES 3.10)

textureLoadU(a, b, c)
textureLoad(a, b, c)
texelFetch(a, ivec2(b), int(c))
textureNumLayers(a)
uint(textureSize(a, 0).z)
textureNumLayersStorage(a)
textureNumLayers(a)

a storage texture has no GLSL ES 3.00 spelling (image load/store is ES 3.10)

textureNumSamples(a)

textureNumSamples has no GLSL ES 3.00 spelling (textureSamples is ES 3.10)

textureSample(a, b, c)
texture(a, c)
textureSampleArray(a, b, c, d)
textureSample(a, b, c, d)
texture(a, vec3(c, float(d)))
textureSampleBias(a, b, c, d)
texture(a, c, d)
textureSampleBiasArray(a, b, c, d, e)
textureSampleBias(a, b, c, d, e)
texture(a, vec3(c, float(d)), e)
textureSampleBiasCubeArray(a, b, c, d, e)
textureSampleBias(a, b, c, d, e)

textureSampleBias on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureSampleCompare(a, b, c, d)
texture(a, vec3(c, d))
textureSampleCompareArray(a, b, c, d, e)
textureSampleCompare(a, b, c, d, e)
texture(a, vec4(c, float(d), e))
textureSampleCompareCube(a, b, c, d)
textureSampleCompare(a, b, c, d)
texture(a, vec4(c, d))
textureSampleCompareCubeArray(a, b, c, d, e)
textureSampleCompare(a, b, c, d, e)

textureSampleCompare on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureSampleCompareLevel(a, b, c, d)
textureLod(a, vec3(c, d), 0.0)
textureSampleCompareLevelArray(a, b, c, d, e)
textureSampleCompareLevel(a, b, c, d, e)
textureGrad(a, vec4(c, float(d), e), vec2(0.0), vec2(0.0))
textureSampleCompareLevelCube(a, b, c, d)
textureSampleCompareLevel(a, b, c, d)
textureGrad(a, vec4(c, d), vec3(0.0), vec3(0.0))
textureSampleCompareLevelCubeArray(a, b, c, d, e)
textureSampleCompareLevel(a, b, c, d, e)

textureSampleCompareLevel on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureSampleCubeArray(a, b, c, d)
textureSample(a, b, c, d)

textureSample on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureSampleGrad(a, b, c, d, e)
textureGrad(a, c, d, e)
textureSampleGradArray(a, b, c, d, e, f)
textureSampleGrad(a, b, c, d, e, f)
textureGrad(a, vec3(c, float(d)), e, f)
textureSampleGradCubeArray(a, b, c, d, e, f)
textureSampleGrad(a, b, c, d, e, f)

textureSampleGrad on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureSampleLevel(a, b, c, d)
textureLod(a, c, d)
textureSampleLevelArray(a, b, c, d, e)
textureSampleLevel(a, b, c, d, e)
textureLod(a, vec3(c, float(d)), e)
textureSampleLevelCubeArray(a, b, c, d, e)
textureSampleLevel(a, b, c, d, e)

textureSampleLevel on a cube array has no GLSL ES 3.00 spelling (no samplerCubeArray)

textureStore(a, b, c)

textureStore has no GLSL ES 3.00 spelling (image load/store is ES 3.10)

원자적 연산

TypeShadeWGSLGLSL ES 3.00
atomicAdd(&a, b)

atomicAdd has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicAnd(&a, b)

atomicAnd has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicCompareExchangeWeak(&a, b, c)

atomicCompareExchangeWeak has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicExchange(&a, b)

atomicExchange has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicLoad(&a)

atomicLoad has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicMax(&a, b)

atomicMax has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicMin(&a, b)

atomicMin has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicOr(&a, b)

atomicOr has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicStore(&a, b)

atomicStore has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicSub(&a, b)

atomicSub has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

atomicXor(&a, b)

atomicXor has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

배리어

TypeShadeWGSLGLSL ES 3.00
storageBarrier()

storageBarrier has no GLSL ES 3.00 spelling (no compute stage)

textureBarrier()

textureBarrier has no GLSL ES 3.00 spelling (no compute stage)

workgroupBarrier()

workgroupBarrier has no GLSL ES 3.00 spelling (no compute stage)

workgroupUniformLoad(&a)

workgroupUniformLoad has no GLSL ES 3.00 spelling (no compute stage)

에뮬레이션 배정밀도

TypeShadeWGSLGLSL ES 3.00

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

f64Guard()
textureLoad(_fp64, vec2<i32>(0, 0), 0).x
texelFetch(_fp64, ivec2(0, 0), 0).x

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

두 백엔드가 돌기 전에 f32 레인 두 개로 바뀝니다.

GLSL 헬퍼 함수

스토리지 버퍼는 GLSL ES 3.00에 형태가 없어서, 스토리지를 읽는 코드는 데이터 텍스처를 읽는 코드로 바뀝니다. 아래가 그 읽기를 대신하는 함수들이며, 모듈이 부르는 함수의 정의는 GLSL 생성기가 함께 생성합니다.

내장 함수GLSL 함수
storageFetchF32
_sfetch
storageFetchU32
_sfetchU
storageFetchI32
_sfetchI

이 페이지의 모든 행은 고정된 커밋의 표기 레지스트리에서 읽어 온 것이고, 여기서 손으로 적은 것은 없습니다.

이 페이지 편집 문제 보고