내장 함수
내장 함수는 GPU 셰이더 언어가 제공하는 함수입니다. 호출은 컴파일러 안에서 공통 이름으로 표현하며, 각 백엔드가 타깃 언어의 표기로 변환합니다. 그래서 한 번 작성한 호출이 두 벌로 생성됩니다. 레지스트리에 담긴 이름은 190개입니다.
한 행을 읽는 법
첫째 칸은 호출이 달고 다니는 이름이며, 인자가 들어갈 자리마다 플레이스홀더를 하나씩 넣었습니다. 다음 두 칸은 WGSL 백엔드와 GLSL ES 3.00 백엔드가 그 호출에 대해 쓰는 코드로, 고정된 커밋의 컴파일러 표기표를 그대로 실행해 얻었습니다. 이 가운데 44개는 두 타깃에서 표기가 같고, 64개는 GLSL ES 3.00에 형태가 아예 없어 그 칸에 컴파일러가 낸 메시지를 싣습니다. 27개는 Math. 이름으로도 부를 수 있으며, 수학과 캐스트 표의 마지막 칸에서 그 이름을 확인할 수 있습니다. WGSL과 GLSL ES 3.00 비교에서는 셰이더 하나를 두 타깃으로 컴파일하고 서로 다른 곳을 짚습니다.
이 이름 가운데 몇 개는 컴파일러가 선택하므로 직접 쓰지 않습니다. 레이어 텍스처 읽기, 깊이 비교, 스토리지 fetch, 부호 없는 좌표로 하는 텍셀 읽기는 각각 별도의 이름을 사용합니다. 그래야 호출의 인자 순서가 어떤 텍스처에 쓰였는지에 따라 달라지지 않습니다. 부호 없는 값의 abs와 정수 dot도 따로 이름을 받는다. GLSL ES 3.00에는 둘 다 그 타입의 오버로드가 없기 때문입니다.
파일이 직접 선언한 이름
파일에 선언한 함수는 같은 이름의 내장 함수보다 우선합니다. 그런 이름은 내장 함수가 되기 전에는 작성자의 함수를 가리켰고, 기능을 더한다고 해서 이미 돌아가던 프로그램의 뜻이 바뀌면 안 되기 때문입니다.
수학
absU(a) abs(a)aldexp(a, b)(a * intBitsToFloat(((b >> 1) + 127) << 23) * intBitsToFloat(((b - (b >> 1)) + 127) << 23))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)기하 연산
dotI(a, b) dot(a, b)_idot(a, b)dotU(a, b) dot(a, b)_idot(a, b)화면 공간 미분
비트 연산
GLSL ES 3.00에는 비트 내장 함수가 하나도 없습니다. 그래서 위 칸은 GLSL 생성기가 정의하는 작은 함수를 부릅니다. 그 정의는 해당 타깃에 있는 시프트와 마스크, 비교만으로 쓰여 있습니다. 하나도 부르지 않는 모듈은 정의도 싣지 않습니다.
패킹
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))unpack4x8snorm(a)max(vec4(ivec4(uvec4(a, a >> 8, a >> 16, a >> 24) << 24) >> 24) / 127.0, vec4(-1.0))캐스트
bitcastVec2F32(a) bitcast<vec2<f32>>(a)uintBitsToFloat(a)bitcastVec2U32(a) bitcast<vec2<u32>>(a)floatBitsToUint(a)bitcastVec3F32(a) bitcast<vec3<f32>>(a)uintBitsToFloat(a)bitcastVec3U32(a) bitcast<vec3<u32>>(a)floatBitsToUint(a)bitcastVec4F32(a) bitcast<vec4<f32>>(a)uintBitsToFloat(a)bitcastVec4U32(a) bitcast<vec4<u32>>(a)floatBitsToUint(a)텍스처와 스토리지
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))textureDimensions1d(a) textureDimensions(a)textureDimensions on a texture_1d is not supported yet on the WebGL2 tier (Rule 10.5)
textureDimensions3d(a) textureDimensions(a)uvec3(textureSize(a, 0))textureDimensionsMs(a) textureDimensions(a)textureDimensions on a multisampled texture is not supported yet on the WebGL2 tier (Rule 10.5)
textureGather(a, b, c, d)textureGather is not supported yet on the WebGL2 tier (Rule 10.5)
textureGatherArray(a, b, c, d, e) textureGather(a, b, c, d, e)textureGather is not supported yet on the WebGL2 tier (Rule 10.5)
textureGatherCompare(a, b, c, d)textureGatherCompare is not supported yet on the WebGL2 tier (Rule 10.5)
textureGatherCompareArray(a, b, c, d, e) textureGatherCompare(a, b, c, d, e)textureGatherCompare is not supported yet on the WebGL2 tier (Rule 10.5)
textureGatherDepth(a, b, c) textureGather(a, b, c)textureGather is not supported yet on the WebGL2 tier (Rule 10.5)
textureGatherDepthArray(a, b, c, d) textureGather(a, b, c, d)textureGather is not supported yet on the WebGL2 tier (Rule 10.5)
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 is not supported yet on the WebGL2 tier (Rule 10.5)
textureLoadMs(a, b, c) textureLoad(a, b, c)a multisampled load is not supported yet on the WebGL2 tier (Rule 10.5)
textureLoadU(a, b, c) textureLoad(a, b, c)texelFetch(a, ivec2(b), int(c))textureNumLayersStorage(a) textureNumLayers(a)a storage texture is not supported yet on the WebGL2 tier (Rule 10.5)
textureNumSamples(a)textureNumSamples is not supported yet on the WebGL2 tier (Rule 10.5)
textureSampleArray(a, b, c, d) textureSample(a, b, c, d)texture(a, vec3(c, float(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 is not supported yet on the WebGL2 tier (Rule 10.5)
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 is not supported yet on the WebGL2 tier (Rule 10.5)
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 is not supported yet on the WebGL2 tier (Rule 10.5)
textureSampleCubeArray(a, b, c, d) textureSample(a, b, c, d)textureSample on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)
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 is not supported yet on the WebGL2 tier (Rule 10.5)
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 is not supported yet on the WebGL2 tier (Rule 10.5)
textureStore(a, b, c)textureStore is not supported yet on the WebGL2 tier (Rule 10.5)
원자적 연산
atomicAdd(&a, b)atomicAdd is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicAnd(&a, b)atomicAnd is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicCompareExchangeWeak(&a, b, c)atomicCompareExchangeWeak is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)
atomicLoad(&a)atomicLoad is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicMax(&a, b)atomicMax is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicMin(&a, b)atomicMin is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicOr(&a, b)atomicOr is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicStore(&a, b)atomicStore is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicSub(&a, b)atomicSub is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
atomicXor(&a, b)atomicXor is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a @compute entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)
배리어
textureBarrier()textureBarrier is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)
workgroupUniformLoad(&a)workgroupUniformLoad is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)
서브그룹
subgroupAdd(a)subgroupAdd is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupAll(a)subgroupAll is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupAnd(a)subgroupAnd is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupAny(a)subgroupAny is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupBallot(a)subgroupBallot is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupBroadcast(a, b)subgroupBroadcast is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupBroadcastFirst(a)subgroupBroadcastFirst is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupElect()subgroupElect is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupExclusiveAdd(a)subgroupExclusiveAdd is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupExclusiveMul(a)subgroupExclusiveMul is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupInclusiveAdd(a)subgroupInclusiveAdd is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupInclusiveMul(a)subgroupInclusiveMul is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupMax(a)subgroupMax is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupMin(a)subgroupMin is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupMul(a)subgroupMul is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupOr(a)subgroupOr is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupShuffle(a, b)subgroupShuffle is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupShuffleDown(a, b)subgroupShuffleDown is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupShuffleUp(a, b)subgroupShuffleUp is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupShuffleXor(a, b)subgroupShuffleXor is lowered to one lane before the GLSL writer runs (Rule 11.21)
subgroupXor(a)subgroupXor is lowered to one lane before the GLSL writer runs (Rule 11.21)
에뮬레이션 배정밀도
f64Guard() textureLoad(_fp64, vec2<i32>(0, 0), 0).xtexelFetch(_fp64, ivec2(0, 0), 0).xGLSL 헬퍼 함수
스토리지 버퍼는 GLSL ES 3.00에 형태가 없어서, 스토리지를 읽는 코드는 데이터 텍스처를 읽는 코드로 바뀝니다. 아래가 그 읽기를 대신하는 함수들이며, 모듈에서 호출하는 함수의 정의는 GLSL 생성기가 함께 생성합니다.
storageFetchF32 _sfetch storageFetchU32 _sfetchU storageFetchI32 _sfetchI 이 페이지의 모든 행은 고정된 커밋의 표기 레지스트리에서 읽어 온 것이고, 사이트에서 별도로 작성한 항목은 없습니다.