UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

14 lines (13 loc) 799 B
import { comptime } from "../core/function/comptime.js"; import { getResolutionCtx } from "../execMode.js"; import { wgslEnableExtensions } from "../wgslExtensions.js"; export const extensionEnabled = comptime((extensionName) => { const resolutionCtx = getResolutionCtx(); if (!resolutionCtx) { throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)"); } if (typeof extensionName !== 'string' || !wgslEnableExtensions.includes(extensionName)) { throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${extensionName}'`); } return (resolutionCtx.enableExtensions ?? []).includes(extensionName); });