@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared WebGPU compositing shaders.
|
|
3
|
+
*
|
|
4
|
+
* These power the single layer-compositing engine used by both the sketch
|
|
5
|
+
* editor and the timeline preview. The pipeline is:
|
|
6
|
+
*
|
|
7
|
+
* background → (per layer: blend pass into ping-pong) → blit to target
|
|
8
|
+
*
|
|
9
|
+
* Each layer renders a full-screen quad; the fragment shader maps the
|
|
10
|
+
* screen UV back into the layer texture via a 2×3 inverse-affine matrix,
|
|
11
|
+
* samples the layer (nearest or linear), optionally applies a rounded-rect
|
|
12
|
+
* mask, and composites it over the current accumulation using the W3C
|
|
13
|
+
* compositing formula and the shared blend functions.
|
|
14
|
+
*
|
|
15
|
+
* The `nearest` + `radius == 0` path is identical to the sketch editor's
|
|
16
|
+
* historical blend-composite shader, so migrating sketch onto this engine
|
|
17
|
+
* does not change its output. `linear` sampling and the rounded-rect mask
|
|
18
|
+
* are opt-in via uniforms (used by the timeline for scaled video clips).
|
|
19
|
+
*/
|
|
20
|
+
export declare const FULLSCREEN_QUAD_VERTEX = "\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) uv: vec2f,\n};\n\n@vertex\nfn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var pos = array<vec2f, 4>(\n vec2f(-1.0, -1.0),\n vec2f( 1.0, -1.0),\n vec2f(-1.0, 1.0),\n vec2f( 1.0, 1.0),\n );\n var uv = array<vec2f, 4>(\n vec2f(0.0, 1.0),\n vec2f(1.0, 1.0),\n vec2f(0.0, 0.0),\n vec2f(1.0, 0.0),\n );\n var out: VertexOutput;\n out.position = vec4f(pos[vertexIndex], 0.0, 1.0);\n out.uv = uv[vertexIndex];\n return out;\n}\n";
|
|
21
|
+
export declare const BLEND_COMPOSITE_FRAGMENT = "\nstruct BlendUniforms {\n params0: vec4f,\n invRow0: vec4f,\n invRow1: vec4f,\n invRow2: vec4f,\n params1: vec4f,\n params2: vec4f,\n};\n\n@group(0) @binding(0) var<uniform> u: BlendUniforms;\n@group(0) @binding(1) var srcTexture: texture_2d<f32>;\n@group(0) @binding(2) var dstTexture: texture_2d<f32>;\n@group(0) @binding(3) var srcSampler: sampler;\n\n\n// Blend mode ids (must match BLEND_MODE_INFOS[*].gpuId in blendModes.ts):\n// 0 = normal, 1 = multiply, 2 = screen, 3 = overlay, 4 = darken,\n// 5 = lighten, 6 = color-dodge, 7 = color-burn, 8 = hard-light,\n// 9 = soft-light, 10 = difference, 11 = exclusion, 12 = add\n\nfn softLightD(x: f32) -> f32 {\n if (x <= 0.25) {\n return ((16.0 * x - 12.0) * x + 4.0) * x;\n }\n return sqrt(x);\n}\n\nfn blendChannel(s: f32, d: f32, mode: u32) -> f32 {\n switch (mode) {\n case 0u: { return s; }\n case 1u: { return s * d; }\n case 2u: { return s + d - s * d; }\n case 3u: {\n return select(\n 1.0 - 2.0 * (1.0 - s) * (1.0 - d),\n 2.0 * s * d,\n d <= 0.5\n );\n }\n case 4u: { return min(s, d); }\n case 5u: { return max(s, d); }\n case 6u: {\n return select(\n min(1.0, d / max(1.0 - s, 0.001)),\n 1.0,\n s >= 1.0\n );\n }\n case 7u: {\n return select(\n max(0.0, 1.0 - (1.0 - d) / max(s, 0.001)),\n 0.0,\n s <= 0.0\n );\n }\n case 8u: {\n return select(\n 1.0 - 2.0 * (1.0 - s) * (1.0 - d),\n 2.0 * s * d,\n s <= 0.5\n );\n }\n case 9u: {\n return select(\n d + (2.0 * s - 1.0) * (softLightD(d) - d),\n d - (1.0 - 2.0 * s) * d * (1.0 - d),\n s <= 0.5\n );\n }\n case 10u: { return abs(s - d); }\n case 11u: { return s + d - 2.0 * s * d; }\n case 12u: { return min(1.0, s + d); }\n default: { return s; }\n }\n}\n\nfn applyBlendMode(src: vec3f, dst: vec3f, mode: u32) -> vec3f {\n return vec3f(\n blendChannel(src.x, dst.x, mode),\n blendChannel(src.y, dst.y, mode),\n blendChannel(src.z, dst.z, mode)\n );\n}\n\n\nfn sdRoundedRect(p: vec2f, b: vec2f, r: f32) -> f32 {\n let q = abs(p) - b + vec2f(r);\n return min(max(q.x, q.y), 0.0) + length(max(q, vec2f(0.0))) - r;\n}\n\n@fragment\nfn fs_blend(@location(0) uv: vec2f) -> @location(0) vec4f {\n let opacity = u.params0.x;\n let blendMode = u32(u.params0.y);\n let canvasSize = u.params0.zw;\n let radius = u.params1.x;\n let smoothness = u.params1.y;\n let filterMode = u32(u.params1.z);\n\n // Destination = current accumulation, sampled at the screen UV (1:1).\n let dstDims = textureDimensions(dstTexture);\n let dstPx = vec2i(\n i32(clamp(floor(uv.x * f32(dstDims.x)), 0.0, f32(dstDims.x) - 1.0)),\n i32(clamp(floor(uv.y * f32(dstDims.y)), 0.0, f32(dstDims.y) - 1.0))\n );\n let dst = textureLoad(dstTexture, dstPx, 0);\n\n // Map screen UV \u2192 layer texel through the inverse homography.\n let px = uv * canvasSize;\n let denominator = dot(u.invRow2.xyz, vec3f(px, 1.0));\n if (abs(denominator) < 0.000001) { return dst; }\n let texel = vec2f(\n u.invRow0.x * px.x + u.invRow0.y * px.y + u.invRow0.z,\n u.invRow1.x * px.x + u.invRow1.y * px.y + u.invRow1.z\n ) / denominator;\n let dims = textureDimensions(srcTexture);\n let dimsF = vec2f(f32(dims.x), f32(dims.y));\n\n if (texel.x < 0.0 || texel.x >= dimsF.x || texel.y < 0.0 || texel.y >= dimsF.y) {\n return dst;\n }\n\n var srcRaw: vec4f;\n if (filterMode == 1u) {\n srcRaw = textureSampleLevel(srcTexture, srcSampler, texel / dimsF, 0.0);\n } else {\n let ix = i32(clamp(floor(texel.x), 0.0, max(dimsF.x - 1.0, 0.0)));\n let iy = i32(clamp(floor(texel.y), 0.0, max(dimsF.y - 1.0, 0.0)));\n srcRaw = textureLoad(srcTexture, vec2i(ix, iy), 0);\n }\n\n var sa = srcRaw.a * opacity;\n\n // Optional rounded-rect mask in layer-local [-1, 1] space.\n if (radius > 0.0) {\n let local = (texel / dimsF) * 2.0 - vec2f(1.0);\n let aspect = select(dimsF.x / dimsF.y, 1.0, dimsF.y == 0.0);\n var p = local;\n if (aspect > 1.0) {\n p.y = p.y / aspect;\n } else {\n p.x = p.x * aspect;\n }\n let halfSize = vec2f(min(1.0, aspect), min(1.0, 1.0 / aspect));\n let r = clamp(radius, 0.0, 0.5) * 2.0 * min(halfSize.x, halfSize.y);\n let dist = sdRoundedRect(p, halfSize, r);\n let mask = 1.0 - smoothstep(-smoothness, smoothness, dist);\n sa = sa * mask;\n }\n\n // Optional directional wipe mask in the layer's normalized quad space\n // (texel / dims), so the wipe edge rotates with the layer. c measures\n // distance from the named edge; the reveal front sits at\n // e = progress * (1 + softness), which clears the whole layer (including the\n // feather band) exactly at progress 1 and hides it all at progress 0.\n let wipeEdge = u32(u.params2.x);\n if (wipeEdge != 0u) {\n let progress = u.params2.y;\n // A tiny floor keeps smoothstep well-defined; softness 0 stays visually a\n // hard (sub-texel) edge.\n let softness = max(u.params2.z, 1e-4);\n let n = texel / dimsF;\n var c = n.x; // 1u: reveal from the left edge\n if (wipeEdge == 2u) {\n c = 1.0 - n.x; // from the right edge\n } else if (wipeEdge == 3u) {\n c = n.y; // from the top edge (texel row 0)\n } else if (wipeEdge == 4u) {\n c = 1.0 - n.y; // from the bottom edge\n }\n let e = progress * (1.0 + softness);\n sa = sa * (1.0 - smoothstep(e - softness, e, c));\n }\n\n // Radial iris reveal, in the layer's own normalized space.\n let irisProgress = u.params2.w;\n if (irisProgress >= 0.0) {\n let p = (texel / dimsF - vec2f(0.5)) * 2.0;\n let radial = length(p);\n let feather = max(u.params1.w, 0.0001);\n let edge = irisProgress * (1.41421356 + feather);\n let iris = 1.0 - smoothstep(edge - feather, edge, radial);\n sa = sa * select(iris, 0.0, irisProgress <= 0.0);\n }\n\n if (sa <= 0.0) {\n return dst;\n }\n\n let da = dst.a;\n let sc = srcRaw.rgb;\n // Canvas lighter adds premultiplied channels and alpha. Applying a\n // saturated straight-color sum inside source-over loses translucent light.\n if (blendMode == 12u) {\n return min(vec4f(sc * sa + dst.rgb, sa + da), vec4f(1.0));\n }\n // The accumulator stores premultiplied color (ad*Cd); the W3C formula needs\n // straight Cd, so divide RGB by alpha before calling the blend functions.\n // Non-normal modes (multiply, overlay, ...) silently produced wrong values\n // before this un-premultiply was added.\n let dc = select(vec3f(0.0), dst.rgb / max(da, 1.0 / 65535.0), da > 0.0);\n let blended = applyBlendMode(sc, dc, blendMode);\n\n // W3C compositing in premul-output form:\n // Co_premul = as*(1 - ad)*Cs + as*ad*B(Cs, Cd) + (1 - as)*ad*Cd\n // The third term (1 - as)*ad*Cd_straight equals (1 - as)*dst.rgb because\n // dst.rgb is already premultiplied (ad*Cd).\n let co = sa * (1.0 - da) * sc + sa * da * blended + (1.0 - sa) * dst.rgb;\n let ao = sa + da * (1.0 - sa);\n return vec4f(co, ao);\n}\n";
|
|
22
|
+
export declare const BLIT_FRAGMENT = "\n@group(0) @binding(0) var blitTexture: texture_2d<f32>;\n\n@fragment\nfn fs_blit(@location(0) uv: vec2f) -> @location(0) vec4f {\n let dims = textureDimensions(blitTexture);\n let px = vec2i(\n i32(clamp(floor(uv.x * f32(dims.x)), 0.0, f32(dims.x) - 1.0)),\n i32(clamp(floor(uv.y * f32(dims.y)), 0.0, f32(dims.y) - 1.0))\n );\n return textureLoad(blitTexture, px, 0);\n}\n";
|
|
23
|
+
export declare const UNPREMULTIPLY_FRAGMENT = "\n@group(0) @binding(0) var srcTexture: texture_2d<f32>;\n\n@fragment\nfn fs_unpremultiply(@location(0) uv: vec2f) -> @location(0) vec4f {\n let dims = textureDimensions(srcTexture);\n let px = vec2i(\n i32(clamp(floor(uv.x * f32(dims.x)), 0.0, f32(dims.x) - 1.0)),\n i32(clamp(floor(uv.y * f32(dims.y)), 0.0, f32(dims.y) - 1.0))\n );\n let c = textureLoad(srcTexture, px, 0);\n if (c.a <= 0.0) {\n return vec4f(0.0, 0.0, 0.0, 0.0);\n }\n return vec4f(c.rgb / c.a, c.a);\n}\n";
|
|
24
|
+
//# sourceMappingURL=shaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaders.d.ts","sourceRoot":"","sources":["../../src/compositor/shaders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,eAAO,MAAM,sBAAsB,mjBAyBlC,CAAC;AAeF,eAAO,MAAM,wBAAwB,44NA+IpC,CAAC;AAIF,eAAO,MAAM,aAAa,qYAYzB,CAAC;AASF,eAAO,MAAM,sBAAsB,gfAgBlC,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared WebGPU compositing shaders.
|
|
3
|
+
*
|
|
4
|
+
* These power the single layer-compositing engine used by both the sketch
|
|
5
|
+
* editor and the timeline preview. The pipeline is:
|
|
6
|
+
*
|
|
7
|
+
* background → (per layer: blend pass into ping-pong) → blit to target
|
|
8
|
+
*
|
|
9
|
+
* Each layer renders a full-screen quad; the fragment shader maps the
|
|
10
|
+
* screen UV back into the layer texture via a 2×3 inverse-affine matrix,
|
|
11
|
+
* samples the layer (nearest or linear), optionally applies a rounded-rect
|
|
12
|
+
* mask, and composites it over the current accumulation using the W3C
|
|
13
|
+
* compositing formula and the shared blend functions.
|
|
14
|
+
*
|
|
15
|
+
* The `nearest` + `radius == 0` path is identical to the sketch editor's
|
|
16
|
+
* historical blend-composite shader, so migrating sketch onto this engine
|
|
17
|
+
* does not change its output. `linear` sampling and the rounded-rect mask
|
|
18
|
+
* are opt-in via uniforms (used by the timeline for scaled video clips).
|
|
19
|
+
*/
|
|
20
|
+
import { WGSL_BLEND_FUNCTIONS } from "../blend/wgsl.js";
|
|
21
|
+
// ─── Full-screen quad vertex shader (4-vertex triangle strip) ─────────────
|
|
22
|
+
export const FULLSCREEN_QUAD_VERTEX = /* wgsl */ `
|
|
23
|
+
struct VertexOutput {
|
|
24
|
+
@builtin(position) position: vec4f,
|
|
25
|
+
@location(0) uv: vec2f,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@vertex
|
|
29
|
+
fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
30
|
+
var pos = array<vec2f, 4>(
|
|
31
|
+
vec2f(-1.0, -1.0),
|
|
32
|
+
vec2f( 1.0, -1.0),
|
|
33
|
+
vec2f(-1.0, 1.0),
|
|
34
|
+
vec2f( 1.0, 1.0),
|
|
35
|
+
);
|
|
36
|
+
var uv = array<vec2f, 4>(
|
|
37
|
+
vec2f(0.0, 1.0),
|
|
38
|
+
vec2f(1.0, 1.0),
|
|
39
|
+
vec2f(0.0, 0.0),
|
|
40
|
+
vec2f(1.0, 0.0),
|
|
41
|
+
);
|
|
42
|
+
var out: VertexOutput;
|
|
43
|
+
out.position = vec4f(pos[vertexIndex], 0.0, 1.0);
|
|
44
|
+
out.uv = uv[vertexIndex];
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
// ─── Blend composite fragment shader ──────────────────────────────────────
|
|
49
|
+
//
|
|
50
|
+
// Uniform layout (4 × vec4f = 64 bytes):
|
|
51
|
+
// params0: opacity, blendMode (as f32), canvasW, canvasH
|
|
52
|
+
// invRow0: a, b, tx, _ (inverse affine row 0: screen px → layer texel)
|
|
53
|
+
// invRow1: c, d, ty, _ (inverse affine row 1)
|
|
54
|
+
// invRow2: p, q, r, _ (projective denominator)
|
|
55
|
+
// params1: borderRadius (normalized 0..0.5), smoothness, filterMode, _
|
|
56
|
+
// filterMode: 0 = nearest (textureLoad), 1 = linear (sampler)
|
|
57
|
+
// params2: wipeEdge, wipeProgress, wipeSoftness, _
|
|
58
|
+
// wipeEdge: 0 = no mask, 1 = left, 2 = right, 3 = top, 4 = bottom
|
|
59
|
+
// (edge the reveal starts from, in the layer's own quad space)
|
|
60
|
+
export const BLEND_COMPOSITE_FRAGMENT = /* wgsl */ `
|
|
61
|
+
struct BlendUniforms {
|
|
62
|
+
params0: vec4f,
|
|
63
|
+
invRow0: vec4f,
|
|
64
|
+
invRow1: vec4f,
|
|
65
|
+
invRow2: vec4f,
|
|
66
|
+
params1: vec4f,
|
|
67
|
+
params2: vec4f,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
@group(0) @binding(0) var<uniform> u: BlendUniforms;
|
|
71
|
+
@group(0) @binding(1) var srcTexture: texture_2d<f32>;
|
|
72
|
+
@group(0) @binding(2) var dstTexture: texture_2d<f32>;
|
|
73
|
+
@group(0) @binding(3) var srcSampler: sampler;
|
|
74
|
+
|
|
75
|
+
${WGSL_BLEND_FUNCTIONS}
|
|
76
|
+
|
|
77
|
+
fn sdRoundedRect(p: vec2f, b: vec2f, r: f32) -> f32 {
|
|
78
|
+
let q = abs(p) - b + vec2f(r);
|
|
79
|
+
return min(max(q.x, q.y), 0.0) + length(max(q, vec2f(0.0))) - r;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@fragment
|
|
83
|
+
fn fs_blend(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
84
|
+
let opacity = u.params0.x;
|
|
85
|
+
let blendMode = u32(u.params0.y);
|
|
86
|
+
let canvasSize = u.params0.zw;
|
|
87
|
+
let radius = u.params1.x;
|
|
88
|
+
let smoothness = u.params1.y;
|
|
89
|
+
let filterMode = u32(u.params1.z);
|
|
90
|
+
|
|
91
|
+
// Destination = current accumulation, sampled at the screen UV (1:1).
|
|
92
|
+
let dstDims = textureDimensions(dstTexture);
|
|
93
|
+
let dstPx = vec2i(
|
|
94
|
+
i32(clamp(floor(uv.x * f32(dstDims.x)), 0.0, f32(dstDims.x) - 1.0)),
|
|
95
|
+
i32(clamp(floor(uv.y * f32(dstDims.y)), 0.0, f32(dstDims.y) - 1.0))
|
|
96
|
+
);
|
|
97
|
+
let dst = textureLoad(dstTexture, dstPx, 0);
|
|
98
|
+
|
|
99
|
+
// Map screen UV → layer texel through the inverse homography.
|
|
100
|
+
let px = uv * canvasSize;
|
|
101
|
+
let denominator = dot(u.invRow2.xyz, vec3f(px, 1.0));
|
|
102
|
+
if (abs(denominator) < 0.000001) { return dst; }
|
|
103
|
+
let texel = vec2f(
|
|
104
|
+
u.invRow0.x * px.x + u.invRow0.y * px.y + u.invRow0.z,
|
|
105
|
+
u.invRow1.x * px.x + u.invRow1.y * px.y + u.invRow1.z
|
|
106
|
+
) / denominator;
|
|
107
|
+
let dims = textureDimensions(srcTexture);
|
|
108
|
+
let dimsF = vec2f(f32(dims.x), f32(dims.y));
|
|
109
|
+
|
|
110
|
+
if (texel.x < 0.0 || texel.x >= dimsF.x || texel.y < 0.0 || texel.y >= dimsF.y) {
|
|
111
|
+
return dst;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var srcRaw: vec4f;
|
|
115
|
+
if (filterMode == 1u) {
|
|
116
|
+
srcRaw = textureSampleLevel(srcTexture, srcSampler, texel / dimsF, 0.0);
|
|
117
|
+
} else {
|
|
118
|
+
let ix = i32(clamp(floor(texel.x), 0.0, max(dimsF.x - 1.0, 0.0)));
|
|
119
|
+
let iy = i32(clamp(floor(texel.y), 0.0, max(dimsF.y - 1.0, 0.0)));
|
|
120
|
+
srcRaw = textureLoad(srcTexture, vec2i(ix, iy), 0);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var sa = srcRaw.a * opacity;
|
|
124
|
+
|
|
125
|
+
// Optional rounded-rect mask in layer-local [-1, 1] space.
|
|
126
|
+
if (radius > 0.0) {
|
|
127
|
+
let local = (texel / dimsF) * 2.0 - vec2f(1.0);
|
|
128
|
+
let aspect = select(dimsF.x / dimsF.y, 1.0, dimsF.y == 0.0);
|
|
129
|
+
var p = local;
|
|
130
|
+
if (aspect > 1.0) {
|
|
131
|
+
p.y = p.y / aspect;
|
|
132
|
+
} else {
|
|
133
|
+
p.x = p.x * aspect;
|
|
134
|
+
}
|
|
135
|
+
let halfSize = vec2f(min(1.0, aspect), min(1.0, 1.0 / aspect));
|
|
136
|
+
let r = clamp(radius, 0.0, 0.5) * 2.0 * min(halfSize.x, halfSize.y);
|
|
137
|
+
let dist = sdRoundedRect(p, halfSize, r);
|
|
138
|
+
let mask = 1.0 - smoothstep(-smoothness, smoothness, dist);
|
|
139
|
+
sa = sa * mask;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Optional directional wipe mask in the layer's normalized quad space
|
|
143
|
+
// (texel / dims), so the wipe edge rotates with the layer. c measures
|
|
144
|
+
// distance from the named edge; the reveal front sits at
|
|
145
|
+
// e = progress * (1 + softness), which clears the whole layer (including the
|
|
146
|
+
// feather band) exactly at progress 1 and hides it all at progress 0.
|
|
147
|
+
let wipeEdge = u32(u.params2.x);
|
|
148
|
+
if (wipeEdge != 0u) {
|
|
149
|
+
let progress = u.params2.y;
|
|
150
|
+
// A tiny floor keeps smoothstep well-defined; softness 0 stays visually a
|
|
151
|
+
// hard (sub-texel) edge.
|
|
152
|
+
let softness = max(u.params2.z, 1e-4);
|
|
153
|
+
let n = texel / dimsF;
|
|
154
|
+
var c = n.x; // 1u: reveal from the left edge
|
|
155
|
+
if (wipeEdge == 2u) {
|
|
156
|
+
c = 1.0 - n.x; // from the right edge
|
|
157
|
+
} else if (wipeEdge == 3u) {
|
|
158
|
+
c = n.y; // from the top edge (texel row 0)
|
|
159
|
+
} else if (wipeEdge == 4u) {
|
|
160
|
+
c = 1.0 - n.y; // from the bottom edge
|
|
161
|
+
}
|
|
162
|
+
let e = progress * (1.0 + softness);
|
|
163
|
+
sa = sa * (1.0 - smoothstep(e - softness, e, c));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Radial iris reveal, in the layer's own normalized space.
|
|
167
|
+
let irisProgress = u.params2.w;
|
|
168
|
+
if (irisProgress >= 0.0) {
|
|
169
|
+
let p = (texel / dimsF - vec2f(0.5)) * 2.0;
|
|
170
|
+
let radial = length(p);
|
|
171
|
+
let feather = max(u.params1.w, 0.0001);
|
|
172
|
+
let edge = irisProgress * (1.41421356 + feather);
|
|
173
|
+
let iris = 1.0 - smoothstep(edge - feather, edge, radial);
|
|
174
|
+
sa = sa * select(iris, 0.0, irisProgress <= 0.0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (sa <= 0.0) {
|
|
178
|
+
return dst;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let da = dst.a;
|
|
182
|
+
let sc = srcRaw.rgb;
|
|
183
|
+
// Canvas lighter adds premultiplied channels and alpha. Applying a
|
|
184
|
+
// saturated straight-color sum inside source-over loses translucent light.
|
|
185
|
+
if (blendMode == 12u) {
|
|
186
|
+
return min(vec4f(sc * sa + dst.rgb, sa + da), vec4f(1.0));
|
|
187
|
+
}
|
|
188
|
+
// The accumulator stores premultiplied color (ad*Cd); the W3C formula needs
|
|
189
|
+
// straight Cd, so divide RGB by alpha before calling the blend functions.
|
|
190
|
+
// Non-normal modes (multiply, overlay, ...) silently produced wrong values
|
|
191
|
+
// before this un-premultiply was added.
|
|
192
|
+
let dc = select(vec3f(0.0), dst.rgb / max(da, 1.0 / 65535.0), da > 0.0);
|
|
193
|
+
let blended = applyBlendMode(sc, dc, blendMode);
|
|
194
|
+
|
|
195
|
+
// W3C compositing in premul-output form:
|
|
196
|
+
// Co_premul = as*(1 - ad)*Cs + as*ad*B(Cs, Cd) + (1 - as)*ad*Cd
|
|
197
|
+
// The third term (1 - as)*ad*Cd_straight equals (1 - as)*dst.rgb because
|
|
198
|
+
// dst.rgb is already premultiplied (ad*Cd).
|
|
199
|
+
let co = sa * (1.0 - da) * sc + sa * da * blended + (1.0 - sa) * dst.rgb;
|
|
200
|
+
let ao = sa + da * (1.0 - sa);
|
|
201
|
+
return vec4f(co, ao);
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
// ─── Blit fragment shader (composite → target/swap chain) ─────────────────
|
|
205
|
+
export const BLIT_FRAGMENT = /* wgsl */ `
|
|
206
|
+
@group(0) @binding(0) var blitTexture: texture_2d<f32>;
|
|
207
|
+
|
|
208
|
+
@fragment
|
|
209
|
+
fn fs_blit(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
210
|
+
let dims = textureDimensions(blitTexture);
|
|
211
|
+
let px = vec2i(
|
|
212
|
+
i32(clamp(floor(uv.x * f32(dims.x)), 0.0, f32(dims.x) - 1.0)),
|
|
213
|
+
i32(clamp(floor(uv.y * f32(dims.y)), 0.0, f32(dims.y) - 1.0))
|
|
214
|
+
);
|
|
215
|
+
return textureLoad(blitTexture, px, 0);
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
// ─── Un-premultiply resolve fragment (premultiplied → straight alpha) ──────
|
|
219
|
+
//
|
|
220
|
+
// The blend pipeline accumulates premultiplied color. Headless readback wants
|
|
221
|
+
// straight (non-premultiplied) RGBA for a faithful PNG encode, so this pass
|
|
222
|
+
// divides RGB by alpha on the GPU — replacing a per-pixel CPU loop over the
|
|
223
|
+
// whole readback. Pairs with `FULLSCREEN_QUAD_VERTEX` (`vs_main`).
|
|
224
|
+
export const UNPREMULTIPLY_FRAGMENT = /* wgsl */ `
|
|
225
|
+
@group(0) @binding(0) var srcTexture: texture_2d<f32>;
|
|
226
|
+
|
|
227
|
+
@fragment
|
|
228
|
+
fn fs_unpremultiply(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
229
|
+
let dims = textureDimensions(srcTexture);
|
|
230
|
+
let px = vec2i(
|
|
231
|
+
i32(clamp(floor(uv.x * f32(dims.x)), 0.0, f32(dims.x) - 1.0)),
|
|
232
|
+
i32(clamp(floor(uv.y * f32(dims.y)), 0.0, f32(dims.y) - 1.0))
|
|
233
|
+
);
|
|
234
|
+
let c = textureLoad(srcTexture, px, 0);
|
|
235
|
+
if (c.a <= 0.0) {
|
|
236
|
+
return vec4f(0.0, 0.0, 0.0, 0.0);
|
|
237
|
+
}
|
|
238
|
+
return vec4f(c.rgb / c.a, c.a);
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
//# sourceMappingURL=shaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaders.js","sourceRoot":"","sources":["../../src/compositor/shaders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,6EAA6E;AAE7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBhD,CAAC;AAEF,6EAA6E;AAC7E,EAAE;AACF,yCAAyC;AACzC,2DAA2D;AAC3D,2EAA2E;AAC3E,kDAAkD;AAClD,oDAAoD;AACpD,yEAAyE;AACzE,kEAAkE;AAClE,qDAAqD;AACrD,sEAAsE;AACtE,mEAAmE;AAEnE,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;EAejD,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgIrB,CAAC;AAEF,6EAA6E;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;;;;;;;;;;;;CAYvC,CAAC;AAEF,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AAEnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;CAgBhD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-layer 2D transform → inverse-affine conversion.
|
|
3
|
+
*
|
|
4
|
+
* The Compositor places each layer on a fixed-size canvas with a position,
|
|
5
|
+
* scale, and rotation. This module is the single source of truth for turning
|
|
6
|
+
* that human-friendly transform into the `InverseAffine` (canvas px → layer
|
|
7
|
+
* texel) the {@link WebGPULayerCompositor} blend shader consumes — so the
|
|
8
|
+
* in-editor live preview and the server-side node render produce identical
|
|
9
|
+
* placement.
|
|
10
|
+
*
|
|
11
|
+
* Convention: the transform rotates and scales the layer about its own center,
|
|
12
|
+
* and `(x, y)` is where that center sits in canvas pixels. With the default
|
|
13
|
+
* transform (`scale = 1`, `rotation = 0`, center at `(w/2, h/2)`) a layer's
|
|
14
|
+
* top-left lands at the canvas origin — identical to an untransformed
|
|
15
|
+
* top-left paste.
|
|
16
|
+
*/
|
|
17
|
+
import type { InverseAffine } from "./compositor.js";
|
|
18
|
+
/** Layer placement on the composite canvas. Angles are radians, CCW. */
|
|
19
|
+
export interface LayerTransform2D {
|
|
20
|
+
/** Canvas-pixel X of the layer center. */
|
|
21
|
+
x: number;
|
|
22
|
+
/** Canvas-pixel Y of the layer center. */
|
|
23
|
+
y: number;
|
|
24
|
+
scaleX: number;
|
|
25
|
+
scaleY: number;
|
|
26
|
+
/** Rotation about the layer center, in radians. */
|
|
27
|
+
rotation: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Default placement for a layer with no explicit transform: contain-fit
|
|
31
|
+
* centered on the canvas, never upscaled.
|
|
32
|
+
*
|
|
33
|
+
* Scale is `min(canvasW/layerW, canvasH/layerH, 1)` — large layers shrink to
|
|
34
|
+
* fit, smaller layers keep their native size. The layer center is pinned to
|
|
35
|
+
* the canvas center. For a same-size base layer this reduces to scale=1 with
|
|
36
|
+
* the top-left at the canvas origin (the historical "untransformed paste"),
|
|
37
|
+
* so single-layer pipelines are unaffected.
|
|
38
|
+
*/
|
|
39
|
+
export declare function defaultLayerTransform(layerWidth: number, layerHeight: number, canvasWidth: number, canvasHeight: number): LayerTransform2D;
|
|
40
|
+
/**
|
|
41
|
+
* Build the {@link InverseAffine} (canvas px → layer texel) for a layer of the
|
|
42
|
+
* given pixel dimensions placed by `transform`.
|
|
43
|
+
*
|
|
44
|
+
* Forward map (texel → canvas): `canvas = R·S·(texel - center) + (x, y)`,
|
|
45
|
+
* with `center = (width/2, height/2)`. The shader needs the inverse; degenerate
|
|
46
|
+
* (zero) scales fall back to identity rather than producing NaNs.
|
|
47
|
+
*/
|
|
48
|
+
export declare function layerTransformToInverseAffine(transform: LayerTransform2D, width: number, height: number): InverseAffine;
|
|
49
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/compositor/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,CAAC,EAAE,MAAM,CAAC;IACV,0CAA0C;IAC1C,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,gBAAgB,CAalB;AAID;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,aAAa,CAwBf"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-layer 2D transform → inverse-affine conversion.
|
|
3
|
+
*
|
|
4
|
+
* The Compositor places each layer on a fixed-size canvas with a position,
|
|
5
|
+
* scale, and rotation. This module is the single source of truth for turning
|
|
6
|
+
* that human-friendly transform into the `InverseAffine` (canvas px → layer
|
|
7
|
+
* texel) the {@link WebGPULayerCompositor} blend shader consumes — so the
|
|
8
|
+
* in-editor live preview and the server-side node render produce identical
|
|
9
|
+
* placement.
|
|
10
|
+
*
|
|
11
|
+
* Convention: the transform rotates and scales the layer about its own center,
|
|
12
|
+
* and `(x, y)` is where that center sits in canvas pixels. With the default
|
|
13
|
+
* transform (`scale = 1`, `rotation = 0`, center at `(w/2, h/2)`) a layer's
|
|
14
|
+
* top-left lands at the canvas origin — identical to an untransformed
|
|
15
|
+
* top-left paste.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Default placement for a layer with no explicit transform: contain-fit
|
|
19
|
+
* centered on the canvas, never upscaled.
|
|
20
|
+
*
|
|
21
|
+
* Scale is `min(canvasW/layerW, canvasH/layerH, 1)` — large layers shrink to
|
|
22
|
+
* fit, smaller layers keep their native size. The layer center is pinned to
|
|
23
|
+
* the canvas center. For a same-size base layer this reduces to scale=1 with
|
|
24
|
+
* the top-left at the canvas origin (the historical "untransformed paste"),
|
|
25
|
+
* so single-layer pipelines are unaffected.
|
|
26
|
+
*/
|
|
27
|
+
export function defaultLayerTransform(layerWidth, layerHeight, canvasWidth, canvasHeight) {
|
|
28
|
+
const safeLW = Math.max(1, layerWidth);
|
|
29
|
+
const safeLH = Math.max(1, layerHeight);
|
|
30
|
+
const safeCW = Math.max(1, canvasWidth);
|
|
31
|
+
const safeCH = Math.max(1, canvasHeight);
|
|
32
|
+
const scale = Math.min(safeCW / safeLW, safeCH / safeLH, 1);
|
|
33
|
+
return {
|
|
34
|
+
x: safeCW / 2,
|
|
35
|
+
y: safeCH / 2,
|
|
36
|
+
scaleX: scale,
|
|
37
|
+
scaleY: scale,
|
|
38
|
+
rotation: 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const IDENTITY = { a: 1, b: 0, tx: 0, c: 0, d: 1, ty: 0 };
|
|
42
|
+
/**
|
|
43
|
+
* Build the {@link InverseAffine} (canvas px → layer texel) for a layer of the
|
|
44
|
+
* given pixel dimensions placed by `transform`.
|
|
45
|
+
*
|
|
46
|
+
* Forward map (texel → canvas): `canvas = R·S·(texel - center) + (x, y)`,
|
|
47
|
+
* with `center = (width/2, height/2)`. The shader needs the inverse; degenerate
|
|
48
|
+
* (zero) scales fall back to identity rather than producing NaNs.
|
|
49
|
+
*/
|
|
50
|
+
export function layerTransformToInverseAffine(transform, width, height) {
|
|
51
|
+
const sx = transform.scaleX;
|
|
52
|
+
const sy = transform.scaleY;
|
|
53
|
+
if (sx === 0 || sy === 0) {
|
|
54
|
+
return { ...IDENTITY };
|
|
55
|
+
}
|
|
56
|
+
const cos = Math.cos(transform.rotation);
|
|
57
|
+
const sin = Math.sin(transform.rotation);
|
|
58
|
+
const cx = width / 2;
|
|
59
|
+
const cy = height / 2;
|
|
60
|
+
// texel = S⁻¹·R⁻¹·(canvas - (x, y)) + center
|
|
61
|
+
const a = cos / sx;
|
|
62
|
+
const b = sin / sx;
|
|
63
|
+
const c = -sin / sy;
|
|
64
|
+
const d = cos / sy;
|
|
65
|
+
return {
|
|
66
|
+
a,
|
|
67
|
+
b,
|
|
68
|
+
tx: cx - a * transform.x - b * transform.y,
|
|
69
|
+
c,
|
|
70
|
+
d,
|
|
71
|
+
ty: cy - c * transform.x - d * transform.y
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/compositor/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgBH;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAkB,EAClB,WAAmB,EACnB,WAAmB,EACnB,YAAoB;IAEpB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5D,OAAO;QACL,CAAC,EAAE,MAAM,GAAG,CAAC;QACb,CAAC,EAAE,MAAM,GAAG,CAAC;QACb,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,SAA2B,EAC3B,KAAa,EACb,MAAc;IAEd,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,CAAC;IAEtB,6CAA6C;IAC7C,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;IACnB,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC;IACpB,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;IACnB,OAAO;QACL,CAAC;QACD,CAAC;QACD,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;QAC1C,CAAC;QACD,CAAC;QACD,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GPUContext` — the host-portability adapter.
|
|
3
|
+
*
|
|
4
|
+
* Holds a TypeGPU `root` (from `tgpu.initFromDevice({ device })`) plus the
|
|
5
|
+
* per-host services the Executor leans on: a pipeline cache, a scratch
|
|
6
|
+
* texture pool, and a capability record. The same `ShaderModule` code runs
|
|
7
|
+
* against a browser `navigator.gpu` device, an Electron device, or a
|
|
8
|
+
* Node.js Dawn device — only the adapter that builds this object differs.
|
|
9
|
+
*/
|
|
10
|
+
import type { TgpuRoot } from "typegpu";
|
|
11
|
+
import { LabeledTexture } from "./texture.js";
|
|
12
|
+
import type { LabeledTextureMeta } from "./texture.js";
|
|
13
|
+
/** Host capabilities used by variant resolution (Phase 3) and validation. */
|
|
14
|
+
export interface GPUCapabilities {
|
|
15
|
+
/** `texture_external` import supported (camera/video fast path). */
|
|
16
|
+
textureExternal: boolean;
|
|
17
|
+
/** `float16` storage textures supported. */
|
|
18
|
+
f16Storage: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type CachedPipeline = GPURenderPipeline | GPUComputePipeline;
|
|
21
|
+
/** Get-or-compile cache for pipelines, keyed by the caller (module id+variant). */
|
|
22
|
+
export interface PipelineCache {
|
|
23
|
+
get(key: string): CachedPipeline | undefined;
|
|
24
|
+
set(key: string, pipeline: CachedPipeline): void;
|
|
25
|
+
}
|
|
26
|
+
export interface ScratchSpec {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
format: GPUTextureFormat;
|
|
30
|
+
usage: GPUTextureUsageFlags;
|
|
31
|
+
meta?: Partial<LabeledTextureMeta>;
|
|
32
|
+
label?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Allocate at exactly `width`×`height` instead of rounding up to the
|
|
35
|
+
* allocation bucket. Needed when the texture is sampled in normalized
|
|
36
|
+
* `[0,1]` space by a later pass *and* is filled by a writer that only covers
|
|
37
|
+
* the logical dimensions (the alpha auto-convert pass): a bucketed texture
|
|
38
|
+
* would leave the margin between the logical size and the bucket unwritten,
|
|
39
|
+
* which normalized sampling then reads as garbage. Trades pool reuse across
|
|
40
|
+
* sizes for a physical size that equals the logical size.
|
|
41
|
+
*/
|
|
42
|
+
exact?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Frame/run-scoped texture pool. `acquire` returns a texture at least as
|
|
46
|
+
* large as requested (bucketed); `release` returns it for reuse. Hosts own
|
|
47
|
+
* lifetime — the pool never reads pixels back to the CPU.
|
|
48
|
+
*/
|
|
49
|
+
export interface ScratchPool {
|
|
50
|
+
acquire(spec: ScratchSpec): LabeledTexture;
|
|
51
|
+
release(texture: LabeledTexture): void;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reusable uniform buffers. Each dispatch in a submission needs its own slot;
|
|
56
|
+
* the host calls `beginSubmission` before recording a new command buffer.
|
|
57
|
+
*
|
|
58
|
+
* Reuse is safe because of WebGPU's queue ordering: a `writeBuffer` is ordered
|
|
59
|
+
* after every previously-submitted command on the queue timeline, so reusing a
|
|
60
|
+
* buffer never races a prior submit's read of it. The only constraint is
|
|
61
|
+
* *within a single submit*: two dispatches must not share a buffer, regardless
|
|
62
|
+
* of how many effects the frame contains.
|
|
63
|
+
*/
|
|
64
|
+
export interface UniformRing {
|
|
65
|
+
beginSubmission(): void;
|
|
66
|
+
acquire(size: number): GPUBuffer;
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
69
|
+
export interface GPUContext {
|
|
70
|
+
readonly root: TgpuRoot;
|
|
71
|
+
readonly device: GPUDevice;
|
|
72
|
+
readonly capabilities: GPUCapabilities;
|
|
73
|
+
readonly pipelineCache: PipelineCache;
|
|
74
|
+
readonly scratch: ScratchPool;
|
|
75
|
+
readonly uniformRing: UniformRing;
|
|
76
|
+
/**
|
|
77
|
+
* 1×1 white texture used as the default for unbound optional inputs (the
|
|
78
|
+
* canonical case is the `mask` slot — modules sample as if a mask is always
|
|
79
|
+
* present, the executor supplies coverage = 1 when no mask is bound).
|
|
80
|
+
* Lazy-allocated on first use; lifetime is tied to the context (no
|
|
81
|
+
* per-encode allocation).
|
|
82
|
+
*/
|
|
83
|
+
getDefaultWhiteTexture(): LabeledTexture;
|
|
84
|
+
}
|
|
85
|
+
/** Round a dimension up to the allocation bucket (multiple of 64, pow2 ≥ 256). */
|
|
86
|
+
export declare function ceilToBucket(value: number): number;
|
|
87
|
+
/**
|
|
88
|
+
* Bucketed, refcounted scratch pool. Buckets on
|
|
89
|
+
* `(format, usage, bucketW, bucketH)`; the caller sees only the requested
|
|
90
|
+
* viewport, the underlying texture may be larger.
|
|
91
|
+
*/
|
|
92
|
+
export declare function makeScratchPool(device: GPUDevice): ScratchPool;
|
|
93
|
+
/** Pool of uniform buffers, sized to the largest submission seen. */
|
|
94
|
+
export declare function makeUniformRing(device: GPUDevice): UniformRing;
|
|
95
|
+
/**
|
|
96
|
+
* Build a {@link GPUContext} from the browser `navigator.gpu`. Browser/WebGPU
|
|
97
|
+
* only — kept out of the package's pure root so Node consumers can import the
|
|
98
|
+
* catalog without touching `navigator`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function createBrowserGPUContext(options?: {
|
|
101
|
+
adapterOptions?: GPURequestAdapterOptions;
|
|
102
|
+
}): Promise<GPUContext>;
|
|
103
|
+
/**
|
|
104
|
+
* Build a {@link GPUContext} from an already-acquired `GPUDevice` (browser,
|
|
105
|
+
* Electron, or Node.js Dawn). The shared path every adapter funnels into.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createGPUContextFromDevice(device: GPUDevice): GPUContext;
|
|
108
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAwB,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,eAAe,EAAE,OAAO,CAAC;IACzB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAEpE,mFAAmF;AACnF,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC;IAC3C,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,IAAI,IAAI,CAAC;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC;;;;;;OAMG;IACH,sBAAsB,IAAI,cAAc,CAAC;CAC1C;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUlD;AAeD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CAuE9D;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,CA8B9D;AAUD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,wBAAwB,CAAA;CAAO,GAC1D,OAAO,CAAC,UAAU,CAAC,CAgBrB;AA8BD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAWxE"}
|