typegpu 0.8.0-alpha.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/chunk-2UXPGML5.js +7 -0
- package/chunk-2UXPGML5.js.map +1 -0
- package/chunk-3246CM7C.cjs +2 -0
- package/chunk-3246CM7C.cjs.map +1 -0
- package/{chunk-BDGVKGU4.js → chunk-4W5Z7BO4.js} +6 -6
- package/chunk-4W5Z7BO4.js.map +1 -0
- package/{chunk-ESIHND6W.cjs → chunk-5Y6GTBWR.cjs} +3 -3
- package/{chunk-ESIHND6W.cjs.map → chunk-5Y6GTBWR.cjs.map} +1 -1
- package/{chunk-DH4X56C7.js → chunk-7S3IK3D4.js} +2 -2
- package/{chunk-MJ6A4DOA.js → chunk-7XFSK632.js} +2 -2
- package/{chunk-WDMOZFKN.cjs → chunk-PRMFGUQT.cjs} +2 -2
- package/{chunk-WDMOZFKN.cjs.map → chunk-PRMFGUQT.cjs.map} +1 -1
- package/{chunk-44LAYHPR.cjs → chunk-TRE7NUKE.cjs} +6 -6
- package/chunk-TRE7NUKE.cjs.map +1 -0
- package/chunk-VOVQAOVG.js +2 -0
- package/chunk-VOVQAOVG.js.map +1 -0
- package/chunk-ZYGTVBDH.cjs +7 -0
- package/chunk-ZYGTVBDH.cjs.map +1 -0
- package/common/index.cjs +1 -1
- package/common/index.d.cts +1 -1
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/data/index.cjs +1 -1
- package/data/index.d.cts +3 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +1 -1
- package/index.cjs +51 -51
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +40 -40
- package/index.js.map +1 -1
- package/{matrix-UOB09LaW.d.cts → matrix-DHFT4O8f.d.cts} +1 -1
- package/{matrix-CjLuYXH1.d.ts → matrix-DLipCOZF.d.ts} +1 -1
- package/package.json +2 -2
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +2 -2
- package/std/index.d.ts +2 -2
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{tgpuConstant-sKeoSjPD.d.ts → tgpuConstant-BU72w5qs.d.cts} +15 -13
- package/{tgpuConstant-sKeoSjPD.d.cts → tgpuConstant-BU72w5qs.d.ts} +15 -13
- package/chunk-44LAYHPR.cjs.map +0 -1
- package/chunk-6OJFCDQF.js +0 -7
- package/chunk-6OJFCDQF.js.map +0 -1
- package/chunk-BDGVKGU4.js.map +0 -1
- package/chunk-CODEFPMD.cjs +0 -2
- package/chunk-CODEFPMD.cjs.map +0 -1
- package/chunk-HLB6TY7I.cjs +0 -7
- package/chunk-HLB6TY7I.cjs.map +0 -1
- package/chunk-ZYSFFI3M.js +0 -2
- package/chunk-ZYSFFI3M.js.map +0 -1
- /package/{chunk-DH4X56C7.js.map → chunk-7S3IK3D4.js.map} +0 -0
- /package/{chunk-MJ6A4DOA.js.map → chunk-7XFSK632.js.map} +0 -0
package/std/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { snip } from '../data/snippet.ts';\nimport { Void } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\n\nexport const discard = createDualImpl(\n // CPU\n (): never => {\n throw new Error(\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n );\n },\n // GPU\n () => snip('discard;', Void),\n 'discard',\n);\n","import { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport {\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuTranslation4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${gpuTranslation4(vector)} * ${matrix})`, matrix.dataType),\n 'translate4',\n);\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuScaling4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${(gpuScaling4(vector))} * ${matrix})`, matrix.dataType),\n 'scale4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationX4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationX4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateX4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationY4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationY4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateY4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationZ4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationZ4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateZ4',\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport {\n type AnyWgslData,\n type atomicI32,\n type atomicU32,\n isWgslData,\n Void,\n} from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('workgroupBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('workgroupBarrier()', Void),\n 'workgroupBarrier',\n);\n\nexport const storageBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('storageBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('storageBarrier()', Void),\n 'storageBarrier',\n);\n\nexport const textureBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('textureBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('textureBarrier()', Void),\n 'textureBarrier',\n);\n\nexport const atomicLoad = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicLoad(&${a})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicLoad',\n);\n\nexport const atomicStore = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): void => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (!isWgslData(a.dataType) || a.dataType.type !== 'atomic') {\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n }\n return snip(stitch`atomicStore(&${a}, ${value})`, Void);\n },\n 'atomicStore',\n);\n\nconst atomicTypeFn = (a: Snippet, _value: Snippet): AnyWgslData[] => {\n if (a.dataType.type === 'atomic' && a.dataType.inner.type === 'i32') {\n return [a.dataType, i32];\n }\n return [a.dataType as AnyWgslData, u32];\n};\n\nexport const atomicAdd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAdd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAdd',\n atomicTypeFn,\n);\n\nexport const atomicSub = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicSub(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicSub',\n atomicTypeFn,\n);\n\nexport const atomicMax = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMax(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMax',\n atomicTypeFn,\n);\n\nexport const atomicMin = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMin(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMin',\n atomicTypeFn,\n);\n\nexport const atomicAnd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAnd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAnd',\n atomicTypeFn,\n);\n\nexport const atomicOr = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicOr(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicOr',\n atomicTypeFn,\n);\n\nexport const atomicXor = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicXor(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicXor',\n atomicTypeFn,\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\nfunction cpuDpdx(value: number): number;\nfunction cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdx<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdx = createDualImpl(\n cpuDpdx,\n (value) => snip(stitch`dpdx(${value})`, value.dataType),\n 'dpdx',\n);\n\nfunction cpuDpdxCoarse(value: number): number;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxCoarse = createDualImpl(\n cpuDpdxCoarse,\n (value) => snip(stitch`dpdxCoarse(${value})`, value.dataType),\n 'dpdxCoarse',\n);\n\nfunction cpuDpdxFine(value: number): number;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxFine = createDualImpl(\n cpuDpdxFine,\n (value) => snip(stitch`dpdxFine(${value})`, value.dataType),\n 'dpdxFine',\n);\n\nfunction cpuDpdy(value: number): number;\nfunction cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdy<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdy = createDualImpl(\n cpuDpdy,\n (value) => snip(stitch`dpdy(${value})`, value.dataType),\n 'dpdy',\n);\n\nfunction cpuDpdyCoarse(value: number): number;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyCoarse = createDualImpl(\n cpuDpdyCoarse,\n (value) => snip(stitch`dpdyCoarse(${value})`, value.dataType),\n 'dpdyCoarse',\n);\n\nfunction cpuDpdyFine(value: number): number;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyFine = createDualImpl(\n cpuDpdyFine,\n (value) => snip(stitch`dpdyFine(${value})`, value.dataType),\n 'dpdyFine',\n);\n\nfunction cpuFwidth(value: number): number;\nfunction cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidth<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidth = createDualImpl(\n cpuFwidth,\n (value) => snip(stitch`fwidth(${value})`, value.dataType),\n 'fwidth',\n);\n\nfunction cpuFwidthCoarse(value: number): number;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthCoarse = createDualImpl(\n cpuFwidthCoarse,\n (value) => snip(stitch`fwidthCoarse(${value})`, value.dataType),\n 'fwidthCoarse',\n);\n\nfunction cpuFwidthFine(value: number): number;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthFine = createDualImpl(\n cpuFwidthFine,\n (value) => snip(stitch`fwidthFine(${value})`, value.dataType),\n 'fwidthFine',\n);\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[]) => a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n type StorageTextureFormats,\n type TextureFormats,\n textureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = textureFormats[format].vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import type { DualFn } from '../data/dualFn.ts';\nimport { bool } from '../data/index.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport { getResolutionCtx, inCodegenMode } from '../execMode.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled: DualFn<\n (extensionName: WgslExtension) => boolean\n> = (() => {\n const jsImpl = (extensionName: WgslExtension) => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n };\n const gpuImpl = (extensionNameSnippet: Snippet) => {\n const { value } = extensionNameSnippet;\n if (\n typeof value !== 'string' ||\n !(wgslExtensions.includes(value as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${value}`,\n );\n }\n return snip(jsImpl(value as WgslExtension), bool);\n };\n\n const impl = (extensionName: WgslExtension) => {\n if (inCodegenMode()) {\n return gpuImpl(extensionName as unknown as Snippet);\n }\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n };\n\n Object.defineProperty(impl, $internal, {\n value: {\n jsImpl,\n gpuImpl,\n argConversionHint: 'keep' as const,\n },\n });\n return impl;\n})() as unknown as DualFn<\n (extensionName: WgslExtension) => boolean\n>;\n"],"mappings":"0nCAIO,IAAMA,GAAUC,EAErB,IAAa,CACX,MAAM,IAAI,MACR,iFACF,CACF,EAEA,IAAMC,EAAK,WAAYC,CAAI,EAC3B,SACF,ECAA,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAExB,CAACC,EAAeC,IAAgBrB,EAAOG,GAAgBkB,CAAM,EAAGD,CAAM,EAEtE,CAACA,EAAQC,IACPC,EAAKC,KAAUlB,GAAgBgB,CAAM,CAAC,MAAMD,CAAM,IAAKA,EAAO,QAAQ,EACxE,YACF,EAQaI,GAASL,EAEpB,CAACC,EAAeC,IAAgBrB,EAAOM,GAAYe,CAAM,EAAGD,CAAM,EAElE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cAAO,eAAeS,EAAME,EAAW,CACrC,MAAO,CACL,OAAAZ,EACA,QAAAI,EACA,kBAAmB,MACrB,CACF,CAAC,EACMM,CACT,GAAG","names":["discard","createDualImpl","snip","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","createDualImpl","matrix","vector","snip","stitch","scale4","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","createDualImpl","snip","Void","storageBarrier","textureBarrier","atomicLoad","a","isWgslData","stitch","safeStringify","atomicStore","value","atomicTypeFn","_value","i32","u32","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","cpuDpdx","value","dpdx","createDualImpl","snip","stitch","cpuDpdxCoarse","dpdxCoarse","cpuDpdxFine","dpdxFine","cpuDpdy","dpdy","cpuDpdyCoarse","dpdyCoarse","cpuDpdyFine","dpdyFine","cpuFwidth","fwidth","cpuFwidthCoarse","fwidthCoarse","cpuFwidthFine","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","textureFormats","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","jsImpl","extensionName","resolutionCtx","getResolutionCtx","gpuImpl","extensionNameSnippet","value","wgslExtensions","snip","bool","impl","inCodegenMode","$internal"]}
|
|
1
|
+
{"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { snip } from '../data/snippet.ts';\nimport { Void } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\n\nexport const discard = createDualImpl(\n // CPU\n (): never => {\n throw new Error(\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n );\n },\n // GPU\n () => snip('discard;', Void),\n 'discard',\n);\n","import { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport {\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuTranslation4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${gpuTranslation4(vector)} * ${matrix})`, matrix.dataType),\n 'translate4',\n);\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuScaling4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${(gpuScaling4(vector))} * ${matrix})`, matrix.dataType),\n 'scale4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationX4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationX4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateX4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationY4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationY4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateY4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationZ4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationZ4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateZ4',\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport {\n type AnyWgslData,\n type atomicI32,\n type atomicU32,\n isWgslData,\n Void,\n} from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('workgroupBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('workgroupBarrier()', Void),\n 'workgroupBarrier',\n);\n\nexport const storageBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('storageBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('storageBarrier()', Void),\n 'storageBarrier',\n);\n\nexport const textureBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('textureBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('textureBarrier()', Void),\n 'textureBarrier',\n);\n\nexport const atomicLoad = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicLoad(&${a})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicLoad',\n);\n\nexport const atomicStore = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): void => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (!isWgslData(a.dataType) || a.dataType.type !== 'atomic') {\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n }\n return snip(stitch`atomicStore(&${a}, ${value})`, Void);\n },\n 'atomicStore',\n);\n\nconst atomicTypeFn = (a: Snippet, _value: Snippet): AnyWgslData[] => {\n if (a.dataType.type === 'atomic' && a.dataType.inner.type === 'i32') {\n return [a.dataType, i32];\n }\n return [a.dataType as AnyWgslData, u32];\n};\n\nexport const atomicAdd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAdd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAdd',\n atomicTypeFn,\n);\n\nexport const atomicSub = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicSub(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicSub',\n atomicTypeFn,\n);\n\nexport const atomicMax = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMax(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMax',\n atomicTypeFn,\n);\n\nexport const atomicMin = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMin(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMin',\n atomicTypeFn,\n);\n\nexport const atomicAnd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAnd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAnd',\n atomicTypeFn,\n);\n\nexport const atomicOr = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicOr(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicOr',\n atomicTypeFn,\n);\n\nexport const atomicXor = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicXor(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicXor',\n atomicTypeFn,\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\nfunction cpuDpdx(value: number): number;\nfunction cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdx<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdx = createDualImpl(\n cpuDpdx,\n (value) => snip(stitch`dpdx(${value})`, value.dataType),\n 'dpdx',\n);\n\nfunction cpuDpdxCoarse(value: number): number;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxCoarse = createDualImpl(\n cpuDpdxCoarse,\n (value) => snip(stitch`dpdxCoarse(${value})`, value.dataType),\n 'dpdxCoarse',\n);\n\nfunction cpuDpdxFine(value: number): number;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxFine = createDualImpl(\n cpuDpdxFine,\n (value) => snip(stitch`dpdxFine(${value})`, value.dataType),\n 'dpdxFine',\n);\n\nfunction cpuDpdy(value: number): number;\nfunction cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdy<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdy = createDualImpl(\n cpuDpdy,\n (value) => snip(stitch`dpdy(${value})`, value.dataType),\n 'dpdy',\n);\n\nfunction cpuDpdyCoarse(value: number): number;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyCoarse = createDualImpl(\n cpuDpdyCoarse,\n (value) => snip(stitch`dpdyCoarse(${value})`, value.dataType),\n 'dpdyCoarse',\n);\n\nfunction cpuDpdyFine(value: number): number;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyFine = createDualImpl(\n cpuDpdyFine,\n (value) => snip(stitch`dpdyFine(${value})`, value.dataType),\n 'dpdyFine',\n);\n\nfunction cpuFwidth(value: number): number;\nfunction cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidth<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidth = createDualImpl(\n cpuFwidth,\n (value) => snip(stitch`fwidth(${value})`, value.dataType),\n 'fwidth',\n);\n\nfunction cpuFwidthCoarse(value: number): number;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthCoarse = createDualImpl(\n cpuFwidthCoarse,\n (value) => snip(stitch`fwidthCoarse(${value})`, value.dataType),\n 'fwidthCoarse',\n);\n\nfunction cpuFwidthFine(value: number): number;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthFine = createDualImpl(\n cpuFwidthFine,\n (value) => snip(stitch`fwidthFine(${value})`, value.dataType),\n 'fwidthFine',\n);\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[]) => a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n type StorageTextureFormats,\n type TextureFormats,\n textureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = textureFormats[format].vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import type { DualFn } from '../data/dualFn.ts';\nimport { bool } from '../data/index.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport { getResolutionCtx, inCodegenMode } from '../execMode.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled: DualFn<\n (extensionName: WgslExtension) => boolean\n> = (() => {\n const jsImpl = (extensionName: WgslExtension) => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n };\n const gpuImpl = (extensionNameSnippet: Snippet) => {\n const { value } = extensionNameSnippet;\n if (\n typeof value !== 'string' ||\n !(wgslExtensions.includes(value as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${value}`,\n );\n }\n return snip(jsImpl(value as WgslExtension), bool);\n };\n\n const impl = (extensionName: WgslExtension) => {\n if (inCodegenMode()) {\n return gpuImpl(extensionName as unknown as Snippet);\n }\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n };\n\n Object.defineProperty(impl, $internal, {\n value: {\n jsImpl,\n gpuImpl,\n argConversionHint: 'keep' as const,\n },\n });\n return impl;\n})() as unknown as DualFn<\n (extensionName: WgslExtension) => boolean\n>;\n"],"mappings":"unCAIO,IAAMA,GAAUC,EAErB,IAAa,CACX,MAAM,IAAI,MACR,iFACF,CACF,EAEA,IAAMC,EAAK,WAAYC,CAAI,EAC3B,SACF,ECAA,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAExB,CAACC,EAAeC,IAAgBrB,EAAOG,GAAgBkB,CAAM,EAAGD,CAAM,EAEtE,CAACA,EAAQC,IACPC,EAAKC,KAAUlB,GAAgBgB,CAAM,CAAC,MAAMD,CAAM,IAAKA,EAAO,QAAQ,EACxE,YACF,EAQaI,GAASL,EAEpB,CAACC,EAAeC,IAAgBrB,EAAOM,GAAYe,CAAM,EAAGD,CAAM,EAElE,CAACA,EAAQC,IACPC,EAAKC,KAAWf,GAAYa,CAAM,CAAE,MAAMD,CAAM,IAAKA,EAAO,QAAQ,EACtE,QACF,EAQaK,GAAWN,EAEtB,CAACC,EAAeM,IAAkB1B,EAAOS,GAAciB,CAAK,EAAGN,CAAM,EAErE,CAACA,EAAQM,IACPJ,EAAKC,KAAWZ,GAAce,CAAK,CAAE,MAAMN,CAAM,IAAKA,EAAO,QAAQ,EACvE,UACF,EAQaO,GAAWR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ACpD,GAAI,CAACe,EACH,MAAM,IAAI,MACR,4EACEnB,EAAK,CAAC,EAAE,IACV,EACF,EAEF,MAAO,CAAE,SAAU,CAACA,EAAK,CAAC,EAAGmB,EAAK,CAAC,CAAC,EAAG,WAAYnB,EAAK,CAAC,CAAE,CAC7D,EACA,WAAYd,EACZ,YAAa,CAAC,EAAGiC,IAAS7B,uBAA4B,CAAC,KAAK6B,CAAI,GAClE,CAAC,EAEYC,GAAchC,EAA8B,CACvD,KAAM,cACN,UAAYC,IAAS,CAAE,SAAU,CAACA,CAAG,EAAG,WAAYA,CAAI,GACxD,WAAYH,EACZ,YAAc,GAAMI,gBAAqB,CAAC,GAC5C,CAAC,ECnOM,IAAM+B,IAER,IAAM,CACT,IAAMC,EAAUC,GAAiC,CAC/C,IAAMC,EAAgBC,EAAiB,EACvC,GAAI,CAACD,EACH,MAAM,IAAI,MACR,+DACF,EAGF,OAAQA,EAAc,kBAAoB,CAAC,GAAG,SAASD,CAAa,CACtE,EACMG,EAAWC,GAAkC,CACjD,GAAM,CAAE,MAAAC,CAAM,EAAID,EAClB,GACE,OAAOC,GAAU,UACjB,CAAEC,EAAe,SAASD,CAAsB,EAEhD,MAAM,IAAI,MACR,0GAA0GA,CAAK,EACjH,EAEF,OAAOE,EAAKR,EAAOM,CAAsB,EAAGG,CAAI,CAClD,EAEMC,EAAQT,GAAiC,CAC7C,GAAIU,EAAc,EAChB,OAAOP,EAAQH,CAAmC,EAEpD,MAAM,IAAI,MACR,+DACF,CACF,EAEA,cAAO,eAAeS,EAAME,EAAW,CACrC,MAAO,CACL,OAAAZ,EACA,QAAAI,EACA,kBAAmB,MACrB,CACF,CAAC,EACMM,CACT,GAAG","names":["discard","createDualImpl","snip","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","createDualImpl","matrix","vector","snip","stitch","scale4","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","createDualImpl","snip","Void","storageBarrier","textureBarrier","atomicLoad","a","isWgslData","stitch","safeStringify","atomicStore","value","atomicTypeFn","_value","i32","u32","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","cpuDpdx","value","dpdx","createDualImpl","snip","stitch","cpuDpdxCoarse","dpdxCoarse","cpuDpdxFine","dpdxFine","cpuDpdy","dpdy","cpuDpdyCoarse","dpdyCoarse","cpuDpdyFine","dpdyFine","cpuFwidth","fwidth","cpuFwidthCoarse","fwidthCoarse","cpuFwidthFine","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","textureFormats","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","jsImpl","extensionName","resolutionCtx","getResolutionCtx","gpuImpl","extensionNameSnippet","value","wgslExtensions","snip","bool","impl","inCodegenMode","$internal"]}
|
|
@@ -2690,7 +2690,7 @@ interface ColorAttachment {
|
|
|
2690
2690
|
* A {@link GPUTextureView} describing the texture subresource that will be output to for this
|
|
2691
2691
|
* color attachment.
|
|
2692
2692
|
*/
|
|
2693
|
-
view: (TgpuTexture & RenderFlag) | GPUTextureView
|
|
2693
|
+
view: (TgpuTexture & RenderFlag) | GPUTextureView | TgpuTextureView<WgslTexture>;
|
|
2694
2694
|
/**
|
|
2695
2695
|
* Indicates the depth slice index of {@link GPUTextureViewDimension#"3d"} {@link GPURenderPassColorAttachment#view}
|
|
2696
2696
|
* that will be output to for this color attachment.
|
|
@@ -3172,7 +3172,7 @@ type GenerationCtx = ResolutionCtx & {
|
|
|
3172
3172
|
dedent(): string;
|
|
3173
3173
|
pushBlockScope(): void;
|
|
3174
3174
|
popBlockScope(): void;
|
|
3175
|
-
generateLog(args: Snippet[]): Snippet;
|
|
3175
|
+
generateLog(op: string, args: Snippet[]): Snippet;
|
|
3176
3176
|
getById(id: string): Snippet | null;
|
|
3177
3177
|
defineVariable(id: string, snippet: Snippet): void;
|
|
3178
3178
|
/**
|
|
@@ -3202,7 +3202,7 @@ interface LogGeneratorOptions {
|
|
|
3202
3202
|
logSizeLimit?: number;
|
|
3203
3203
|
/**
|
|
3204
3204
|
* The prefix attached to each log call.
|
|
3205
|
-
* @default
|
|
3205
|
+
* @default ' GPU '
|
|
3206
3206
|
*/
|
|
3207
3207
|
messagePrefix?: string;
|
|
3208
3208
|
}
|
|
@@ -3210,20 +3210,26 @@ type SerializedLogCallData = WgslStruct<{
|
|
|
3210
3210
|
id: U32;
|
|
3211
3211
|
serializedData: WgslArray<U32>;
|
|
3212
3212
|
}>;
|
|
3213
|
+
interface LogMeta {
|
|
3214
|
+
op: SupportedLogOps;
|
|
3215
|
+
argTypes: (string | AnyWgslData)[];
|
|
3216
|
+
}
|
|
3213
3217
|
/**
|
|
3214
3218
|
* The resources required for logging within the TGSL console.
|
|
3215
3219
|
*
|
|
3216
3220
|
* @property indexBuffer - A buffer used for indexing log entries. Needs to be cleared after each dispatch/draw.
|
|
3217
3221
|
* @property dataBuffer - A buffer containing an array of serialized log call data.
|
|
3218
3222
|
* @property options - The configuration options for the LogGenerator.
|
|
3219
|
-
* @property
|
|
3223
|
+
* @property logIdToMeta - A mapping from log identifiers to an object containing the corresponding log op and argument types.
|
|
3220
3224
|
*/
|
|
3221
3225
|
interface LogResources {
|
|
3222
3226
|
indexBuffer: TgpuMutable<Atomic<U32>>;
|
|
3223
3227
|
dataBuffer: TgpuMutable<WgslArray<SerializedLogCallData>>;
|
|
3224
3228
|
options: Required<LogGeneratorOptions>;
|
|
3225
|
-
|
|
3229
|
+
logIdToMeta: Map<number, LogMeta>;
|
|
3226
3230
|
}
|
|
3231
|
+
declare const supportedLogOps: readonly ["log", "debug", "info", "warn", "error", "clear"];
|
|
3232
|
+
type SupportedLogOps = (typeof supportedLogOps)[number];
|
|
3227
3233
|
|
|
3228
3234
|
interface ShaderGenerator {
|
|
3229
3235
|
initGenerator(ctx: GenerationCtx): void;
|
|
@@ -3648,18 +3654,14 @@ interface TgpuRoot extends Unwrapper {
|
|
|
3648
3654
|
interface ExperimentalTgpuRoot extends TgpuRoot, WithBinding {
|
|
3649
3655
|
readonly nameRegistrySetting: 'strict' | 'random';
|
|
3650
3656
|
readonly shaderGenerator?: ShaderGenerator | undefined;
|
|
3651
|
-
/**
|
|
3652
|
-
* The current command encoder. This property will
|
|
3653
|
-
* hold the same value until `flush()` is called.
|
|
3654
|
-
*/
|
|
3655
|
-
readonly commandEncoder: GPUCommandEncoder;
|
|
3656
3657
|
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
3657
3658
|
beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
|
|
3658
3659
|
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
3659
3660
|
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
3660
3661
|
/**
|
|
3661
|
-
*
|
|
3662
|
-
* submitted to the GPU
|
|
3662
|
+
* @deprecated Used to cause all commands enqueued by pipelines to be
|
|
3663
|
+
* submitted to the GPU, but now commands are immediately dispatched,
|
|
3664
|
+
* which makes this method unnecessary.
|
|
3663
3665
|
*/
|
|
3664
3666
|
flush(): void;
|
|
3665
3667
|
}
|
|
@@ -5187,4 +5189,4 @@ interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNam
|
|
|
5187
5189
|
*/
|
|
5188
5190
|
declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: InferGPU<TDataType>): TgpuConst<TDataType>;
|
|
5189
5191
|
|
|
5190
|
-
export { $internal as $, type AnyData as A, isUsableAsVertex as B, type Configurable as C, type Disarray as D, isDerived as E, isSlot as F, isComparisonSampler as G, isSampler as H, type Infer as I, isTexture as J, isUsableAsRender as K, type LogResources as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type ResolvedSnippet as R, ShelllessRepository as S, type TgpuSlot as T, isVariable as U, type TgpuGuardedComputePipeline as V, type Wgsl as W, type ValidateBufferSchema as X, type ValidateStorageSchema as Y, type ValidateUniformSchema as Z, type WithBinding as _, type TgpuDerived as a, type
|
|
5192
|
+
export { $internal as $, type AnyData as A, isUsableAsVertex as B, type Configurable as C, type Disarray as D, isDerived as E, isSlot as F, isComparisonSampler as G, isSampler as H, type Infer as I, isTexture as J, isUsableAsRender as K, type LogResources as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type ResolvedSnippet as R, ShelllessRepository as S, type TgpuSlot as T, isVariable as U, type TgpuGuardedComputePipeline as V, type Wgsl as W, type ValidateBufferSchema as X, type ValidateStorageSchema as Y, type ValidateUniformSchema as Z, type WithBinding as _, type TgpuDerived as a, type Vec4h as a$, type WithCompute as a0, type WithFragment as a1, type WithVertex as a2, type Storage as a3, type StorageFlag as a4, type TgpuRenderPipeline as a5, type TgpuComputePipeline as a6, type IndexFlag as a7, type Uniform as a8, type UniformFlag as a9, type TgpuLayoutEntry as aA, type TgpuLayoutExternalTexture as aB, type TgpuLayoutSampler as aC, type TgpuLayoutStorage as aD, type TgpuLayoutTexture as aE, type TgpuLayoutUniform as aF, type TgpuFnShell as aG, type TgpuVertexFn as aH, type TgpuVertexFnShell as aI, type TgpuFragmentFn as aJ, type TgpuFragmentFnShell as aK, type TgpuComputeFn as aL, type TgpuComputeFnShell as aM, type TgpuDeclare as aN, type INTERNAL_GlobalExt as aO, type Vec2f as aP, type Vec2b as aQ, type Vec2h as aR, type Vec2i as aS, type Vec2u as aT, type Vec3b as aU, type Vec3f as aV, type Vec3h as aW, type Vec3i as aX, type Vec3u as aY, type Vec4b as aZ, type Vec4f as a_, type ValidUsagesFor as aa, type Vertex as ab, type VertexFlag as ac, type TgpuBufferMutable as ad, type TgpuBufferReadonly as ae, type TgpuBufferUniform as af, type TgpuMutable as ag, type TgpuReadonly as ah, type TgpuUniform as ai, type Eventual as aj, type TgpuTexture as ak, type TgpuTextureView as al, type TextureProps as am, type RenderFlag as an, type SampledFlag as ao, type TgpuConst as ap, type VariableScope as aq, type TgpuComparisonSampler as ar, type TgpuFixedComparisonSampler as as, type TgpuFixedSampler as at, type TgpuSampler as au, type TgpuQuerySet as av, type BindLayoutEntry as aw, type ExtractBindGroupInputFromLayout as ax, type LayoutEntryToInput as ay, type TgpuLayoutComparisonSampler as az, type TgpuBindGroupLayout as b, textureDepthCube as b$, type Vec4i as b0, type Vec4u as b1, type Bool as b2, type F16 as b3, type F32 as b4, type I32 as b5, type U16 as b6, type U32 as b7, type WgslStruct as b8, type DualFn as b9, type m4x4f as bA, type Mat2x2f as bB, type Mat3x3f as bC, type Mat4x4f as bD, type Size as bE, type v2b as bF, type v2f as bG, type v2i as bH, type v2u as bI, type v3b as bJ, type v3f as bK, type v3i as bL, type v3u as bM, type v4b as bN, type v4f as bO, type v4i as bP, type v4u as bQ, type AnyLooseData as bR, type LooseDecorated as bS, texture1d as bT, texture2d as bU, texture2dArray as bV, texture3d as bW, textureCube as bX, textureCubeArray as bY, textureDepth2d as bZ, textureDepth2dArray as b_, type StorableData as ba, type Ptr as bb, type BaseData as bc, type Unstruct as bd, type Atomic as be, isAlignAttrib as bf, isAtomic as bg, isBuiltinAttrib as bh, isDecorated as bi, isInterpolateAttrib as bj, isLocationAttrib as bk, isPtr as bl, isSizeAttrib as bm, isWgslArray as bn, isWgslData as bo, isWgslStruct as bp, Void as bq, type Align as br, type AnyVecInstance as bs, type AnyWgslStruct as bt, type Builtin as bu, type Decorated as bv, type Interpolate as bw, type Location as bx, type m2x2f as by, type m3x3f as bz, type TgpuBindGroup as c, type FormatToWGSLType as c$, textureDepthCubeArray as c0, textureDepthMultisampled2d as c1, textureExternal as c2, textureMultisampled2d as c3, textureStorage1d as c4, textureStorage2d as c5, textureStorage2dArray as c6, textureStorage3d as c7, type WgslExternalTexture as c8, type WgslStorageTexture as c9, invariant as cA, type IsBuiltin as cB, isBuiltin as cC, location as cD, size as cE, isData as cF, isDisarray as cG, isLooseData as cH, isLooseDecorated as cI, isUnstruct as cJ, builtin as cK, type AnyBuiltin as cL, type BuiltinClipDistances as cM, type BuiltinFragDepth as cN, type BuiltinFrontFacing as cO, type BuiltinGlobalInvocationId as cP, type BuiltinInstanceIndex as cQ, type BuiltinLocalInvocationId as cR, type BuiltinLocalInvocationIndex as cS, type BuiltinNumWorkgroups as cT, type BuiltinPosition as cU, type BuiltinSampleIndex as cV, type BuiltinSampleMask as cW, type BuiltinVertexIndex as cX, type BuiltinWorkgroupId as cY, type InferGPU as cZ, type InferPartial as c_, type WgslStorageTexture1d as ca, type WgslStorageTexture2d as cb, type WgslStorageTexture2dArray as cc, type WgslStorageTexture3d as cd, type WgslStorageTextureProps as ce, type WgslTexture as cf, type WgslTexture1d as cg, type WgslTexture2d as ch, type WgslTexture2dArray as ci, type WgslTexture3d as cj, type WgslTextureCube as ck, type WgslTextureCubeArray as cl, type WgslTextureDepth2d as cm, type WgslTextureDepth2dArray as cn, type WgslTextureDepthCube as co, type WgslTextureDepthCubeArray as cp, type WgslTextureDepthMultisampled2d as cq, type WgslTextureMultisampled2d as cr, comparisonSampler as cs, sampler as ct, type WgslComparisonSampler as cu, type WgslSampler as cv, align as cw, type AnyAttribute as cx, type HasCustomLocation as cy, interpolate as cz, type WgslExtension as d, type atomicI32 as d$, type TgpuVertexFormatData as d0, formatToWGSLType as d1, packedFormats as d2, uint8 as d3, uint8x2 as d4, uint8x4 as d5, sint8 as d6, sint8x2 as d7, sint8x4 as d8, unorm8 as d9, uint32x2 as dA, uint32x3 as dB, uint32x4 as dC, sint32 as dD, sint32x2 as dE, sint32x3 as dF, sint32x4 as dG, unorm10_10_10_2 as dH, unorm8x4_bgra as dI, type PackedData as dJ, isPackedData as dK, type AnyNumericVecInstance as dL, type AnyFloatVecInstance as dM, type AnyIntegerVecInstance as dN, type v3h as dO, type AnyMatInstance as dP, type AbstractFloat as dQ, type AbstractInt as dR, type v2h as dS, type v4h as dT, type AnyFloat32VecInstance as dU, type AnySignedVecInstance as dV, type vBaseForMat as dW, type mBaseForVec as dX, type AnyVec2Instance as dY, type AnyVec3Instance as dZ, type AnyBooleanVecInstance as d_, unorm8x2 as da, unorm8x4 as db, snorm8 as dc, snorm8x2 as dd, snorm8x4 as de, uint16 as df, uint16x2 as dg, uint16x4 as dh, sint16 as di, sint16x2 as dj, sint16x4 as dk, unorm16 as dl, unorm16x2 as dm, unorm16x4 as dn, snorm16 as dp, snorm16x2 as dq, snorm16x4 as dr, float16 as ds, float16x2 as dt, float16x4 as du, float32 as dv, float32x2 as dw, float32x3 as dx, float32x4 as dy, uint32 as dz, type ShaderGenerator as e, type atomicU32 as e0, type StorageTextureFormats as e1, type TextureFormats as e2, $repr as e3, type TgpuBuffer as f, type TgpuVar as g, type LogGeneratorOptions as h, type TgpuRoot as i, type AnyWgslData as j, type TgpuFn as k, type TgpuBufferUsage as l, type TgpuAccessor as m, type TgpuVertexLayout as n, type WgslArray as o, fn as p, bindGroupLayout as q, privateVar as r, constant as s, fragmentFn as t, vertexFn as u, vertexLayout as v, workgroupVar as w, computeFn as x, declare as y, isBuffer as z };
|
|
@@ -2690,7 +2690,7 @@ interface ColorAttachment {
|
|
|
2690
2690
|
* A {@link GPUTextureView} describing the texture subresource that will be output to for this
|
|
2691
2691
|
* color attachment.
|
|
2692
2692
|
*/
|
|
2693
|
-
view: (TgpuTexture & RenderFlag) | GPUTextureView
|
|
2693
|
+
view: (TgpuTexture & RenderFlag) | GPUTextureView | TgpuTextureView<WgslTexture>;
|
|
2694
2694
|
/**
|
|
2695
2695
|
* Indicates the depth slice index of {@link GPUTextureViewDimension#"3d"} {@link GPURenderPassColorAttachment#view}
|
|
2696
2696
|
* that will be output to for this color attachment.
|
|
@@ -3172,7 +3172,7 @@ type GenerationCtx = ResolutionCtx & {
|
|
|
3172
3172
|
dedent(): string;
|
|
3173
3173
|
pushBlockScope(): void;
|
|
3174
3174
|
popBlockScope(): void;
|
|
3175
|
-
generateLog(args: Snippet[]): Snippet;
|
|
3175
|
+
generateLog(op: string, args: Snippet[]): Snippet;
|
|
3176
3176
|
getById(id: string): Snippet | null;
|
|
3177
3177
|
defineVariable(id: string, snippet: Snippet): void;
|
|
3178
3178
|
/**
|
|
@@ -3202,7 +3202,7 @@ interface LogGeneratorOptions {
|
|
|
3202
3202
|
logSizeLimit?: number;
|
|
3203
3203
|
/**
|
|
3204
3204
|
* The prefix attached to each log call.
|
|
3205
|
-
* @default
|
|
3205
|
+
* @default ' GPU '
|
|
3206
3206
|
*/
|
|
3207
3207
|
messagePrefix?: string;
|
|
3208
3208
|
}
|
|
@@ -3210,20 +3210,26 @@ type SerializedLogCallData = WgslStruct<{
|
|
|
3210
3210
|
id: U32;
|
|
3211
3211
|
serializedData: WgslArray<U32>;
|
|
3212
3212
|
}>;
|
|
3213
|
+
interface LogMeta {
|
|
3214
|
+
op: SupportedLogOps;
|
|
3215
|
+
argTypes: (string | AnyWgslData)[];
|
|
3216
|
+
}
|
|
3213
3217
|
/**
|
|
3214
3218
|
* The resources required for logging within the TGSL console.
|
|
3215
3219
|
*
|
|
3216
3220
|
* @property indexBuffer - A buffer used for indexing log entries. Needs to be cleared after each dispatch/draw.
|
|
3217
3221
|
* @property dataBuffer - A buffer containing an array of serialized log call data.
|
|
3218
3222
|
* @property options - The configuration options for the LogGenerator.
|
|
3219
|
-
* @property
|
|
3223
|
+
* @property logIdToMeta - A mapping from log identifiers to an object containing the corresponding log op and argument types.
|
|
3220
3224
|
*/
|
|
3221
3225
|
interface LogResources {
|
|
3222
3226
|
indexBuffer: TgpuMutable<Atomic<U32>>;
|
|
3223
3227
|
dataBuffer: TgpuMutable<WgslArray<SerializedLogCallData>>;
|
|
3224
3228
|
options: Required<LogGeneratorOptions>;
|
|
3225
|
-
|
|
3229
|
+
logIdToMeta: Map<number, LogMeta>;
|
|
3226
3230
|
}
|
|
3231
|
+
declare const supportedLogOps: readonly ["log", "debug", "info", "warn", "error", "clear"];
|
|
3232
|
+
type SupportedLogOps = (typeof supportedLogOps)[number];
|
|
3227
3233
|
|
|
3228
3234
|
interface ShaderGenerator {
|
|
3229
3235
|
initGenerator(ctx: GenerationCtx): void;
|
|
@@ -3648,18 +3654,14 @@ interface TgpuRoot extends Unwrapper {
|
|
|
3648
3654
|
interface ExperimentalTgpuRoot extends TgpuRoot, WithBinding {
|
|
3649
3655
|
readonly nameRegistrySetting: 'strict' | 'random';
|
|
3650
3656
|
readonly shaderGenerator?: ShaderGenerator | undefined;
|
|
3651
|
-
/**
|
|
3652
|
-
* The current command encoder. This property will
|
|
3653
|
-
* hold the same value until `flush()` is called.
|
|
3654
|
-
*/
|
|
3655
|
-
readonly commandEncoder: GPUCommandEncoder;
|
|
3656
3657
|
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
3657
3658
|
beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
|
|
3658
3659
|
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
3659
3660
|
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
3660
3661
|
/**
|
|
3661
|
-
*
|
|
3662
|
-
* submitted to the GPU
|
|
3662
|
+
* @deprecated Used to cause all commands enqueued by pipelines to be
|
|
3663
|
+
* submitted to the GPU, but now commands are immediately dispatched,
|
|
3664
|
+
* which makes this method unnecessary.
|
|
3663
3665
|
*/
|
|
3664
3666
|
flush(): void;
|
|
3665
3667
|
}
|
|
@@ -5187,4 +5189,4 @@ interface TgpuConst<TDataType extends AnyWgslData = AnyWgslData> extends TgpuNam
|
|
|
5187
5189
|
*/
|
|
5188
5190
|
declare function constant<TDataType extends AnyWgslData>(dataType: TDataType, value: InferGPU<TDataType>): TgpuConst<TDataType>;
|
|
5189
5191
|
|
|
5190
|
-
export { $internal as $, type AnyData as A, isUsableAsVertex as B, type Configurable as C, type Disarray as D, isDerived as E, isSlot as F, isComparisonSampler as G, isSampler as H, type Infer as I, isTexture as J, isUsableAsRender as K, type LogResources as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type ResolvedSnippet as R, ShelllessRepository as S, type TgpuSlot as T, isVariable as U, type TgpuGuardedComputePipeline as V, type Wgsl as W, type ValidateBufferSchema as X, type ValidateStorageSchema as Y, type ValidateUniformSchema as Z, type WithBinding as _, type TgpuDerived as a, type
|
|
5192
|
+
export { $internal as $, type AnyData as A, isUsableAsVertex as B, type Configurable as C, type Disarray as D, isDerived as E, isSlot as F, isComparisonSampler as G, isSampler as H, type Infer as I, isTexture as J, isUsableAsRender as K, type LogResources as L, isUsableAsSampled as M, isUsableAsStorage as N, isUsableAsUniform as O, isBufferShorthand as P, isTgpuFn as Q, type ResolvedSnippet as R, ShelllessRepository as S, type TgpuSlot as T, isVariable as U, type TgpuGuardedComputePipeline as V, type Wgsl as W, type ValidateBufferSchema as X, type ValidateStorageSchema as Y, type ValidateUniformSchema as Z, type WithBinding as _, type TgpuDerived as a, type Vec4h as a$, type WithCompute as a0, type WithFragment as a1, type WithVertex as a2, type Storage as a3, type StorageFlag as a4, type TgpuRenderPipeline as a5, type TgpuComputePipeline as a6, type IndexFlag as a7, type Uniform as a8, type UniformFlag as a9, type TgpuLayoutEntry as aA, type TgpuLayoutExternalTexture as aB, type TgpuLayoutSampler as aC, type TgpuLayoutStorage as aD, type TgpuLayoutTexture as aE, type TgpuLayoutUniform as aF, type TgpuFnShell as aG, type TgpuVertexFn as aH, type TgpuVertexFnShell as aI, type TgpuFragmentFn as aJ, type TgpuFragmentFnShell as aK, type TgpuComputeFn as aL, type TgpuComputeFnShell as aM, type TgpuDeclare as aN, type INTERNAL_GlobalExt as aO, type Vec2f as aP, type Vec2b as aQ, type Vec2h as aR, type Vec2i as aS, type Vec2u as aT, type Vec3b as aU, type Vec3f as aV, type Vec3h as aW, type Vec3i as aX, type Vec3u as aY, type Vec4b as aZ, type Vec4f as a_, type ValidUsagesFor as aa, type Vertex as ab, type VertexFlag as ac, type TgpuBufferMutable as ad, type TgpuBufferReadonly as ae, type TgpuBufferUniform as af, type TgpuMutable as ag, type TgpuReadonly as ah, type TgpuUniform as ai, type Eventual as aj, type TgpuTexture as ak, type TgpuTextureView as al, type TextureProps as am, type RenderFlag as an, type SampledFlag as ao, type TgpuConst as ap, type VariableScope as aq, type TgpuComparisonSampler as ar, type TgpuFixedComparisonSampler as as, type TgpuFixedSampler as at, type TgpuSampler as au, type TgpuQuerySet as av, type BindLayoutEntry as aw, type ExtractBindGroupInputFromLayout as ax, type LayoutEntryToInput as ay, type TgpuLayoutComparisonSampler as az, type TgpuBindGroupLayout as b, textureDepthCube as b$, type Vec4i as b0, type Vec4u as b1, type Bool as b2, type F16 as b3, type F32 as b4, type I32 as b5, type U16 as b6, type U32 as b7, type WgslStruct as b8, type DualFn as b9, type m4x4f as bA, type Mat2x2f as bB, type Mat3x3f as bC, type Mat4x4f as bD, type Size as bE, type v2b as bF, type v2f as bG, type v2i as bH, type v2u as bI, type v3b as bJ, type v3f as bK, type v3i as bL, type v3u as bM, type v4b as bN, type v4f as bO, type v4i as bP, type v4u as bQ, type AnyLooseData as bR, type LooseDecorated as bS, texture1d as bT, texture2d as bU, texture2dArray as bV, texture3d as bW, textureCube as bX, textureCubeArray as bY, textureDepth2d as bZ, textureDepth2dArray as b_, type StorableData as ba, type Ptr as bb, type BaseData as bc, type Unstruct as bd, type Atomic as be, isAlignAttrib as bf, isAtomic as bg, isBuiltinAttrib as bh, isDecorated as bi, isInterpolateAttrib as bj, isLocationAttrib as bk, isPtr as bl, isSizeAttrib as bm, isWgslArray as bn, isWgslData as bo, isWgslStruct as bp, Void as bq, type Align as br, type AnyVecInstance as bs, type AnyWgslStruct as bt, type Builtin as bu, type Decorated as bv, type Interpolate as bw, type Location as bx, type m2x2f as by, type m3x3f as bz, type TgpuBindGroup as c, type FormatToWGSLType as c$, textureDepthCubeArray as c0, textureDepthMultisampled2d as c1, textureExternal as c2, textureMultisampled2d as c3, textureStorage1d as c4, textureStorage2d as c5, textureStorage2dArray as c6, textureStorage3d as c7, type WgslExternalTexture as c8, type WgslStorageTexture as c9, invariant as cA, type IsBuiltin as cB, isBuiltin as cC, location as cD, size as cE, isData as cF, isDisarray as cG, isLooseData as cH, isLooseDecorated as cI, isUnstruct as cJ, builtin as cK, type AnyBuiltin as cL, type BuiltinClipDistances as cM, type BuiltinFragDepth as cN, type BuiltinFrontFacing as cO, type BuiltinGlobalInvocationId as cP, type BuiltinInstanceIndex as cQ, type BuiltinLocalInvocationId as cR, type BuiltinLocalInvocationIndex as cS, type BuiltinNumWorkgroups as cT, type BuiltinPosition as cU, type BuiltinSampleIndex as cV, type BuiltinSampleMask as cW, type BuiltinVertexIndex as cX, type BuiltinWorkgroupId as cY, type InferGPU as cZ, type InferPartial as c_, type WgslStorageTexture1d as ca, type WgslStorageTexture2d as cb, type WgslStorageTexture2dArray as cc, type WgslStorageTexture3d as cd, type WgslStorageTextureProps as ce, type WgslTexture as cf, type WgslTexture1d as cg, type WgslTexture2d as ch, type WgslTexture2dArray as ci, type WgslTexture3d as cj, type WgslTextureCube as ck, type WgslTextureCubeArray as cl, type WgslTextureDepth2d as cm, type WgslTextureDepth2dArray as cn, type WgslTextureDepthCube as co, type WgslTextureDepthCubeArray as cp, type WgslTextureDepthMultisampled2d as cq, type WgslTextureMultisampled2d as cr, comparisonSampler as cs, sampler as ct, type WgslComparisonSampler as cu, type WgslSampler as cv, align as cw, type AnyAttribute as cx, type HasCustomLocation as cy, interpolate as cz, type WgslExtension as d, type atomicI32 as d$, type TgpuVertexFormatData as d0, formatToWGSLType as d1, packedFormats as d2, uint8 as d3, uint8x2 as d4, uint8x4 as d5, sint8 as d6, sint8x2 as d7, sint8x4 as d8, unorm8 as d9, uint32x2 as dA, uint32x3 as dB, uint32x4 as dC, sint32 as dD, sint32x2 as dE, sint32x3 as dF, sint32x4 as dG, unorm10_10_10_2 as dH, unorm8x4_bgra as dI, type PackedData as dJ, isPackedData as dK, type AnyNumericVecInstance as dL, type AnyFloatVecInstance as dM, type AnyIntegerVecInstance as dN, type v3h as dO, type AnyMatInstance as dP, type AbstractFloat as dQ, type AbstractInt as dR, type v2h as dS, type v4h as dT, type AnyFloat32VecInstance as dU, type AnySignedVecInstance as dV, type vBaseForMat as dW, type mBaseForVec as dX, type AnyVec2Instance as dY, type AnyVec3Instance as dZ, type AnyBooleanVecInstance as d_, unorm8x2 as da, unorm8x4 as db, snorm8 as dc, snorm8x2 as dd, snorm8x4 as de, uint16 as df, uint16x2 as dg, uint16x4 as dh, sint16 as di, sint16x2 as dj, sint16x4 as dk, unorm16 as dl, unorm16x2 as dm, unorm16x4 as dn, snorm16 as dp, snorm16x2 as dq, snorm16x4 as dr, float16 as ds, float16x2 as dt, float16x4 as du, float32 as dv, float32x2 as dw, float32x3 as dx, float32x4 as dy, uint32 as dz, type ShaderGenerator as e, type atomicU32 as e0, type StorageTextureFormats as e1, type TextureFormats as e2, $repr as e3, type TgpuBuffer as f, type TgpuVar as g, type LogGeneratorOptions as h, type TgpuRoot as i, type AnyWgslData as j, type TgpuFn as k, type TgpuBufferUsage as l, type TgpuAccessor as m, type TgpuVertexLayout as n, type WgslArray as o, fn as p, bindGroupLayout as q, privateVar as r, constant as s, fragmentFn as t, vertexFn as u, vertexLayout as v, workgroupVar as w, computeFn as x, declare as y, isBuffer as z };
|