@nodetool-ai/gpu 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 +52 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/blend/blendModes.d.ts +67 -0
- package/dist/blend/blendModes.d.ts.map +1 -0
- package/dist/blend/blendModes.js +80 -0
- package/dist/blend/blendModes.js.map +1 -0
- package/dist/blend/index.d.ts +10 -0
- package/dist/blend/index.d.ts.map +1 -0
- package/dist/blend/index.js +10 -0
- package/dist/blend/index.js.map +1 -0
- package/dist/blend/wgsl.d.ts +16 -0
- package/dist/blend/wgsl.d.ts.map +1 -0
- package/dist/blend/wgsl.js +85 -0
- package/dist/blend/wgsl.js.map +1 -0
- package/dist/compositor/compositor.d.ts +112 -0
- package/dist/compositor/compositor.d.ts.map +1 -0
- package/dist/compositor/compositor.js +353 -0
- package/dist/compositor/compositor.js.map +1 -0
- package/dist/compositor/headless.d.ts +47 -0
- package/dist/compositor/headless.d.ts.map +1 -0
- package/dist/compositor/headless.js +158 -0
- package/dist/compositor/headless.js.map +1 -0
- package/dist/compositor/index.d.ts +8 -0
- package/dist/compositor/index.d.ts.map +1 -0
- package/dist/compositor/index.js +8 -0
- package/dist/compositor/index.js.map +1 -0
- package/dist/compositor/shaders.d.ts +24 -0
- package/dist/compositor/shaders.d.ts.map +1 -0
- package/dist/compositor/shaders.js +241 -0
- package/dist/compositor/shaders.js.map +1 -0
- package/dist/compositor/transform.d.ts +49 -0
- package/dist/compositor/transform.d.ts.map +1 -0
- package/dist/compositor/transform.js +74 -0
- package/dist/compositor/transform.js.map +1 -0
- package/dist/context.d.ts +108 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +205 -0
- package/dist/context.js.map +1 -0
- package/dist/debug/premulValidator.d.ts +85 -0
- package/dist/debug/premulValidator.d.ts.map +1 -0
- package/dist/debug/premulValidator.js +239 -0
- package/dist/debug/premulValidator.js.map +1 -0
- package/dist/executor.d.ts +74 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +413 -0
- package/dist/executor.js.map +1 -0
- package/dist/fullscreenQuad.d.ts +11 -0
- package/dist/fullscreenQuad.d.ts.map +1 -0
- package/dist/fullscreenQuad.js +31 -0
- package/dist/fullscreenQuad.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +162 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +100 -0
- package/dist/module.js.map +1 -0
- package/dist/node.d.ts +38 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +140 -0
- package/dist/node.js.map +1 -0
- package/dist/pool.d.ts +30 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +33 -0
- package/dist/pool.js.map +1 -0
- package/dist/recipe.d.ts +148 -0
- package/dist/recipe.d.ts.map +1 -0
- package/dist/recipe.js +181 -0
- package/dist/recipe.js.map +1 -0
- package/dist/registry.d.ts +49 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +100 -0
- package/dist/registry.js.map +1 -0
- package/dist/shaders/_canary/passthrough/v1/module.d.ts +13 -0
- package/dist/shaders/_canary/passthrough/v1/module.d.ts.map +1 -0
- package/dist/shaders/_canary/passthrough/v1/module.js +71 -0
- package/dist/shaders/_canary/passthrough/v1/module.js.map +1 -0
- package/dist/shaders/alpha/premulToStraight/v1/module.d.ts +16 -0
- package/dist/shaders/alpha/premulToStraight/v1/module.d.ts.map +1 -0
- package/dist/shaders/alpha/premulToStraight/v1/module.js +62 -0
- package/dist/shaders/alpha/premulToStraight/v1/module.js.map +1 -0
- package/dist/shaders/alpha/straightToPremul/v1/module.d.ts +19 -0
- package/dist/shaders/alpha/straightToPremul/v1/module.d.ts.map +1 -0
- package/dist/shaders/alpha/straightToPremul/v1/module.js +61 -0
- package/dist/shaders/alpha/straightToPremul/v1/module.js.map +1 -0
- package/dist/shaders/color/brightnessContrast/v1/module.d.ts +17 -0
- package/dist/shaders/color/brightnessContrast/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/brightnessContrast/v1/module.js +84 -0
- package/dist/shaders/color/brightnessContrast/v1/module.js.map +1 -0
- package/dist/shaders/color/cdl/v1/module.d.ts +35 -0
- package/dist/shaders/color/cdl/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/cdl/v1/module.js +106 -0
- package/dist/shaders/color/cdl/v1/module.js.map +1 -0
- package/dist/shaders/color/channelMerge/v1/module.d.ts +22 -0
- package/dist/shaders/color/channelMerge/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/channelMerge/v1/module.js +101 -0
- package/dist/shaders/color/channelMerge/v1/module.js.map +1 -0
- package/dist/shaders/color/channelShuffle/v1/module.d.ts +29 -0
- package/dist/shaders/color/channelShuffle/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/channelShuffle/v1/module.js +94 -0
- package/dist/shaders/color/channelShuffle/v1/module.js.map +1 -0
- package/dist/shaders/color/channelSplit/v1/module.d.ts +18 -0
- package/dist/shaders/color/channelSplit/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/channelSplit/v1/module.js +90 -0
- package/dist/shaders/color/channelSplit/v1/module.js.map +1 -0
- package/dist/shaders/color/colorBalance/v1/module.d.ts +18 -0
- package/dist/shaders/color/colorBalance/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/colorBalance/v1/module.js +86 -0
- package/dist/shaders/color/colorBalance/v1/module.js.map +1 -0
- package/dist/shaders/color/cubeLut/v1/module.d.ts +14 -0
- package/dist/shaders/color/cubeLut/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/cubeLut/v1/module.js +78 -0
- package/dist/shaders/color/cubeLut/v1/module.js.map +1 -0
- package/dist/shaders/color/curves/v1/module.d.ts +31 -0
- package/dist/shaders/color/curves/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/curves/v1/module.js +102 -0
- package/dist/shaders/color/curves/v1/module.js.map +1 -0
- package/dist/shaders/color/exposure/v1/module.d.ts +15 -0
- package/dist/shaders/color/exposure/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/exposure/v1/module.js +78 -0
- package/dist/shaders/color/exposure/v1/module.js.map +1 -0
- package/dist/shaders/color/exposureTone/v1/module.d.ts +28 -0
- package/dist/shaders/color/exposureTone/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/exposureTone/v1/module.js +107 -0
- package/dist/shaders/color/exposureTone/v1/module.js.map +1 -0
- package/dist/shaders/color/filmLook/v1/module.d.ts +28 -0
- package/dist/shaders/color/filmLook/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/filmLook/v1/module.js +103 -0
- package/dist/shaders/color/filmLook/v1/module.js.map +1 -0
- package/dist/shaders/color/grade/v1/module.d.ts +35 -0
- package/dist/shaders/color/grade/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/grade/v1/module.js +182 -0
- package/dist/shaders/color/grade/v1/module.js.map +1 -0
- package/dist/shaders/color/grayscale/v1/module.d.ts +14 -0
- package/dist/shaders/color/grayscale/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/grayscale/v1/module.js +79 -0
- package/dist/shaders/color/grayscale/v1/module.js.map +1 -0
- package/dist/shaders/color/hsb/v1/module.d.ts +20 -0
- package/dist/shaders/color/hsb/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/hsb/v1/module.js +131 -0
- package/dist/shaders/color/hsb/v1/module.js.map +1 -0
- package/dist/shaders/color/hslAdjust/v1/module.d.ts +30 -0
- package/dist/shaders/color/hslAdjust/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/hslAdjust/v1/module.js +170 -0
- package/dist/shaders/color/hslAdjust/v1/module.js.map +1 -0
- package/dist/shaders/color/invert/v1/module.d.ts +15 -0
- package/dist/shaders/color/invert/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/invert/v1/module.js +85 -0
- package/dist/shaders/color/invert/v1/module.js.map +1 -0
- package/dist/shaders/color/levels/v1/module.d.ts +33 -0
- package/dist/shaders/color/levels/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/levels/v1/module.js +116 -0
- package/dist/shaders/color/levels/v1/module.js.map +1 -0
- package/dist/shaders/color/liftGammaGain/v1/module.d.ts +40 -0
- package/dist/shaders/color/liftGammaGain/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/liftGammaGain/v1/module.js +114 -0
- package/dist/shaders/color/liftGammaGain/v1/module.js.map +1 -0
- package/dist/shaders/color/posterize/v1/module.d.ts +16 -0
- package/dist/shaders/color/posterize/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/posterize/v1/module.js +80 -0
- package/dist/shaders/color/posterize/v1/module.js.map +1 -0
- package/dist/shaders/color/solarize/v1/module.d.ts +15 -0
- package/dist/shaders/color/solarize/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/solarize/v1/module.js +83 -0
- package/dist/shaders/color/solarize/v1/module.js.map +1 -0
- package/dist/shaders/color/splitToning/v1/module.d.ts +26 -0
- package/dist/shaders/color/splitToning/v1/module.d.ts.map +1 -0
- package/dist/shaders/color/splitToning/v1/module.js +95 -0
- package/dist/shaders/color/splitToning/v1/module.js.map +1 -0
- package/dist/shaders/filters/blur/gaussian/v1/module.d.ts +23 -0
- package/dist/shaders/filters/blur/gaussian/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/blur/gaussian/v1/module.js +110 -0
- package/dist/shaders/filters/blur/gaussian/v1/module.js.map +1 -0
- package/dist/shaders/filters/blur/separable/v1/module.d.ts +18 -0
- package/dist/shaders/filters/blur/separable/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/blur/separable/v1/module.js +64 -0
- package/dist/shaders/filters/blur/separable/v1/module.js.map +1 -0
- package/dist/shaders/filters/convolve3x3/v1/module.d.ts +23 -0
- package/dist/shaders/filters/convolve3x3/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/convolve3x3/v1/module.js +128 -0
- package/dist/shaders/filters/convolve3x3/v1/module.js.map +1 -0
- package/dist/shaders/filters/glow/v1/module.d.ts +26 -0
- package/dist/shaders/filters/glow/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/glow/v1/module.js +102 -0
- package/dist/shaders/filters/glow/v1/module.js.map +1 -0
- package/dist/shaders/filters/grain/v1/module.d.ts +38 -0
- package/dist/shaders/filters/grain/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/grain/v1/module.js +110 -0
- package/dist/shaders/filters/grain/v1/module.js.map +1 -0
- package/dist/shaders/filters/pixelate/v1/module.d.ts +14 -0
- package/dist/shaders/filters/pixelate/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/pixelate/v1/module.js +76 -0
- package/dist/shaders/filters/pixelate/v1/module.js.map +1 -0
- package/dist/shaders/filters/sharpen/unsharpMask/v1/module.d.ts +17 -0
- package/dist/shaders/filters/sharpen/unsharpMask/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/sharpen/unsharpMask/v1/module.js +93 -0
- package/dist/shaders/filters/sharpen/unsharpMask/v1/module.js.map +1 -0
- package/dist/shaders/filters/threshold/v1/module.d.ts +17 -0
- package/dist/shaders/filters/threshold/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/threshold/v1/module.js +71 -0
- package/dist/shaders/filters/threshold/v1/module.js.map +1 -0
- package/dist/shaders/filters/vignette/v1/module.d.ts +18 -0
- package/dist/shaders/filters/vignette/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/vignette/v1/module.js +78 -0
- package/dist/shaders/filters/vignette/v1/module.js.map +1 -0
- package/dist/shaders/filters/visualFx/v1/module.d.ts +24 -0
- package/dist/shaders/filters/visualFx/v1/module.d.ts.map +1 -0
- package/dist/shaders/filters/visualFx/v1/module.js +210 -0
- package/dist/shaders/filters/visualFx/v1/module.js.map +1 -0
- package/dist/shaders/index.d.ts +86 -0
- package/dist/shaders/index.d.ts.map +1 -0
- package/dist/shaders/index.js +161 -0
- package/dist/shaders/index.js.map +1 -0
- package/dist/shaders/keyer/chromaKey/v1/module.d.ts +25 -0
- package/dist/shaders/keyer/chromaKey/v1/module.d.ts.map +1 -0
- package/dist/shaders/keyer/chromaKey/v1/module.js +111 -0
- package/dist/shaders/keyer/chromaKey/v1/module.js.map +1 -0
- package/dist/shaders/keyer/lumaKey/v1/module.d.ts +22 -0
- package/dist/shaders/keyer/lumaKey/v1/module.d.ts.map +1 -0
- package/dist/shaders/keyer/lumaKey/v1/module.js +89 -0
- package/dist/shaders/keyer/lumaKey/v1/module.js.map +1 -0
- package/dist/shaders/mask/apply/v1/module.d.ts +16 -0
- package/dist/shaders/mask/apply/v1/module.d.ts.map +1 -0
- package/dist/shaders/mask/apply/v1/module.js +79 -0
- package/dist/shaders/mask/apply/v1/module.js.map +1 -0
- package/dist/shaders/mask/fromImage/v1/module.d.ts +18 -0
- package/dist/shaders/mask/fromImage/v1/module.d.ts.map +1 -0
- package/dist/shaders/mask/fromImage/v1/module.js +99 -0
- package/dist/shaders/mask/fromImage/v1/module.js.map +1 -0
- package/dist/shaders/mask/invert/v1/module.d.ts +12 -0
- package/dist/shaders/mask/invert/v1/module.d.ts.map +1 -0
- package/dist/shaders/mask/invert/v1/module.js +57 -0
- package/dist/shaders/mask/invert/v1/module.js.map +1 -0
- package/dist/shaders/mixer/add/v1/module.d.ts +17 -0
- package/dist/shaders/mixer/add/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/add/v1/module.js +73 -0
- package/dist/shaders/mixer/add/v1/module.js.map +1 -0
- package/dist/shaders/mixer/colorOverlay/v1/module.d.ts +26 -0
- package/dist/shaders/mixer/colorOverlay/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/colorOverlay/v1/module.js +81 -0
- package/dist/shaders/mixer/colorOverlay/v1/module.js.map +1 -0
- package/dist/shaders/mixer/dropShadow/v1/module.d.ts +28 -0
- package/dist/shaders/mixer/dropShadow/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/dropShadow/v1/module.js +104 -0
- package/dist/shaders/mixer/dropShadow/v1/module.js.map +1 -0
- package/dist/shaders/mixer/outline/v1/module.d.ts +27 -0
- package/dist/shaders/mixer/outline/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/outline/v1/module.js +105 -0
- package/dist/shaders/mixer/outline/v1/module.js.map +1 -0
- package/dist/shaders/mixer/over/v1/module.d.ts +16 -0
- package/dist/shaders/mixer/over/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/over/v1/module.js +71 -0
- package/dist/shaders/mixer/over/v1/module.js.map +1 -0
- package/dist/shaders/mixer/shadowCompose/v1/module.d.ts +26 -0
- package/dist/shaders/mixer/shadowCompose/v1/module.d.ts.map +1 -0
- package/dist/shaders/mixer/shadowCompose/v1/module.js +95 -0
- package/dist/shaders/mixer/shadowCompose/v1/module.js.map +1 -0
- package/dist/shaders/sources/angularGradient/v1/module.d.ts +18 -0
- package/dist/shaders/sources/angularGradient/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/angularGradient/v1/module.js +67 -0
- package/dist/shaders/sources/angularGradient/v1/module.js.map +1 -0
- package/dist/shaders/sources/checkerboard/v1/module.d.ts +19 -0
- package/dist/shaders/sources/checkerboard/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/checkerboard/v1/module.js +70 -0
- package/dist/shaders/sources/checkerboard/v1/module.js.map +1 -0
- package/dist/shaders/sources/diamondGradient/v1/module.d.ts +18 -0
- package/dist/shaders/sources/diamondGradient/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/diamondGradient/v1/module.js +61 -0
- package/dist/shaders/sources/diamondGradient/v1/module.js.map +1 -0
- package/dist/shaders/sources/gaussianNoise/v1/module.d.ts +21 -0
- package/dist/shaders/sources/gaussianNoise/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/gaussianNoise/v1/module.js +72 -0
- package/dist/shaders/sources/gaussianNoise/v1/module.js.map +1 -0
- package/dist/shaders/sources/linearGradient/v1/module.d.ts +21 -0
- package/dist/shaders/sources/linearGradient/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/linearGradient/v1/module.js +72 -0
- package/dist/shaders/sources/linearGradient/v1/module.js.map +1 -0
- package/dist/shaders/sources/radialGradient/v1/module.d.ts +18 -0
- package/dist/shaders/sources/radialGradient/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/radialGradient/v1/module.js +60 -0
- package/dist/shaders/sources/radialGradient/v1/module.js.map +1 -0
- package/dist/shaders/sources/solid/v1/module.d.ts +17 -0
- package/dist/shaders/sources/solid/v1/module.d.ts.map +1 -0
- package/dist/shaders/sources/solid/v1/module.js +49 -0
- package/dist/shaders/sources/solid/v1/module.js.map +1 -0
- package/dist/shaders/transform/affine/v1/module.d.ts +36 -0
- package/dist/shaders/transform/affine/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/affine/v1/module.js +94 -0
- package/dist/shaders/transform/affine/v1/module.js.map +1 -0
- package/dist/shaders/transform/cornerPin/v1/module.d.ts +40 -0
- package/dist/shaders/transform/cornerPin/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/cornerPin/v1/module.js +109 -0
- package/dist/shaders/transform/cornerPin/v1/module.js.map +1 -0
- package/dist/shaders/transform/crop/v1/module.d.ts +26 -0
- package/dist/shaders/transform/crop/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/crop/v1/module.js +82 -0
- package/dist/shaders/transform/crop/v1/module.js.map +1 -0
- package/dist/shaders/transform/displace/v1/module.d.ts +23 -0
- package/dist/shaders/transform/displace/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/displace/v1/module.js +95 -0
- package/dist/shaders/transform/displace/v1/module.js.map +1 -0
- package/dist/shaders/transform/mirror/v1/module.d.ts +14 -0
- package/dist/shaders/transform/mirror/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/mirror/v1/module.js +73 -0
- package/dist/shaders/transform/mirror/v1/module.js.map +1 -0
- package/dist/shaders/transform/offset/v1/module.d.ts +21 -0
- package/dist/shaders/transform/offset/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/offset/v1/module.js +88 -0
- package/dist/shaders/transform/offset/v1/module.js.map +1 -0
- package/dist/shaders/transform/pad/v1/module.d.ts +26 -0
- package/dist/shaders/transform/pad/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/pad/v1/module.js +95 -0
- package/dist/shaders/transform/pad/v1/module.js.map +1 -0
- package/dist/shaders/transform/polarRemap/v1/module.d.ts +20 -0
- package/dist/shaders/transform/polarRemap/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/polarRemap/v1/module.js +95 -0
- package/dist/shaders/transform/polarRemap/v1/module.js.map +1 -0
- package/dist/shaders/transform/resize/v1/module.d.ts +20 -0
- package/dist/shaders/transform/resize/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/resize/v1/module.js +116 -0
- package/dist/shaders/transform/resize/v1/module.js.map +1 -0
- package/dist/shaders/transform/rotate90/v1/module.d.ts +25 -0
- package/dist/shaders/transform/rotate90/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/rotate90/v1/module.js +90 -0
- package/dist/shaders/transform/rotate90/v1/module.js.map +1 -0
- package/dist/shaders/transform/spherize/v1/module.d.ts +21 -0
- package/dist/shaders/transform/spherize/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/spherize/v1/module.js +94 -0
- package/dist/shaders/transform/spherize/v1/module.js.map +1 -0
- package/dist/shaders/transform/tile/v1/module.d.ts +22 -0
- package/dist/shaders/transform/tile/v1/module.d.ts.map +1 -0
- package/dist/shaders/transform/tile/v1/module.js +89 -0
- package/dist/shaders/transform/tile/v1/module.js.map +1 -0
- package/dist/shared/lumaWgsl.d.ts +14 -0
- package/dist/shared/lumaWgsl.d.ts.map +1 -0
- package/dist/shared/lumaWgsl.js +18 -0
- package/dist/shared/lumaWgsl.js.map +1 -0
- package/dist/shared/premulWgsl.d.ts +46 -0
- package/dist/shared/premulWgsl.d.ts.map +1 -0
- package/dist/shared/premulWgsl.js +90 -0
- package/dist/shared/premulWgsl.js.map +1 -0
- package/dist/texture.d.ts +54 -0
- package/dist/texture.d.ts.map +1 -0
- package/dist/texture.js +70 -0
- package/dist/texture.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/validate/wgslLinearity.d.ts +86 -0
- package/dist/validate/wgslLinearity.d.ts.map +1 -0
- package/dist/validate/wgslLinearity.js +298 -0
- package/dist/validate/wgslLinearity.js.map +1 -0
- package/dist/webgpu/index.d.ts +11 -0
- package/dist/webgpu/index.d.ts.map +1 -0
- package/dist/webgpu/index.js +11 -0
- package/dist/webgpu/index.js.map +1 -0
- package/package.json +85 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared shader-pool contracts. Pure types + small const tuples — no WebGPU
|
|
3
|
+
* runtime, Node-safe. The pool's atomic unit of reuse is a {@link
|
|
4
|
+
* ShaderModule} (see `module.ts`); these are the vocabulary its fields are
|
|
5
|
+
* built from.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load-time WGSL static validator for the premul-invariant `linearity` tag.
|
|
3
|
+
*
|
|
4
|
+
* Item 3 of the shader-pool invariant enforcement plan. Runs inside
|
|
5
|
+
* {@link defineModule} after `tgpu.resolve(...)` and rejects modules whose
|
|
6
|
+
* WGSL contradicts their declared {@link LinearityMode}. Failures are throws
|
|
7
|
+
* so a misclassified module never reaches the registry.
|
|
8
|
+
*
|
|
9
|
+
* ## What it checks
|
|
10
|
+
*
|
|
11
|
+
* | `linearity` | rule |
|
|
12
|
+
* |---------------------|------------------------------------------------------------------------|
|
|
13
|
+
* | `"source"` | skipped — no input to validate |
|
|
14
|
+
* | `"alpha-only"` | output RGB must be literal zero (no `.r/.g/.b/.rgb` written to return) |
|
|
15
|
+
* | `"linear-in-rgb"` | flag nonlinear tokens (`pow|log|sqrt|step|smoothstep|floor|...`) on |
|
|
16
|
+
* | | the same line as a `.rgb` access |
|
|
17
|
+
* | `"nonlinear-in-rgb"`| must show the unpremul handshake (`unpremul` token, `.rgb /` divide, |
|
|
18
|
+
* | | or all inputs declared `alpha: "straight"`) whenever a sample variable |
|
|
19
|
+
* | | is dereferenced with `.rgb` |
|
|
20
|
+
*
|
|
21
|
+
* ## Brittleness — read before tightening
|
|
22
|
+
*
|
|
23
|
+
* Pure string analysis, no AST. The WGSL grammar is rich (block comments,
|
|
24
|
+
* raw strings, multi-line expressions, identifier shadowing) and this scanner
|
|
25
|
+
* cannot follow any of it. Concrete known limits:
|
|
26
|
+
*
|
|
27
|
+
* - **Line-level scope.** Co-occurrence rules ("`pow` and `.rgb` on the same
|
|
28
|
+
* line") miss multi-line expressions and over-trigger on dense lines.
|
|
29
|
+
* - **Per-file unpremul check.** The nonlinear-in-rgb rule treats a single
|
|
30
|
+
* `unpremul` or `.rgb /` token anywhere in the file as the handshake — it
|
|
31
|
+
* does not prove the unpremul happens **before** the `.rgb` read. A shader
|
|
32
|
+
* that unpremuls at the end after using `.rgb` will spuriously pass.
|
|
33
|
+
* - **Sample variable detection.** We look for `let X = textureSample(...)` /
|
|
34
|
+
* `let X = textureLoad(...)` (also `var X = ...`); only those `X.rgb`
|
|
35
|
+
* references are treated as "premul .rgb access". Direct `textureSample(...).rgb`
|
|
36
|
+
* without an intermediate name is also recognized. Params-field references
|
|
37
|
+
* like `p.color.rgb` are intentionally not flagged.
|
|
38
|
+
* - **Block comments.** `/* … */` blocks are not stripped. A nonlinear token
|
|
39
|
+
* buried in a comment will be treated as code. Same-line `//` comments are
|
|
40
|
+
* preserved so the suppression token below works.
|
|
41
|
+
*
|
|
42
|
+
* False positives are the failure mode — they break the build. The suppression
|
|
43
|
+
* token (`// premul: ok`) is the escape hatch. False negatives merely defer the
|
|
44
|
+
* catch to the runtime debug pass.
|
|
45
|
+
*
|
|
46
|
+
* ## Suppression
|
|
47
|
+
*
|
|
48
|
+
* Add one of these tokens as a `//` comment on the same line as the offending
|
|
49
|
+
* op to silence the validator for that line:
|
|
50
|
+
*
|
|
51
|
+
* - `// premul: ok`
|
|
52
|
+
* - `// premul: linear-safe`
|
|
53
|
+
* - `// premul: handled`
|
|
54
|
+
*
|
|
55
|
+
* Pair the suppression with a TODO comment when the underlying shader is
|
|
56
|
+
* actually buggy (so the deferred work is still tracked).
|
|
57
|
+
*
|
|
58
|
+
* ## Cost
|
|
59
|
+
*
|
|
60
|
+
* Module-load-time: regex over a ~200-line string, done once per `defineModule`
|
|
61
|
+
* call. Target: under 1 ms per module on modern hardware.
|
|
62
|
+
*
|
|
63
|
+
* ## Escape hatch
|
|
64
|
+
*
|
|
65
|
+
* Set `NODETOOL_GPU_VALIDATE=off` to disable the validator entirely. Useful for
|
|
66
|
+
* hotfixes where a misclassified module must ship before the WGSL can be
|
|
67
|
+
* corrected. Read once at module load via `globalThis.process?.env`.
|
|
68
|
+
*/
|
|
69
|
+
import type { InputContract, LinearityMode } from "../types.js";
|
|
70
|
+
interface LinearityValidationResult {
|
|
71
|
+
ok: boolean;
|
|
72
|
+
violations: string[];
|
|
73
|
+
}
|
|
74
|
+
interface LinearityValidationArgs {
|
|
75
|
+
id: string;
|
|
76
|
+
linearity: LinearityMode;
|
|
77
|
+
wgsl: string;
|
|
78
|
+
inputs: Record<string, InputContract>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Validate that the resolved WGSL is consistent with its declared
|
|
82
|
+
* {@link LinearityMode}. Returns `{ ok, violations }`; the caller throws.
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateWgslLinearity(args: LinearityValidationArgs): LinearityValidationResult;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=wgslLinearity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgslLinearity.d.ts","sourceRoot":"","sources":["../../src/validate/wgslLinearity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuChE,UAAU,yBAAyB;IACjC,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACvC;AA4KD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,uBAAuB,GAC5B,yBAAyB,CA6B3B"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load-time WGSL static validator for the premul-invariant `linearity` tag.
|
|
3
|
+
*
|
|
4
|
+
* Item 3 of the shader-pool invariant enforcement plan. Runs inside
|
|
5
|
+
* {@link defineModule} after `tgpu.resolve(...)` and rejects modules whose
|
|
6
|
+
* WGSL contradicts their declared {@link LinearityMode}. Failures are throws
|
|
7
|
+
* so a misclassified module never reaches the registry.
|
|
8
|
+
*
|
|
9
|
+
* ## What it checks
|
|
10
|
+
*
|
|
11
|
+
* | `linearity` | rule |
|
|
12
|
+
* |---------------------|------------------------------------------------------------------------|
|
|
13
|
+
* | `"source"` | skipped — no input to validate |
|
|
14
|
+
* | `"alpha-only"` | output RGB must be literal zero (no `.r/.g/.b/.rgb` written to return) |
|
|
15
|
+
* | `"linear-in-rgb"` | flag nonlinear tokens (`pow|log|sqrt|step|smoothstep|floor|...`) on |
|
|
16
|
+
* | | the same line as a `.rgb` access |
|
|
17
|
+
* | `"nonlinear-in-rgb"`| must show the unpremul handshake (`unpremul` token, `.rgb /` divide, |
|
|
18
|
+
* | | or all inputs declared `alpha: "straight"`) whenever a sample variable |
|
|
19
|
+
* | | is dereferenced with `.rgb` |
|
|
20
|
+
*
|
|
21
|
+
* ## Brittleness — read before tightening
|
|
22
|
+
*
|
|
23
|
+
* Pure string analysis, no AST. The WGSL grammar is rich (block comments,
|
|
24
|
+
* raw strings, multi-line expressions, identifier shadowing) and this scanner
|
|
25
|
+
* cannot follow any of it. Concrete known limits:
|
|
26
|
+
*
|
|
27
|
+
* - **Line-level scope.** Co-occurrence rules ("`pow` and `.rgb` on the same
|
|
28
|
+
* line") miss multi-line expressions and over-trigger on dense lines.
|
|
29
|
+
* - **Per-file unpremul check.** The nonlinear-in-rgb rule treats a single
|
|
30
|
+
* `unpremul` or `.rgb /` token anywhere in the file as the handshake — it
|
|
31
|
+
* does not prove the unpremul happens **before** the `.rgb` read. A shader
|
|
32
|
+
* that unpremuls at the end after using `.rgb` will spuriously pass.
|
|
33
|
+
* - **Sample variable detection.** We look for `let X = textureSample(...)` /
|
|
34
|
+
* `let X = textureLoad(...)` (also `var X = ...`); only those `X.rgb`
|
|
35
|
+
* references are treated as "premul .rgb access". Direct `textureSample(...).rgb`
|
|
36
|
+
* without an intermediate name is also recognized. Params-field references
|
|
37
|
+
* like `p.color.rgb` are intentionally not flagged.
|
|
38
|
+
* - **Block comments.** `/* … */` blocks are not stripped. A nonlinear token
|
|
39
|
+
* buried in a comment will be treated as code. Same-line `//` comments are
|
|
40
|
+
* preserved so the suppression token below works.
|
|
41
|
+
*
|
|
42
|
+
* False positives are the failure mode — they break the build. The suppression
|
|
43
|
+
* token (`// premul: ok`) is the escape hatch. False negatives merely defer the
|
|
44
|
+
* catch to the runtime debug pass.
|
|
45
|
+
*
|
|
46
|
+
* ## Suppression
|
|
47
|
+
*
|
|
48
|
+
* Add one of these tokens as a `//` comment on the same line as the offending
|
|
49
|
+
* op to silence the validator for that line:
|
|
50
|
+
*
|
|
51
|
+
* - `// premul: ok`
|
|
52
|
+
* - `// premul: linear-safe`
|
|
53
|
+
* - `// premul: handled`
|
|
54
|
+
*
|
|
55
|
+
* Pair the suppression with a TODO comment when the underlying shader is
|
|
56
|
+
* actually buggy (so the deferred work is still tracked).
|
|
57
|
+
*
|
|
58
|
+
* ## Cost
|
|
59
|
+
*
|
|
60
|
+
* Module-load-time: regex over a ~200-line string, done once per `defineModule`
|
|
61
|
+
* call. Target: under 1 ms per module on modern hardware.
|
|
62
|
+
*
|
|
63
|
+
* ## Escape hatch
|
|
64
|
+
*
|
|
65
|
+
* Set `NODETOOL_GPU_VALIDATE=off` to disable the validator entirely. Useful for
|
|
66
|
+
* hotfixes where a misclassified module must ship before the WGSL can be
|
|
67
|
+
* corrected. Read once at module load via `globalThis.process?.env`.
|
|
68
|
+
*/
|
|
69
|
+
/** Comment tokens that suppress a line-level violation. */
|
|
70
|
+
const SUPPRESSION_TOKENS = [
|
|
71
|
+
"premul: ok",
|
|
72
|
+
"premul: linear-safe",
|
|
73
|
+
"premul: handled"
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Tokens treated as nonlinear ops for the `linear-in-rgb` heuristic. The check
|
|
77
|
+
* looks for any of these followed by `(` on the same line as a `.rgb` access.
|
|
78
|
+
* `clamp` is intentionally absent — `clamp(x, 0, 1)` is a saturate (linear-safe).
|
|
79
|
+
*/
|
|
80
|
+
const NONLINEAR_TOKENS = [
|
|
81
|
+
"pow",
|
|
82
|
+
"log",
|
|
83
|
+
"log2",
|
|
84
|
+
"exp",
|
|
85
|
+
"exp2",
|
|
86
|
+
"sqrt",
|
|
87
|
+
"smoothstep",
|
|
88
|
+
"step",
|
|
89
|
+
"floor",
|
|
90
|
+
"ceil",
|
|
91
|
+
"round",
|
|
92
|
+
"trunc",
|
|
93
|
+
"fract"
|
|
94
|
+
];
|
|
95
|
+
const NONLINEAR_RE = new RegExp(`\\b(?:${NONLINEAR_TOKENS.join("|")})\\s*\\(`);
|
|
96
|
+
const RGB_RE = /\.rgb\b/;
|
|
97
|
+
// `[^=\n]+` keeps the optional type annotation from chewing across newlines —
|
|
98
|
+
// without the `\n` exclusion, `var source: texture_2d<f32>;` would greedily
|
|
99
|
+
// match past intervening lines until it found a later `= textureSample(...)`,
|
|
100
|
+
// polluting the sample-variable set with binding-declaration names.
|
|
101
|
+
const SAMPLE_DECL_RE = /\b(?:let|var)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*[^=\n]+)?=\s*(?:textureSample|textureLoad)\b/g;
|
|
102
|
+
/**
|
|
103
|
+
* Read the env-flag once per process. `off` disables the validator entirely.
|
|
104
|
+
* Anything else (including unset) leaves it enabled.
|
|
105
|
+
*/
|
|
106
|
+
function validatorDisabled() {
|
|
107
|
+
// SAFETY: this package compiles without @types/node, so `process` is not a
|
|
108
|
+
// declared global here. The asserted shape only claims optional members, and
|
|
109
|
+
// the optional chain reads the flag as unset in a host that has no
|
|
110
|
+
// `process` (browser, worker) — which leaves the validator enabled.
|
|
111
|
+
const env = globalThis
|
|
112
|
+
.process?.env;
|
|
113
|
+
return env?.NODETOOL_GPU_VALIDATE === "off";
|
|
114
|
+
}
|
|
115
|
+
/** True if the line contains one of the suppression tokens in a `//` comment. */
|
|
116
|
+
function lineSuppressed(line) {
|
|
117
|
+
const slash = line.indexOf("//");
|
|
118
|
+
if (slash === -1)
|
|
119
|
+
return false;
|
|
120
|
+
const comment = line.slice(slash).toLowerCase();
|
|
121
|
+
return SUPPRESSION_TOKENS.some((token) => comment.includes(token));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Find every variable name declared as `let X = textureSample(...)` or
|
|
125
|
+
* `let X = textureLoad(...)` (also `var X = …`). Returned in declaration
|
|
126
|
+
* order, deduplicated.
|
|
127
|
+
*/
|
|
128
|
+
function findSampleVariables(wgsl) {
|
|
129
|
+
const out = new Set();
|
|
130
|
+
for (const match of wgsl.matchAll(SAMPLE_DECL_RE)) {
|
|
131
|
+
out.add(match[1]);
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* True iff `line` reads `.rgb` from one of the named sample variables, or
|
|
137
|
+
* directly off `textureSample(...).rgb` / `textureLoad(...).rgb`.
|
|
138
|
+
*/
|
|
139
|
+
function lineReadsSampleRgb(line, samples) {
|
|
140
|
+
// Direct textureSample(...).rgb / textureLoad(...).rgb.
|
|
141
|
+
if (/\btexture(?:Sample|Load)\b[\s\S]*\)\s*\.rgb\b/.test(line)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
for (const name of samples) {
|
|
145
|
+
// `\bNAME\.rgb\b` — matches `src.rgb` but not `p.color.rgb`.
|
|
146
|
+
const re = new RegExp(`(?<![.\\w])${name}\\.rgb\\b`);
|
|
147
|
+
if (re.test(line))
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Detect the `nonlinear-in-rgb` unpremul handshake at file scope. Returns
|
|
154
|
+
* `true` if the module contains any plausible unpremul mechanism — token
|
|
155
|
+
* `unpremul`, `.rgb /` divide pattern, or all inputs declared
|
|
156
|
+
* `alpha: "straight"`.
|
|
157
|
+
*/
|
|
158
|
+
function hasUnpremulHandshake(wgsl, inputs) {
|
|
159
|
+
if (/unpremul/i.test(wgsl))
|
|
160
|
+
return true;
|
|
161
|
+
if (/\.rgb\s*\/\s*/.test(wgsl))
|
|
162
|
+
return true;
|
|
163
|
+
// Per-channel unpremul: `.r / a`, `.g / a`, `.b / a` patterns count too.
|
|
164
|
+
if (/\.[rgb]\s*\/\s*[A-Za-z_]/.test(wgsl))
|
|
165
|
+
return true;
|
|
166
|
+
const inputNames = Object.keys(inputs);
|
|
167
|
+
if (inputNames.length === 0)
|
|
168
|
+
return true; // no premul input to violate
|
|
169
|
+
const allStraight = inputNames.every((name) => inputs[name].alpha === "straight");
|
|
170
|
+
return allStraight;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* `alpha-only`: scan the WGSL for any `vec4f(...)` returned-as-output whose
|
|
174
|
+
* first three components look non-zero. Permissive — only flags the obvious
|
|
175
|
+
* `vec4f(src.rgb, ...)` / `vec4f(src.r, src.g, src.b, ...)` shapes.
|
|
176
|
+
*/
|
|
177
|
+
function checkAlphaOnly(wgsl) {
|
|
178
|
+
const violations = [];
|
|
179
|
+
const lines = wgsl.split("\n");
|
|
180
|
+
for (let i = 0; i < lines.length; i++) {
|
|
181
|
+
const line = lines[i];
|
|
182
|
+
if (lineSuppressed(line))
|
|
183
|
+
continue;
|
|
184
|
+
// Looking for `return vec4f(...)` or `textureStore(..., vec4...(...))`.
|
|
185
|
+
if (!/\b(?:return|textureStore)\b/.test(line))
|
|
186
|
+
continue;
|
|
187
|
+
// Strip out an inline comment so we don't false-positive on `// foo.rgb`.
|
|
188
|
+
const code = stripLineComment(line);
|
|
189
|
+
// `vec4<f32>(0.0, 0.0, 0.0, ...)` and `vec4f(0.0, 0.0, 0.0, ...)` are the
|
|
190
|
+
// canonical zero-RGB form. Any other RGB shape is suspect.
|
|
191
|
+
if (/\bvec4(?:<f32>|f)\s*\(\s*0(?:\.0+)?\s*,\s*0(?:\.0+)?\s*,\s*0(?:\.0+)?\s*,/.test(code)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
// `vec4f(0.0)` splats zero everywhere — also fine.
|
|
195
|
+
if (/\bvec4(?:<f32>|f)\s*\(\s*0(?:\.0+)?\s*\)/.test(code))
|
|
196
|
+
continue;
|
|
197
|
+
// No vec4 here at all — not the output line.
|
|
198
|
+
if (!/\bvec4(?:<f32>|f)\s*\(/.test(code))
|
|
199
|
+
continue;
|
|
200
|
+
// Has vec4 and isn't a known zero-RGB form: flag if it references RGB-bearing tokens.
|
|
201
|
+
if (/\.rgb\b/.test(code) || /\.(?:r|g|b)\b/.test(code)) {
|
|
202
|
+
violations.push(`line ${i + 1}: alpha-only module writes non-zero RGB to output (\`${line.trim()}\`)`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return violations;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `linear-in-rgb`: flag any line that combines a nonlinear-op token with a
|
|
209
|
+
* `.rgb` access. Heuristic, brittle on multi-line expressions; that's the
|
|
210
|
+
* trade-off documented at the top of the file.
|
|
211
|
+
*/
|
|
212
|
+
function checkLinear(wgsl) {
|
|
213
|
+
const violations = [];
|
|
214
|
+
const lines = wgsl.split("\n");
|
|
215
|
+
for (let i = 0; i < lines.length; i++) {
|
|
216
|
+
const line = lines[i];
|
|
217
|
+
if (lineSuppressed(line))
|
|
218
|
+
continue;
|
|
219
|
+
const code = stripLineComment(line);
|
|
220
|
+
if (!RGB_RE.test(code))
|
|
221
|
+
continue;
|
|
222
|
+
if (!NONLINEAR_RE.test(code))
|
|
223
|
+
continue;
|
|
224
|
+
violations.push(`line ${i + 1}: linear-in-rgb module applies nonlinear op to \`.rgb\` (\`${line.trim()}\`)`);
|
|
225
|
+
}
|
|
226
|
+
return violations;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* `nonlinear-in-rgb`: the module must show the unpremul handshake whenever a
|
|
230
|
+
* sample variable's `.rgb` is read. If no handshake exists at file scope and
|
|
231
|
+
* any sample `.rgb` access is found, flag once per offending line.
|
|
232
|
+
*/
|
|
233
|
+
function checkNonlinear(wgsl, inputs) {
|
|
234
|
+
if (hasUnpremulHandshake(wgsl, inputs))
|
|
235
|
+
return [];
|
|
236
|
+
const samples = findSampleVariables(wgsl);
|
|
237
|
+
if (samples.size === 0 && !/\btexture(?:Sample|Load)\b[\s\S]*\.rgb\b/.test(wgsl)) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
const violations = [];
|
|
241
|
+
const lines = wgsl.split("\n");
|
|
242
|
+
for (let i = 0; i < lines.length; i++) {
|
|
243
|
+
const line = lines[i];
|
|
244
|
+
if (lineSuppressed(line))
|
|
245
|
+
continue;
|
|
246
|
+
const code = stripLineComment(line);
|
|
247
|
+
if (!lineReadsSampleRgb(code, samples))
|
|
248
|
+
continue;
|
|
249
|
+
violations.push(`line ${i + 1}: nonlinear-in-rgb module reads \`.rgb\` from a premul sample without an unpremul handshake (\`${line.trim()}\`)`);
|
|
250
|
+
}
|
|
251
|
+
if (violations.length === 0)
|
|
252
|
+
return [];
|
|
253
|
+
// Always include the file-level summary first so the error message names
|
|
254
|
+
// the missing mechanism even when the per-line list is long.
|
|
255
|
+
return [
|
|
256
|
+
"module tagged `nonlinear-in-rgb` but no `unpremul` / `.rgb /` divide / all-straight-inputs handshake found",
|
|
257
|
+
...violations
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
/** Strip a trailing `// ...` comment so suppression tokens don't trip pattern matches. */
|
|
261
|
+
function stripLineComment(line) {
|
|
262
|
+
const slash = line.indexOf("//");
|
|
263
|
+
if (slash === -1)
|
|
264
|
+
return line;
|
|
265
|
+
return line.slice(0, slash);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Validate that the resolved WGSL is consistent with its declared
|
|
269
|
+
* {@link LinearityMode}. Returns `{ ok, violations }`; the caller throws.
|
|
270
|
+
*/
|
|
271
|
+
export function validateWgslLinearity(args) {
|
|
272
|
+
if (validatorDisabled()) {
|
|
273
|
+
return { ok: true, violations: [] };
|
|
274
|
+
}
|
|
275
|
+
const { linearity, wgsl, inputs } = args;
|
|
276
|
+
let violations = [];
|
|
277
|
+
switch (linearity) {
|
|
278
|
+
case "source":
|
|
279
|
+
// Generators have no premul input to violate; trust the source.
|
|
280
|
+
break;
|
|
281
|
+
case "alpha-only":
|
|
282
|
+
violations = checkAlphaOnly(wgsl);
|
|
283
|
+
break;
|
|
284
|
+
case "linear-in-rgb":
|
|
285
|
+
violations = checkLinear(wgsl);
|
|
286
|
+
break;
|
|
287
|
+
case "nonlinear-in-rgb":
|
|
288
|
+
violations = checkNonlinear(wgsl, inputs);
|
|
289
|
+
break;
|
|
290
|
+
default: {
|
|
291
|
+
// Exhaustiveness: a new mode without a check is a defect, not a silent pass.
|
|
292
|
+
const _exhaustive = linearity;
|
|
293
|
+
void _exhaustive;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return { ok: violations.length === 0, violations };
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=wgslLinearity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgslLinearity.js","sourceRoot":"","sources":["../../src/validate/wgslLinearity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAIH,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG;IACzB,YAAY;IACZ,qBAAqB;IACrB,iBAAiB;CACT,CAAC;AAEX;;;;GAIG;AACH,MAAM,gBAAgB,GAAG;IACvB,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,YAAY;IACZ,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;CACC,CAAC;AAEX,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,SAAS,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC/E,MAAM,MAAM,GAAG,SAAS,CAAC;AACzB,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,oEAAoE;AACpE,MAAM,cAAc,GAClB,iGAAiG,CAAC;AAcpG;;;GAGG;AACH,SAAS,iBAAiB;IACxB,2EAA2E;IAC3E,6EAA6E;IAC7E,mEAAmE;IACnE,oEAAoE;IACpE,MAAM,GAAG,GAAI,UAAyE;SACnF,OAAO,EAAE,GAAG,CAAC;IAChB,OAAO,GAAG,EAAE,qBAAqB,KAAK,KAAK,CAAC;AAC9C,CAAC;AAED,iFAAiF;AACjF,SAAS,cAAc,CAAC,IAAY;IAClC,MAAM,KAAK,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EAAE,GAAG,IAAI,CAAC;IAEzC,IAAI,UAAU,GAAa,EAAE,CAAC;IAC9B,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,gEAAgE;YAChE,MAAM;QACR,KAAK,YAAY;YACf,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM;QACR,KAAK,eAAe;YAClB,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM;QACR,KAAK,kBAAkB;YACrB,UAAU,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM;QACR,SAAS,CAAC;YACR,6EAA6E;YAC7E,MAAM,WAAW,GAAU,SAAS,CAAC;YACrC,KAAK,WAAW,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/gpu/webgpu — Browser/WebGPU runtime entry point.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from the package root so the pure blend catalog + pool
|
|
5
|
+
* contracts (the root export) stay importable by Node-side consumers without
|
|
6
|
+
* pulling in `navigator.gpu`. This entry adds the browser `GPUContext`
|
|
7
|
+
* adapter and the shared layer-compositing engine.
|
|
8
|
+
*/
|
|
9
|
+
export * from "../compositor/index.js";
|
|
10
|
+
export { createBrowserGPUContext } from "../context.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webgpu/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/gpu/webgpu — Browser/WebGPU runtime entry point.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from the package root so the pure blend catalog + pool
|
|
5
|
+
* contracts (the root export) stay importable by Node-side consumers without
|
|
6
|
+
* pulling in `navigator.gpu`. This entry adds the browser `GPUContext`
|
|
7
|
+
* adapter and the shared layer-compositing engine.
|
|
8
|
+
*/
|
|
9
|
+
export * from "../compositor/index.js";
|
|
10
|
+
export { createBrowserGPUContext } from "../context.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webgpu/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nodetool-ai/gpu",
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "Canonical blend-mode catalog and shared WGSL blend functions for NodeTool compositors (sketch, timeline, Compositor node)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.0.0"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node ../../scripts/build-typescript-workspace.mjs",
|
|
13
|
+
"test": "node ../../scripts/run-vitest.mjs run",
|
|
14
|
+
"test:watch": "node ../../scripts/run-vitest.mjs",
|
|
15
|
+
"lint": "node ../../scripts/run-tsc.mjs --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@nodetool-ai/protocol": "^0.8.1",
|
|
19
|
+
"typegpu": "^0.11.6"
|
|
20
|
+
},
|
|
21
|
+
"optionalDependencies": {
|
|
22
|
+
"webgpu": "^0.4.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@webgpu/types": "^0.1.70",
|
|
26
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
27
|
+
"vitest": "^5.0.1"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"nodetool-dev": "./src/index.ts",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./pool": {
|
|
37
|
+
"nodetool-dev": "./src/pool.ts",
|
|
38
|
+
"types": "./dist/pool.d.ts",
|
|
39
|
+
"import": "./dist/pool.js",
|
|
40
|
+
"default": "./dist/pool.js"
|
|
41
|
+
},
|
|
42
|
+
"./webgpu": {
|
|
43
|
+
"nodetool-dev": "./src/webgpu/index.ts",
|
|
44
|
+
"types": "./dist/webgpu/index.d.ts",
|
|
45
|
+
"import": "./dist/webgpu/index.js",
|
|
46
|
+
"default": "./dist/webgpu/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./node": {
|
|
49
|
+
"nodetool-dev": "./src/node.ts",
|
|
50
|
+
"types": "./dist/node.d.ts",
|
|
51
|
+
"import": "./dist/node.js",
|
|
52
|
+
"default": "./dist/node.js"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/nodetool-ai/nodetool.git",
|
|
59
|
+
"directory": "packages/gpu"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://nodetool.ai",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/nodetool-ai/nodetool/issues"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"dist",
|
|
70
|
+
"README.md"
|
|
71
|
+
],
|
|
72
|
+
"keywords": [
|
|
73
|
+
"nodetool",
|
|
74
|
+
"ai",
|
|
75
|
+
"workflow",
|
|
76
|
+
"workflow-automation",
|
|
77
|
+
"typescript",
|
|
78
|
+
"gpu",
|
|
79
|
+
"webgpu",
|
|
80
|
+
"wgsl",
|
|
81
|
+
"blend-modes",
|
|
82
|
+
"compositor",
|
|
83
|
+
"shaders"
|
|
84
|
+
]
|
|
85
|
+
}
|