@luma.gl/shaders 10.0.0-alpha.5 → 10.0.0-alpha.7
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/LICENSE +38 -0
- package/dist/dist.dev.js +159 -127
- package/dist/dist.min.js +110 -105
- package/dist/glsl.cjs.map +1 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/glsl-shader-assembler.cjs +1 -1
- package/dist/lib/glsl-shader-assembler.js +1 -1
- package/dist/lib/glsl-shader-assembler.js.map +1 -1
- package/dist/lib/preprocessor/preprocessor.cjs +21 -0
- package/dist/lib/preprocessor/preprocessor.js +21 -0
- package/dist/lib/preprocessor/preprocessor.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +11 -19
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +2 -2
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js +12 -20
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +6 -6
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +7 -7
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts +7 -7
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.cjs +4 -1
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.js +4 -1
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.d.ts +2 -0
- package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -1
- package/dist/lib/shader-assembly/shader-plugin-varyings.cjs +39 -22
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts +5 -5
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-plugin-varyings.js +45 -19
- package/dist/lib/shader-assembly/shader-plugin-varyings.js.map +1 -1
- package/dist/lib/shader-generator/glsl/generate-glsl.d.ts +1 -1
- package/dist/lib/shader-generator/glsl/generate-glsl.d.ts.map +1 -1
- package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts +1 -1
- package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -1
- package/dist/lib/shader-plugin.cjs +44 -30
- package/dist/lib/shader-plugin.d.ts +33 -32
- package/dist/lib/shader-plugin.d.ts.map +1 -1
- package/dist/lib/shader-plugin.js +49 -31
- package/dist/lib/shader-plugin.js.map +1 -1
- package/dist/lib/wgsl-shader-assembler.cjs +1 -1
- package/dist/lib/wgsl-shader-assembler.js +1 -1
- package/dist/lib/wgsl-shader-assembler.js.map +1 -1
- package/dist/modules/engine/clip/clip.cjs +18 -30
- package/dist/modules/engine/clip/clip.d.ts.map +1 -1
- package/dist/modules/engine/clip/clip.js +19 -31
- package/dist/modules/engine/clip/clip.js.map +1 -1
- package/dist/modules/engine/filter/filter.cjs +9 -18
- package/dist/modules/engine/filter/filter.d.ts.map +1 -1
- package/dist/modules/engine/filter/filter.js +9 -18
- package/dist/modules/engine/filter/filter.js.map +1 -1
- package/dist/modules/math/fp64/fp64.cjs +1 -1
- package/dist/modules/math/fp64/fp64.d.ts +1 -1
- package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
- package/dist/modules/math/fp64/fp64.js +1 -1
- package/dist/modules/math/fp64/fp64.js.map +1 -1
- package/dist/types.cjs +27 -16
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -7
- package/dist/types.js.map +1 -1
- package/dist/wgsl.cjs +20 -4
- package/dist/wgsl.cjs.map +1 -1
- package/dist/wgsl.d.ts +1 -1
- package/dist/wgsl.d.ts.map +1 -1
- package/dist/wgsl.js +1 -1
- package/dist/wgsl.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +3 -4
- package/src/lib/glsl-shader-assembler.ts +1 -1
- package/src/lib/preprocessor/preprocessor.ts +25 -0
- package/src/lib/shader-assembly/assemble-glsl-shaders.ts +17 -22
- package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +8 -8
- package/src/lib/shader-assembly/shader-assembly-types.ts +7 -7
- package/src/lib/shader-assembly/shader-hooks.ts +6 -1
- package/src/lib/shader-assembly/shader-injections.ts +2 -0
- package/src/lib/shader-assembly/shader-plugin-varyings.ts +58 -27
- package/src/lib/shader-generator/glsl/generate-glsl.ts +1 -1
- package/src/lib/shader-generator/wgsl/generate-wgsl.ts +1 -1
- package/src/lib/shader-module/shader-module-dependencies.ts +1 -1
- package/src/lib/shader-plugin.ts +75 -68
- package/src/lib/wgsl-shader-assembler.ts +1 -1
- package/src/modules/engine/clip/clip.ts +19 -31
- package/src/modules/engine/filter/filter.ts +9 -18
- package/src/modules/math/fp64/fp64.ts +1 -1
- package/src/types.ts +75 -7
- package/src/wgsl.ts +12 -1
|
@@ -24,45 +24,55 @@ module.exports = __toCommonJS(shader_plugin_exports);
|
|
|
24
24
|
var import_types = require("../types.cjs");
|
|
25
25
|
const SHADER_PLUGIN_INJECTION_TARGET_REGEX = /^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;
|
|
26
26
|
function resolveShaderPlugins(plugins = [], shaderLanguage) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const resolved = {
|
|
28
|
+
modules: [],
|
|
29
|
+
defines: {},
|
|
30
|
+
injections: {},
|
|
31
|
+
vertexInputs: {},
|
|
32
|
+
interStageVariables: {}
|
|
33
|
+
};
|
|
32
34
|
for (const plugin of plugins) {
|
|
33
|
-
|
|
34
|
-
appendShaderPluginVariant({ modules, defines, injections, vertexInputs, varyings }, plugin[shaderLanguage]);
|
|
35
|
+
appendShaderPlugin(resolved, plugin, shaderLanguage);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
const { vertexInputs, interStageVariables } = resolved;
|
|
38
|
+
for (const name of Object.keys(interStageVariables)) {
|
|
37
39
|
if (vertexInputs[name]) {
|
|
38
40
|
throw new Error(`ShaderPlugin name "${name}" cannot be both a vertex input and a varying`);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
return
|
|
43
|
+
return resolved;
|
|
42
44
|
}
|
|
43
|
-
function mergeShaderPluginModules(modules = [], pluginModules = []) {
|
|
45
|
+
function mergeShaderPluginModules(modules = [], pluginModules = [], options = {}) {
|
|
46
|
+
var _a, _b;
|
|
44
47
|
const mergedModules = [...modules];
|
|
45
|
-
const
|
|
48
|
+
const selectedModules = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const module2 of mergedModules) {
|
|
50
|
+
const selected = selectedModules.get(module2.name);
|
|
51
|
+
if (selected && selected !== module2)
|
|
52
|
+
(_a = options.onConflict) == null ? void 0 : _a.call(options, module2.name, selected, module2);
|
|
53
|
+
if (!selected)
|
|
54
|
+
selectedModules.set(module2.name, module2);
|
|
55
|
+
}
|
|
46
56
|
for (const pluginModule of pluginModules) {
|
|
47
|
-
|
|
57
|
+
const selected = selectedModules.get(pluginModule.name);
|
|
58
|
+
if (selected && selected !== pluginModule) {
|
|
59
|
+
(_b = options.onConflict) == null ? void 0 : _b.call(options, pluginModule.name, selected, pluginModule);
|
|
60
|
+
}
|
|
61
|
+
if (!selected) {
|
|
48
62
|
mergedModules.push(pluginModule);
|
|
49
|
-
|
|
63
|
+
selectedModules.set(pluginModule.name, pluginModule);
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
return mergedModules;
|
|
53
67
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if ((_a = variant.modules) == null ? void 0 : _a.length) {
|
|
60
|
-
resolved.modules.push(...variant.modules);
|
|
68
|
+
function appendShaderPlugin(resolved, plugin, shaderLanguage) {
|
|
69
|
+
if (plugin.module) {
|
|
70
|
+
resolved.modules.push(plugin.module);
|
|
61
71
|
}
|
|
62
|
-
if (
|
|
63
|
-
Object.assign(resolved.defines,
|
|
72
|
+
if (plugin.defines) {
|
|
73
|
+
Object.assign(resolved.defines, plugin.defines);
|
|
64
74
|
}
|
|
65
|
-
for (const [name, type] of Object.entries(
|
|
75
|
+
for (const [name, type] of Object.entries(plugin.vertexInputs || {})) {
|
|
66
76
|
assertShaderPluginInterfaceName(name, "vertex input");
|
|
67
77
|
const existingType = resolved.vertexInputs[name];
|
|
68
78
|
if (existingType && existingType !== type) {
|
|
@@ -70,23 +80,27 @@ function appendShaderPluginVariant(resolved, variant) {
|
|
|
70
80
|
}
|
|
71
81
|
resolved.vertexInputs[name] = type;
|
|
72
82
|
}
|
|
73
|
-
for (const [name, varying] of Object.entries(
|
|
83
|
+
for (const [name, varying] of Object.entries(plugin.interStageVariables || {})) {
|
|
74
84
|
assertShaderPluginInterfaceName(name, "varying");
|
|
75
|
-
const normalizedVarying =
|
|
76
|
-
const existingVarying = resolved.
|
|
85
|
+
const normalizedVarying = normalizeShaderPluginInterStageVariable(name, varying);
|
|
86
|
+
const existingVarying = resolved.interStageVariables[name];
|
|
77
87
|
if (existingVarying && (existingVarying.type !== normalizedVarying.type || existingVarying.interpolation !== normalizedVarying.interpolation)) {
|
|
78
88
|
throw new Error(`ShaderPlugin varying "${name}" has conflicting declarations "${existingVarying.type}/${existingVarying.interpolation}" and "${normalizedVarying.type}/${normalizedVarying.interpolation}"`);
|
|
79
89
|
}
|
|
80
|
-
resolved.
|
|
90
|
+
resolved.interStageVariables[name] = normalizedVarying;
|
|
81
91
|
}
|
|
82
|
-
for (const injection of
|
|
92
|
+
for (const injection of plugin.injections || []) {
|
|
93
|
+
const source = injection[shaderLanguage];
|
|
94
|
+
if (source === void 0)
|
|
95
|
+
continue;
|
|
83
96
|
assertNamedShaderPluginInjectionTarget(injection.target);
|
|
84
97
|
if (!resolved.injections[injection.target]) {
|
|
85
98
|
resolved.injections[injection.target] = [];
|
|
86
99
|
}
|
|
87
100
|
const injections = resolved.injections[injection.target];
|
|
88
101
|
injections.push({
|
|
89
|
-
|
|
102
|
+
pluginName: plugin.name,
|
|
103
|
+
injection: source,
|
|
90
104
|
order: injection.order ?? 0
|
|
91
105
|
});
|
|
92
106
|
}
|
|
@@ -96,7 +110,7 @@ function assertShaderPluginInterfaceName(name, kind) {
|
|
|
96
110
|
throw new Error(`ShaderPlugin ${kind} "${name}" must be a valid non-reserved identifier`);
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
|
-
function
|
|
113
|
+
function normalizeShaderPluginInterStageVariable(name, varying) {
|
|
100
114
|
const { primitiveType } = import_types.shaderTypeDecoder.getAttributeShaderTypeInfo(varying.type);
|
|
101
115
|
const integerType = primitiveType === "i32" || primitiveType === "u32";
|
|
102
116
|
const interpolation = varying.interpolation || (integerType ? "flat" : "smooth");
|
|
@@ -7,62 +7,63 @@ export type ShaderPluginInjectionTarget = 'vs:#decl' | 'vs:#main-start' | 'vs:#m
|
|
|
7
7
|
export type ShaderPluginInjection = {
|
|
8
8
|
/** Named shader anchor or hook that receives this source. */
|
|
9
9
|
target: ShaderPluginInjectionTarget;
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/** GLSL source for this target. Omit to skip this injection when assembling GLSL. */
|
|
11
|
+
glsl?: string;
|
|
12
|
+
/** WGSL source for this target. Omit to skip this injection when assembling WGSL. */
|
|
13
|
+
wgsl?: string;
|
|
12
14
|
/** Relative injection order within the target. */
|
|
13
15
|
order?: number;
|
|
14
16
|
};
|
|
15
|
-
/** Portable interpolation modes for ShaderPlugin
|
|
16
|
-
export type
|
|
17
|
+
/** Portable interpolation modes for ShaderPlugin inter-stage variables. */
|
|
18
|
+
export type ShaderPluginInterStageVariableInterpolation = 'smooth' | 'flat';
|
|
17
19
|
/** Cross-stage value contributed by a ShaderPlugin. */
|
|
18
|
-
export type
|
|
20
|
+
export type ShaderPluginInterStageVariable = {
|
|
19
21
|
/** Portable scalar or vector shader type. */
|
|
20
22
|
type: AttributeShaderType;
|
|
21
23
|
/** Defaults to smooth for floating-point types and flat for integer types. */
|
|
22
|
-
interpolation?:
|
|
24
|
+
interpolation?: ShaderPluginInterStageVariableInterpolation;
|
|
23
25
|
};
|
|
24
|
-
/** Fully normalized ShaderPlugin
|
|
25
|
-
export type
|
|
26
|
+
/** Fully normalized ShaderPlugin inter-stage variable declaration. */
|
|
27
|
+
export type ResolvedShaderPluginInterStageVariable = {
|
|
26
28
|
type: AttributeShaderType;
|
|
27
|
-
interpolation:
|
|
29
|
+
interpolation: ShaderPluginInterStageVariableInterpolation;
|
|
28
30
|
};
|
|
29
|
-
/**
|
|
30
|
-
export type
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
31
|
+
/** Reusable shader assembly descriptor with one portable interface and language-specific source. */
|
|
32
|
+
export type ShaderPlugin = {
|
|
33
|
+
/** Stable plugin identifier. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Primary shader module. Supporting modules belong in its dependencies; omit for injection-only plugins. */
|
|
36
|
+
module?: ShaderModule<any, any, any>;
|
|
37
|
+
/** Boolean or numeric preprocessor defines added to shader assembly. */
|
|
38
|
+
defines?: Record<string, boolean | number>;
|
|
35
39
|
/** Named code injections added to shader assembly. */
|
|
36
40
|
injections?: ShaderPluginInjection[];
|
|
37
41
|
/** Shader-facing vertex inputs added by this plugin. Buffer ownership remains with the caller. */
|
|
38
42
|
vertexInputs?: Record<string, AttributeShaderType>;
|
|
39
43
|
/** Values transported from the selected vertex entry point to the fragment entry point. */
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
/** Reusable cross-backend shader assembly descriptor. */
|
|
43
|
-
export type ShaderPlugin = ShaderPluginVariant & {
|
|
44
|
-
/** Stable plugin identifier. */
|
|
45
|
-
name: string;
|
|
46
|
-
/** GLSL-only shader assembly contributions. */
|
|
47
|
-
glsl?: ShaderPluginVariant;
|
|
48
|
-
/** WGSL-only shader assembly contributions. */
|
|
49
|
-
wgsl?: ShaderPluginVariant;
|
|
44
|
+
interStageVariables?: Record<string, ShaderPluginInterStageVariable>;
|
|
50
45
|
};
|
|
51
46
|
/** ShaderPlugin contributions resolved for one shader language. */
|
|
52
47
|
export type ResolvedShaderPlugins = {
|
|
53
48
|
/** Resolved shader modules in plugin declaration order. */
|
|
54
49
|
modules: ShaderModule[];
|
|
55
|
-
/** Resolved boolean preprocessor defines. */
|
|
56
|
-
defines: Record<string, boolean>;
|
|
50
|
+
/** Resolved boolean or numeric preprocessor defines. */
|
|
51
|
+
defines: Record<string, boolean | number>;
|
|
57
52
|
/** Resolved named code injections grouped by target. */
|
|
58
53
|
injections: Record<string, ShaderInjection[]>;
|
|
59
54
|
/** Resolved shader-facing vertex inputs in plugin declaration order. */
|
|
60
55
|
vertexInputs: Record<string, AttributeShaderType>;
|
|
61
|
-
/** Resolved
|
|
62
|
-
|
|
56
|
+
/** Resolved inter-stage variables in plugin declaration order. */
|
|
57
|
+
interStageVariables: Record<string, ResolvedShaderPluginInterStageVariable>;
|
|
63
58
|
};
|
|
64
|
-
/** Resolve
|
|
59
|
+
/** Resolve plugin interfaces and select injection source for one shader language. */
|
|
65
60
|
export declare function resolveShaderPlugins(plugins: readonly ShaderPlugin[] | undefined, shaderLanguage: 'glsl' | 'wgsl'): ResolvedShaderPlugins;
|
|
66
|
-
/**
|
|
67
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Preserve explicit module inputs while appending plugin modules by first-seen name.
|
|
63
|
+
* Optional diagnostics report distinct descriptors sharing a name, without changing selection.
|
|
64
|
+
* Descriptor identity is checked; equivalent independently-created descriptors also report a conflict.
|
|
65
|
+
*/
|
|
66
|
+
export declare function mergeShaderPluginModules(modules?: readonly ShaderModule[], pluginModules?: readonly ShaderModule[], options?: {
|
|
67
|
+
onConflict?: (name: string, selected: ShaderModule, ignored: ShaderModule) => void;
|
|
68
|
+
}): ShaderModule[];
|
|
68
69
|
//# sourceMappingURL=shader-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-plugin.d.ts","sourceRoot":"","sources":["../../src/lib/shader-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,+CAA4C;AACzE,OAAO,KAAK,EAAC,YAAY,EAAC,yCAAsC;AAChE,OAAO,EAAoB,KAAK,mBAAmB,EAAC,oBAAiB;AAErE,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GACnC,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,MAAM,MAAM,EAAE,GACd,MAAM,MAAM,EAAE,CAAC;AAEnB,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,6DAA6D;IAC7D,MAAM,EAAE,2BAA2B,CAAC;IACpC,
|
|
1
|
+
{"version":3,"file":"shader-plugin.d.ts","sourceRoot":"","sources":["../../src/lib/shader-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,+CAA4C;AACzE,OAAO,KAAK,EAAC,YAAY,EAAC,yCAAsC;AAChE,OAAO,EAAoB,KAAK,mBAAmB,EAAC,oBAAiB;AAErE,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GACnC,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,MAAM,MAAM,EAAE,GACd,MAAM,MAAM,EAAE,CAAC;AAEnB,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,6DAA6D;IAC7D,MAAM,EAAE,2BAA2B,CAAC;IACpC,qFAAqF;IACrF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IAC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CAAC,CAAC;IAC9C,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAClD,kEAAkE;IAClE,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,sCAAsC,CAAC,CAAC;CAC7E,CAAC;AAKF,qFAAqF;AACrF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,YAAY,EAAE,YAAK,EACrC,cAAc,EAAE,MAAM,GAAG,MAAM,GAC9B,qBAAqB,CAqBvB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,SAAS,YAAY,EAAO,EACrC,aAAa,GAAE,SAAS,YAAY,EAAO,EAC3C,OAAO,GAAE;IAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;CAAM,GACjG,YAAY,EAAE,CAqBhB"}
|
|
@@ -3,47 +3,61 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
import { shaderTypeDecoder } from "../types.js";
|
|
5
5
|
const SHADER_PLUGIN_INJECTION_TARGET_REGEX = /^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;
|
|
6
|
-
/** Resolve
|
|
6
|
+
/** Resolve plugin interfaces and select injection source for one shader language. */
|
|
7
7
|
export function resolveShaderPlugins(plugins = [], shaderLanguage) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const resolved = {
|
|
9
|
+
modules: [],
|
|
10
|
+
defines: {},
|
|
11
|
+
injections: {},
|
|
12
|
+
vertexInputs: {},
|
|
13
|
+
interStageVariables: {}
|
|
14
|
+
};
|
|
13
15
|
for (const plugin of plugins) {
|
|
14
|
-
|
|
15
|
-
appendShaderPluginVariant({ modules, defines, injections, vertexInputs, varyings }, plugin[shaderLanguage]);
|
|
16
|
+
appendShaderPlugin(resolved, plugin, shaderLanguage);
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
const { vertexInputs, interStageVariables } = resolved;
|
|
19
|
+
for (const name of Object.keys(interStageVariables)) {
|
|
18
20
|
if (vertexInputs[name]) {
|
|
19
21
|
throw new Error(`ShaderPlugin name "${name}" cannot be both a vertex input and a varying`);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
return
|
|
24
|
+
return resolved;
|
|
23
25
|
}
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Preserve explicit module inputs while appending plugin modules by first-seen name.
|
|
28
|
+
* Optional diagnostics report distinct descriptors sharing a name, without changing selection.
|
|
29
|
+
* Descriptor identity is checked; equivalent independently-created descriptors also report a conflict.
|
|
30
|
+
*/
|
|
31
|
+
export function mergeShaderPluginModules(modules = [], pluginModules = [], options = {}) {
|
|
26
32
|
const mergedModules = [...modules];
|
|
27
|
-
const
|
|
33
|
+
const selectedModules = new Map();
|
|
34
|
+
for (const module of mergedModules) {
|
|
35
|
+
const selected = selectedModules.get(module.name);
|
|
36
|
+
if (selected && selected !== module)
|
|
37
|
+
options.onConflict?.(module.name, selected, module);
|
|
38
|
+
if (!selected)
|
|
39
|
+
selectedModules.set(module.name, module);
|
|
40
|
+
}
|
|
28
41
|
for (const pluginModule of pluginModules) {
|
|
29
|
-
|
|
42
|
+
const selected = selectedModules.get(pluginModule.name);
|
|
43
|
+
if (selected && selected !== pluginModule) {
|
|
44
|
+
options.onConflict?.(pluginModule.name, selected, pluginModule);
|
|
45
|
+
}
|
|
46
|
+
if (!selected) {
|
|
30
47
|
mergedModules.push(pluginModule);
|
|
31
|
-
|
|
48
|
+
selectedModules.set(pluginModule.name, pluginModule);
|
|
32
49
|
}
|
|
33
50
|
}
|
|
34
51
|
return mergedModules;
|
|
35
52
|
}
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
if (variant.modules?.length) {
|
|
41
|
-
resolved.modules.push(...variant.modules);
|
|
53
|
+
function appendShaderPlugin(resolved, plugin, shaderLanguage) {
|
|
54
|
+
if (plugin.module) {
|
|
55
|
+
resolved.modules.push(plugin.module);
|
|
42
56
|
}
|
|
43
|
-
if (
|
|
44
|
-
Object.assign(resolved.defines,
|
|
57
|
+
if (plugin.defines) {
|
|
58
|
+
Object.assign(resolved.defines, plugin.defines);
|
|
45
59
|
}
|
|
46
|
-
for (const [name, type] of Object.entries(
|
|
60
|
+
for (const [name, type] of Object.entries(plugin.vertexInputs || {})) {
|
|
47
61
|
assertShaderPluginInterfaceName(name, 'vertex input');
|
|
48
62
|
const existingType = resolved.vertexInputs[name];
|
|
49
63
|
if (existingType && existingType !== type) {
|
|
@@ -51,10 +65,10 @@ function appendShaderPluginVariant(resolved, variant) {
|
|
|
51
65
|
}
|
|
52
66
|
resolved.vertexInputs[name] = type;
|
|
53
67
|
}
|
|
54
|
-
for (const [name, varying] of Object.entries(
|
|
68
|
+
for (const [name, varying] of Object.entries(plugin.interStageVariables || {})) {
|
|
55
69
|
assertShaderPluginInterfaceName(name, 'varying');
|
|
56
|
-
const normalizedVarying =
|
|
57
|
-
const existingVarying = resolved.
|
|
70
|
+
const normalizedVarying = normalizeShaderPluginInterStageVariable(name, varying);
|
|
71
|
+
const existingVarying = resolved.interStageVariables[name];
|
|
58
72
|
if (existingVarying &&
|
|
59
73
|
(existingVarying.type !== normalizedVarying.type ||
|
|
60
74
|
existingVarying.interpolation !== normalizedVarying.interpolation)) {
|
|
@@ -62,16 +76,20 @@ function appendShaderPluginVariant(resolved, variant) {
|
|
|
62
76
|
`"${existingVarying.type}/${existingVarying.interpolation}" and ` +
|
|
63
77
|
`"${normalizedVarying.type}/${normalizedVarying.interpolation}"`);
|
|
64
78
|
}
|
|
65
|
-
resolved.
|
|
79
|
+
resolved.interStageVariables[name] = normalizedVarying;
|
|
66
80
|
}
|
|
67
|
-
for (const injection of
|
|
81
|
+
for (const injection of plugin.injections || []) {
|
|
82
|
+
const source = injection[shaderLanguage];
|
|
83
|
+
if (source === undefined)
|
|
84
|
+
continue;
|
|
68
85
|
assertNamedShaderPluginInjectionTarget(injection.target);
|
|
69
86
|
if (!resolved.injections[injection.target]) {
|
|
70
87
|
resolved.injections[injection.target] = [];
|
|
71
88
|
}
|
|
72
89
|
const injections = resolved.injections[injection.target];
|
|
73
90
|
injections.push({
|
|
74
|
-
|
|
91
|
+
pluginName: plugin.name,
|
|
92
|
+
injection: source,
|
|
75
93
|
order: injection.order ?? 0
|
|
76
94
|
});
|
|
77
95
|
}
|
|
@@ -81,7 +99,7 @@ function assertShaderPluginInterfaceName(name, kind) {
|
|
|
81
99
|
throw new Error(`ShaderPlugin ${kind} "${name}" must be a valid non-reserved identifier`);
|
|
82
100
|
}
|
|
83
101
|
}
|
|
84
|
-
function
|
|
102
|
+
function normalizeShaderPluginInterStageVariable(name, varying) {
|
|
85
103
|
const { primitiveType } = shaderTypeDecoder.getAttributeShaderTypeInfo(varying.type);
|
|
86
104
|
const integerType = primitiveType === 'i32' || primitiveType === 'u32';
|
|
87
105
|
const interpolation = varying.interpolation || (integerType ? 'flat' : 'smooth');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-plugin.js","sourceRoot":"","sources":["../../src/lib/shader-plugin.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,iBAAiB,EAA2B,oBAAiB;
|
|
1
|
+
{"version":3,"file":"shader-plugin.js","sourceRoot":"","sources":["../../src/lib/shader-plugin.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,iBAAiB,EAA2B,oBAAiB;AAwErE,MAAM,oCAAoC,GACxC,6DAA6D,CAAC;AAEhE,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAClC,UAAmC,EAAE,EACrC,cAA+B;IAE/B,M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
|
37
37
|
assembleWGSLShader(props) {
|
|
38
38
|
var _a, _b, _c;
|
|
39
39
|
const modules = this._getModuleList(props.modules);
|
|
40
|
-
const hookFunctions = this._hookFunctions;
|
|
40
|
+
const hookFunctions = [...this._hookFunctions, ...props.hookFunctions || []];
|
|
41
41
|
const translated = this._transpileShader(props, modules, props.source, props.shaderStage ?? (props.computeEntryPoint ? "compute" : void 0));
|
|
42
42
|
const entryPoints = {
|
|
43
43
|
vertex: ((_a = translated.entryPoints) == null ? void 0 : _a.vertex) ?? props.vertexEntryPoint,
|
|
@@ -18,7 +18,7 @@ export class WGSLShaderAssembler extends ShaderAssembler {
|
|
|
18
18
|
*/
|
|
19
19
|
assembleWGSLShader(props) {
|
|
20
20
|
const modules = this._getModuleList(props.modules); // Combine with default modules
|
|
21
|
-
const hookFunctions = this._hookFunctions
|
|
21
|
+
const hookFunctions = [...this._hookFunctions, ...(props.hookFunctions || [])];
|
|
22
22
|
const translated = this._transpileShader(props, modules, props.source, props.shaderStage ?? (props.computeEntryPoint ? 'compute' : undefined));
|
|
23
23
|
const entryPoints = {
|
|
24
24
|
vertex: translated.entryPoints?.vertex ?? props.vertexEntryPoint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgsl-shader-assembler.js","sourceRoot":"","sources":["../../src/lib/wgsl-shader-assembler.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,eAAe,EAAC,mCAAgC;AAGxD,OAAO,EAAC,kBAAkB,EAAC,mDAAgD;AAC3E,OAAO,EACL,iCAAiC,EAElC,gDAA6C;AAC9C,OAAO,EAAC,UAAU,EAAC,uCAAoC;AACvD,OAAO,EAAC,iBAAiB,EAAC,iDAA8C;AAIxE,mDAAmD;AACnD,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAC7C,cAAc,GAAW,MAAM,CAAC;IACzC,kFAAkF;IACjE,oBAAoB,GAAG,IAAI,GAAG,EAAkB,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
107
|
+
interStageVariables: {
|
|
108
108
|
clipCoordinates: { type: "vec2<f32>", interpolation: "smooth" }
|
|
109
109
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
injection: `clipCoordinates = geometryCoordinates;
|
|
110
|
+
injections: [
|
|
111
|
+
{
|
|
112
|
+
target: "vs:CLIP_POSITION",
|
|
113
|
+
glsl: `clipCoordinates = geometryCoordinates;
|
|
115
114
|
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_INSTANCE} &&
|
|
116
115
|
!clip_isInBounds(instanceCoordinates)) {
|
|
117
116
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
target: "fs:CLIP_COLOR",
|
|
122
|
-
injection: `if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
123
|
-
!clip_isInBounds(clipCoordinates)) {
|
|
124
|
-
discard;
|
|
125
|
-
}`
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
wgsl: {
|
|
130
|
-
injections: [
|
|
131
|
-
{
|
|
132
|
-
target: "vs:CLIP_POSITION",
|
|
133
|
-
injection: `clipCoordinates = geometryCoordinates;
|
|
117
|
+
}`,
|
|
118
|
+
wgsl: `clipCoordinates = geometryCoordinates;
|
|
134
119
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_INSTANCE} &&
|
|
135
120
|
!clip_isInBounds(instanceCoordinates)) {
|
|
136
121
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
137
122
|
}`
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
target: "fs:CLIP_COLOR",
|
|
126
|
+
glsl: `if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
127
|
+
!clip_isInBounds(clipCoordinates)) {
|
|
128
|
+
discard;
|
|
129
|
+
}`,
|
|
130
|
+
wgsl: `if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
142
131
|
!clip_isInBounds(clipCoordinates)) {
|
|
143
132
|
discard;
|
|
144
133
|
}`
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
134
|
+
}
|
|
135
|
+
]
|
|
148
136
|
};
|
|
149
137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
150
138
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/clip/clip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,sCAAmC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,2FAA2F;IAC3F,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAChC,CAAC;AAqFF,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/clip/clip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,sCAAmC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,2FAA2F;IAC3F,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAChC,CAAC;AAqFF,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,YAoC9B,CAAC"}
|
|
@@ -79,51 +79,39 @@ fn clip_isInBounds(coordinates: vec2<f32>) -> bool {
|
|
|
79
79
|
/** Coordinate-system-neutral instance and geometry clipping. */
|
|
80
80
|
export const clipShaderPlugin = {
|
|
81
81
|
name: 'clip',
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
module: clipShaderModule,
|
|
83
|
+
interStageVariables: {
|
|
84
84
|
clipCoordinates: { type: 'vec2<f32>', interpolation: 'smooth' }
|
|
85
85
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
injection: `\
|
|
86
|
+
injections: [
|
|
87
|
+
{
|
|
88
|
+
target: 'vs:CLIP_POSITION',
|
|
89
|
+
glsl: `\
|
|
91
90
|
clipCoordinates = geometryCoordinates;
|
|
92
91
|
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_INSTANCE} &&
|
|
93
92
|
!clip_isInBounds(instanceCoordinates)) {
|
|
94
93
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
target: 'fs:CLIP_COLOR',
|
|
99
|
-
injection: `\
|
|
100
|
-
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
101
|
-
!clip_isInBounds(clipCoordinates)) {
|
|
102
|
-
discard;
|
|
103
|
-
}`
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
wgsl: {
|
|
108
|
-
injections: [
|
|
109
|
-
{
|
|
110
|
-
target: 'vs:CLIP_POSITION',
|
|
111
|
-
injection: `\
|
|
94
|
+
}`,
|
|
95
|
+
wgsl: `\
|
|
112
96
|
clipCoordinates = geometryCoordinates;
|
|
113
97
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_INSTANCE} &&
|
|
114
98
|
!clip_isInBounds(instanceCoordinates)) {
|
|
115
99
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
116
100
|
}`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
target: 'fs:CLIP_COLOR',
|
|
104
|
+
glsl: `\
|
|
105
|
+
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
106
|
+
!clip_isInBounds(clipCoordinates)) {
|
|
107
|
+
discard;
|
|
108
|
+
}`,
|
|
109
|
+
wgsl: `\
|
|
121
110
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
122
111
|
!clip_isInBounds(clipCoordinates)) {
|
|
123
112
|
discard;
|
|
124
113
|
}`
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
128
116
|
};
|
|
129
117
|
//# sourceMappingURL=clip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip.js","sourceRoot":"","sources":["../../../../src/modules/engine/clip/clip.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAoB5D,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,EAA2B;IAClC,QAAQ,EAAE,EAAkB;IAC5B,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IACzC,YAAY,EAAE;QACZ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,WAAW;KACpB;IACD,eAAe,EAAE;QACf,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,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DAEsC,kBAAkB;;;EAGlE;YACI,IAAI,EAAE;;wDAE4C,kBAAkB;;;EAGxE;SACG;QACD;YACE,MAAM,EAAE,eAAe;YACvB,IAAI,EAAE;kDACsC,kBAAkB;;;EAGlE;YACI,IAAI,EAAE;wDAC4C,kBAAkB;;;EAGxE;SACG;KACF;CACF,CAAC"}
|
|
@@ -80,30 +80,21 @@ fn filter_isVisible(value: f32) -> bool {
|
|
|
80
80
|
};
|
|
81
81
|
const filterShaderPlugin = {
|
|
82
82
|
name: "filter",
|
|
83
|
-
|
|
83
|
+
module: filterShaderModule,
|
|
84
84
|
vertexInputs: {
|
|
85
85
|
filterValues: "f32"
|
|
86
86
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
injection: `if (!filter_isVisible(filterValues)) {
|
|
87
|
+
injections: [
|
|
88
|
+
{
|
|
89
|
+
target: "vs:FILTER_POSITION",
|
|
90
|
+
glsl: `if (!filter_isVisible(filterValues)) {
|
|
92
91
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
wgsl: {
|
|
98
|
-
injections: [
|
|
99
|
-
{
|
|
100
|
-
target: "vs:FILTER_POSITION",
|
|
101
|
-
injection: `if (!filter_isVisible(filterValues)) {
|
|
92
|
+
}`,
|
|
93
|
+
wgsl: `if (!filter_isVisible(filterValues)) {
|
|
102
94
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
103
95
|
}`
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
107
98
|
};
|
|
108
99
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
100
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/filter/filter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,sCAAmC;AAE7D,MAAM,MAAM,uBAAuB,GAAG;IACpC,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA+DF,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/filter/filter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,sCAAmC;AAE7D,MAAM,MAAM,uBAAuB,GAAG;IACpC,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA+DF,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,EAAE,YAmBhC,CAAC"}
|