@luma.gl/shaders 10.0.0-alpha.7 → 10.0.0-alpha.9
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/dist/dist.dev.js +233 -249
- package/dist/dist.min.js +124 -124
- package/dist/glsl.cjs.map +2 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/shader-assembler-base.cjs +3 -4
- package/dist/lib/shader-assembler-base.d.ts +4 -5
- package/dist/lib/shader-assembler-base.d.ts.map +1 -1
- package/dist/lib/shader-assembler-base.js +3 -4
- package/dist/lib/shader-assembler-base.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +6 -17
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +5 -4
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js +14 -19
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +6 -25
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts +5 -6
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +14 -27
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts +2 -2
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-shared.js.map +1 -1
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts +11 -7
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.cjs +26 -29
- package/dist/lib/shader-assembly/shader-hooks.d.ts +34 -32
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.js +29 -33
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.cjs +26 -2
- package/dist/lib/shader-assembly/shader-injections.d.ts +20 -7
- package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.js +24 -0
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -1
- package/dist/lib/shader-module/shader-module.cjs +3 -9
- package/dist/lib/shader-module/shader-module.d.ts +4 -8
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +3 -6
- package/dist/lib/shader-module/shader-module.js.map +1 -1
- package/dist/lib/shader-plugin.cjs +38 -17
- package/dist/lib/shader-plugin.d.ts +9 -17
- package/dist/lib/shader-plugin.d.ts.map +1 -1
- package/dist/lib/shader-plugin.js +43 -16
- package/dist/lib/shader-plugin.js.map +1 -1
- package/dist/modules/engine/clip/clip.cjs +4 -2
- package/dist/modules/engine/clip/clip.d.ts.map +1 -1
- package/dist/modules/engine/clip/clip.js +4 -2
- package/dist/modules/engine/clip/clip.js.map +1 -1
- package/dist/modules/engine/filter/filter.cjs +2 -1
- package/dist/modules/engine/filter/filter.d.ts.map +1 -1
- package/dist/modules/engine/filter/filter.js +2 -1
- package/dist/modules/engine/filter/filter.js.map +1 -1
- package/dist/modules/lighting/lights/lighting.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.cjs +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.cjs +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +2 -2
- package/dist/types/texture-formats.d.ts +1 -1
- package/dist/types/texture-formats.d.ts.map +1 -1
- package/dist/wgsl.cjs.map +2 -2
- package/package.json +3 -3
- package/src/index.ts +5 -4
- package/src/lib/shader-assembler-base.ts +5 -6
- package/src/lib/shader-assembly/assemble-glsl-shaders.ts +27 -26
- package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +28 -43
- package/src/lib/shader-assembly/shader-assembly-shared.ts +5 -5
- package/src/lib/shader-assembly/shader-assembly-types.ts +11 -7
- package/src/lib/shader-assembly/shader-hooks.ts +65 -68
- package/src/lib/shader-assembly/shader-injections.ts +52 -8
- package/src/lib/shader-module/shader-module.ts +7 -14
- package/src/lib/shader-plugin.ts +59 -48
- package/src/modules/engine/clip/clip.ts +4 -2
- package/src/modules/engine/filter/filter.ts +2 -1
- package/src/modules/lighting/lights/lighting.ts +1 -1
- package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +2 -2
- package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +2 -2
- package/src/types/texture-formats.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { PlatformInfo } from "./lib/shader-assembly/platform-info.js";
|
|
|
6
6
|
export type { ShaderBindingDebugRow } from "./lib/shader-assembly/wgsl-binding-debug.js";
|
|
7
7
|
export { scanWGSLInterface, type ScanWGSLInterfaceOptions } from "./lib/shader-assembly/wgsl-interface-scan.js";
|
|
8
8
|
export type { ShaderModule } from "./lib/shader-module/shader-module.js";
|
|
9
|
-
export type { ResolvedShaderPlugins, ResolvedShaderPluginInterStageVariable, ShaderPlugin,
|
|
9
|
+
export type { ResolvedShaderPlugins, ResolvedShaderPluginInterStageVariable, ShaderPlugin, ShaderPluginInterStageVariable, ShaderPluginInterStageVariableInterpolation } from "./lib/shader-plugin.js";
|
|
10
10
|
export type { ShaderPass, ShaderPassInputSource, ShaderPassRenderTarget, ShaderSubPass } from "./lib/shader-module/shader-pass.js";
|
|
11
11
|
export type { CompositeShaderPassComputeOptimization, CompositeShaderPass, CompositeShaderPassStep } from "./lib/shader-module/composite-shader-pass.js";
|
|
12
12
|
export type { ShaderModuleUniformValue, UniformTypes } from "./lib/utils/uniform-types.js";
|
|
@@ -20,8 +20,8 @@ export { getGLSLUniformBlocks, getShaderModuleUniformBlockFields, getShaderModul
|
|
|
20
20
|
export { getShaderModuleSource } from "./lib/shader-assembly/assemble-shaders.js";
|
|
21
21
|
export { resolveModules as _resolveModules } from "./lib/shader-module/shader-module-dependencies.js";
|
|
22
22
|
export { ShaderAssembler, GLSLShaderAssembler, WGSLShaderAssembler } from "./lib/shader-assembler.js";
|
|
23
|
-
export type { ShaderHook,
|
|
24
|
-
export type { ShaderInjection } from "./lib/shader-assembly/shader-injections.js";
|
|
23
|
+
export type { ShaderHook, ShaderHookImplementation } from "./lib/shader-assembly/shader-hooks.js";
|
|
24
|
+
export type { ShaderInjection, ResolvedShaderInjection } from "./lib/shader-assembly/shader-injections.js";
|
|
25
25
|
export { getShaderInfo } from "./lib/glsl-utils/get-shader-info.js";
|
|
26
26
|
export { getQualifierDetails, getPassthroughFS, typeToChannelSuffix, typeToChannelCount, convertToVec4 } from "./lib/glsl-utils/shader-utils.js";
|
|
27
27
|
export type { ShaderGenerationOptions } from "./lib/shader-generator/generate-shader.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,YAAY,EAAC,YAAY,EAAC,+CAA4C;AACtE,YAAY,EAAC,qBAAqB,EAAC,oDAAiD;AACpF,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC9B,qDAAkD;AAInD,YAAY,EAAC,YAAY,EAAC,6CAA0C;AACpE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,EACL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,0DAAuD"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAU5D,OAAO,EACL,iBAAiB,EAElB,qDAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAU5D,OAAO,EACL,iBAAiB,EAElB,qDAAkD;AAyBnD,OAAO,EAAC,sBAAsB,EAAE,uBAAuB,EAAC,6CAA0C;AAClG,OAAO,EAAC,uBAAuB,EAAC,6CAA0C;AAC1E,OAAO,EAAC,2BAA2B,EAAC,0DAAuD;AAC3F,OAAO,EAAC,6BAA6B,EAAC,6CAA0C;AAChF,OAAO,EAAC,wBAAwB,EAAE,oBAAoB,EAAC,+BAA4B;AAMnF,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,+BAA+B,EAC/B,4CAA4C,EAC5C,iCAAiC,EACjC,mCAAmC,EACpC,4DAAyD;AAE1D,OAAO,EAAC,qBAAqB,EAAC,kDAA+C;AAE7E,OAAO,EAAC,cAAc,IAAI,eAAe,EAAC,0DAAuD;AAEjG,kBAAkB;AAClB,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAE,mBAAmB,EAAC,kCAA+B;AAOjG,iBAAiB;AAEjB,8BAA8B;AAC9B,OAAO,EAAC,aAAa,EAAC,4CAAyC;AAC/D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACd,yCAAsC;AAIvC,OAAO,EAAC,uBAAuB,EAAC,kDAA+C;AAC/E,OAAO,EAAC,UAAU,EAAC,mDAAgD;AAEnE,uDAAuD;AACvD,OAAO,EAAC,UAAU,EAA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F,OAAO,EAAC,WAAW,EAAC,wDAAqD;AACzE,OAAO,EAAC,QAAQ,EAAE,iBAAiB,EAAC,qDAAkD;AAEtF,OAAO,EAAC,SAAS,EAAC,oDAAiD;AACnE,OAAO,EAAC,kBAAkB,EAAC,8DAA2D;AAEtF,OAAO,EACL,WAAW,EAGZ,wDAAqD;AACtD,OAAO,EACL,SAAS,EAGV,oDAAiD;AAElD,OAAO,EAAC,aAAa,EAAC,0DAAuD;AAa7E,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAClE,OAAO,EAAC,MAAM,EAAsC,4CAAyC;AAE7F,OAAO,EACL,UAAU,EAGX,oDAAiD;AAClD,OAAO,EACL,cAAc,EACd,uBAAuB,EAKxB,8DAA2D;AAE5D,OAAO,EAAC,OAAO,EAA0C,8CAA2C;AAEpG,OAAO,EACL,WAAW,EAGZ,wDAAqD;AAEtD,OAAO,EACL,YAAY,EAGb,0DAAuD"}
|
|
@@ -88,11 +88,10 @@ class ShaderAssembler {
|
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Register a shader hook
|
|
91
|
-
* @param hook
|
|
92
|
-
* @param options Optional hook metadata such as always-on header and footer source.
|
|
91
|
+
* @param hook Shared stage and name with language-specific parameters, return type, and source.
|
|
93
92
|
*/
|
|
94
|
-
addShaderHook(hook
|
|
95
|
-
this._hookFunctions.push(
|
|
93
|
+
addShaderHook(hook) {
|
|
94
|
+
this._hookFunctions.push(hook);
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
97
|
* Remove all registered shader hooks, for example before re-registering hooks for a new
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ShaderModule } from "./shader-module/shader-module.js";
|
|
2
2
|
import type { AssembleShaderProps } from "./shader-assembly/shader-assembly-types.js";
|
|
3
|
-
import type { ShaderHook
|
|
3
|
+
import type { ShaderHook } from "./shader-assembly/shader-hooks.js";
|
|
4
4
|
import type { ShaderTranspiler, ShaderTranspileResult } from "./shader-transpiler/shader-transpiler.js";
|
|
5
5
|
/**
|
|
6
6
|
* A stateful version of `assembleShaders` that can be used to assemble shaders.
|
|
@@ -12,7 +12,7 @@ export declare abstract class ShaderAssembler {
|
|
|
12
12
|
/** Compilers registered by the application, isolated to this assembler. */
|
|
13
13
|
private readonly _shaderTranspilers;
|
|
14
14
|
/** Hook functions */
|
|
15
|
-
protected readonly _hookFunctions:
|
|
15
|
+
protected readonly _hookFunctions: ShaderHook[];
|
|
16
16
|
/** Shader modules */
|
|
17
17
|
protected _defaultModules: ShaderModule[];
|
|
18
18
|
/** Register or replace the compiler for one input language. */
|
|
@@ -35,10 +35,9 @@ export declare abstract class ShaderAssembler {
|
|
|
35
35
|
removeDefaultModule(module: ShaderModule): void;
|
|
36
36
|
/**
|
|
37
37
|
* Register a shader hook
|
|
38
|
-
* @param hook
|
|
39
|
-
* @param options Optional hook metadata such as always-on header and footer source.
|
|
38
|
+
* @param hook Shared stage and name with language-specific parameters, return type, and source.
|
|
40
39
|
*/
|
|
41
|
-
addShaderHook(hook:
|
|
40
|
+
addShaderHook(hook: ShaderHook): void;
|
|
42
41
|
/**
|
|
43
42
|
* Remove all registered shader hooks, for example before re-registering hooks for a new
|
|
44
43
|
* application configuration. Default modules are not affected.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-assembler-base.d.ts","sourceRoot":"","sources":["../../src/lib/shader-assembler-base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,yCAAsC;AAEhE,OAAO,KAAK,EAAC,mBAAmB,EAAC,mDAAgD;AACjF,OAAO,KAAK,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"shader-assembler-base.d.ts","sourceRoot":"","sources":["../../src/lib/shader-assembler-base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,yCAAsC;AAEhE,OAAO,KAAK,EAAC,mBAAmB,EAAC,mDAAgD;AACjF,OAAO,KAAK,EAAC,UAAU,EAAC,0CAAuC;AA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optional hook metadata such as always-on header and footer source.
|
|
89
|
+
* @param hook Shared stage and name with language-specific parameters, return type, and source.
|
|
91
90
|
*/
|
|
92
|
-
addShaderHook(hook
|
|
93
|
-
this._hookFunctions.push(
|
|
91
|
+
addShaderHook(hook) {
|
|
92
|
+
this._hookFunctions.push(hook);
|
|
94
93
|
}
|
|
95
94
|
/**
|
|
96
95
|
* Remove all registered shader hooks, for example before re-registering hooks for a new
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-assembler-base.js","sourceRoot":"","sources":["../../src/lib/shader-assembler-base.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,uBAAuB,EAAC,yCAAsC;AAGtE,OAAO,EAAC,MAAM,EAAC,0BAAuB;AAMtC,OAAO,EAAC,2BAA2B,EAAC,sDAAmD;AAEvF;;;GAGG;AACH,MAAM,OAAgB,eAAe;IAGnC,2EAA2E;IAC1D,kBAAkB,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC1E,qBAAqB;IACF,cAAc,
|
|
1
|
+
{"version":3,"file":"shader-assembler-base.js","sourceRoot":"","sources":["../../src/lib/shader-assembler-base.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,uBAAuB,EAAC,yCAAsC;AAGtE,OAAO,EAAC,MAAM,EAAC,0BAAuB;AAMtC,OAAO,EAAC,2BAA2B,EAAC,sDAAmD;AAEvF;;;GAGG;AACH,MAAM,OAAgB,eAAe;IAGnC,2EAA2E;IAC1D,kBAAkB,GAAG,IAAI,GAAG,EAA4B,CAAC;IAC1E,qBAAqB;IACF,cAAc,GAAiB,EAAE,CAAC;IACrD,qBAAqB;IACX,eAAe,GAAmB,EAAE,CAAC;IAE/C,+DAA+D;IAC/D,mBAAmB,CAAC,UAA4B;QAC9C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,cAAc,EAA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C,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;YACtD,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAEvB,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -61,7 +61,6 @@ function assembleGLSLShaderPair(options) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
function assembleShaderGLSL(platformInfo, options) {
|
|
64
|
-
var _a;
|
|
65
64
|
const { source, stage, language = "glsl", modules, defines = {}, hookFunctions = [], inject = {}, pluginInjections = {}, pluginVertexInputs = {}, pluginInterStageVariables = {}, prologue = true, log } = options;
|
|
66
65
|
(0, import_assert.assert)(typeof source === "string", "shader source must be a string");
|
|
67
66
|
const sourceVersion = language === "glsl" ? (0, import_get_shader_info.getShaderInfo)(source).version : -1;
|
|
@@ -95,13 +94,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
95
94
|
`;
|
|
96
95
|
break;
|
|
97
96
|
}
|
|
98
|
-
const hookFunctionMap = (0, import_shader_hooks.normalizeShaderHooks)(hookFunctions);
|
|
97
|
+
const hookFunctionMap = (0, import_shader_hooks.normalizeShaderHooks)(hookFunctions, options.pluginHooks, "glsl");
|
|
99
98
|
const hookInjections = {};
|
|
100
99
|
const declInjections = {};
|
|
101
100
|
const mainInjections = {};
|
|
102
101
|
(0, import_shader_assembly_shared.appendInjections)(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const applicationInjections = Array.isArray(inject) ? (0, import_shader_injections.resolveShaderInjections)(inject, "glsl") : {};
|
|
103
|
+
(0, import_shader_assembly_shared.appendInjections)(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
104
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
105
|
+
for (const key in injectionMap) {
|
|
106
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
105
107
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
106
108
|
if (match) {
|
|
107
109
|
const hash = match[2];
|
|
@@ -143,19 +145,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
143
145
|
}
|
|
144
146
|
const moduleSource = (0, import_shader_assembly_shared.getShaderModuleSource)(module2, stage, log);
|
|
145
147
|
assembledSource += moduleSource;
|
|
146
|
-
const injections = ((_a = module2.instance) == null ? void 0 : _a.normalizedInjections[stage]) || {};
|
|
147
|
-
for (const key in injections) {
|
|
148
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
149
|
-
if (match) {
|
|
150
|
-
const name = match[2];
|
|
151
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
152
|
-
injectionType[key] = injectionType[key] || [];
|
|
153
|
-
injectionType[key].push(injections[key]);
|
|
154
|
-
} else {
|
|
155
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
156
|
-
hookInjections[key].push(injections[key]);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
148
|
}
|
|
160
149
|
(0, import_shader_hooks.validateShaderHookInjections)(hookFunctionMap, hookInjections, stage);
|
|
161
150
|
assembledSource += "// ----- MAIN SHADER SOURCE -------------------------";
|
|
@@ -2,7 +2,7 @@ import { type AssembleShaderOptions, type GetUniformsFunc, type ShaderAssemblyLo
|
|
|
2
2
|
import { PlatformInfo } from "./platform-info.js";
|
|
3
3
|
import { type ShaderModule } from "../shader-module/shader-module.js";
|
|
4
4
|
import { type ShaderHook } from "./shader-hooks.js";
|
|
5
|
-
import { type ShaderInjection } from "./shader-injections.js";
|
|
5
|
+
import { type ShaderInjection, type ResolvedShaderInjection } from "./shader-injections.js";
|
|
6
6
|
import { type AttributeShaderType } from "../../types.js";
|
|
7
7
|
import { type ResolvedShaderPluginInterStageVariable } from "../shader-plugin.js";
|
|
8
8
|
/**
|
|
@@ -37,9 +37,10 @@ export declare function assembleShaderGLSL(platformInfo: PlatformInfo, options:
|
|
|
37
37
|
stage: 'vertex' | 'fragment';
|
|
38
38
|
modules: ShaderModule[];
|
|
39
39
|
defines?: Record<string, boolean | number>;
|
|
40
|
-
hookFunctions?: readonly
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
hookFunctions?: readonly ShaderHook[];
|
|
41
|
+
pluginHooks?: readonly ShaderHook[];
|
|
42
|
+
inject?: readonly ShaderInjection[] | Record<string, string | ResolvedShaderInjection>;
|
|
43
|
+
pluginInjections?: Record<string, ResolvedShaderInjection[]>;
|
|
43
44
|
pluginVertexInputs?: Record<string, AttributeShaderType>;
|
|
44
45
|
pluginInterStageVariables?: Record<string, ResolvedShaderPluginInterStageVariable>;
|
|
45
46
|
prologue?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble-glsl-shaders.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-glsl-shaders.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,mCAAgC;AAOjC,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,KAAK,YAAY,EAAgC,0CAAuC;AAChG,OAAO,EACL,KAAK,UAAU,EAIhB,0BAAuB;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"assemble-glsl-shaders.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-glsl-shaders.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KA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AAC,CAAC;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC7D,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACzD,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sCAAsC,CAAC,CAAC;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB,UAgKF;AAED;;;;;;;;;;;;;;;;;;EAkBE;AAEF,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAM,GAAG,MAAM,CAS5F"}
|
|
@@ -5,7 +5,7 @@ import { getShaderModuleDependencies } from "../shader-module/shader-module-depe
|
|
|
5
5
|
import { assembleGetUniforms, appendInjections, getShaderModuleSource, INJECT_SHADER_DECLARATIONS } from "./shader-assembly-shared.js";
|
|
6
6
|
import { checkShaderModuleDeprecations } from "../shader-module/shader-module.js";
|
|
7
7
|
import { normalizeShaderHooks, validateShaderHookInjections, getShaderHooks } from "./shader-hooks.js";
|
|
8
|
-
import { injectShader } from "./shader-injections.js";
|
|
8
|
+
import { injectShader, resolveShaderInjections } from "./shader-injections.js";
|
|
9
9
|
import { assert } from "../utils/assert.js";
|
|
10
10
|
import { getShaderInfo } from "../glsl-utils/get-shader-info.js";
|
|
11
11
|
import { getPlatformShaderDefines } from "./platform-defines.js";
|
|
@@ -92,14 +92,23 @@ ${getApplicationDefines(allDefines)}
|
|
|
92
92
|
`;
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
95
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, 'glsl');
|
|
96
96
|
// Add source of dependent modules in resolved order
|
|
97
97
|
const hookInjections = {};
|
|
98
98
|
const declInjections = {};
|
|
99
99
|
const mainInjections = {};
|
|
100
100
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const applicationInjections = Array.isArray(inject)
|
|
102
|
+
? resolveShaderInjections(inject, 'glsl')
|
|
103
|
+
: {};
|
|
104
|
+
appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
105
|
+
const injectionMap = Array.isArray(inject)
|
|
106
|
+
? {}
|
|
107
|
+
: inject;
|
|
108
|
+
for (const key in injectionMap) {
|
|
109
|
+
const injection = typeof injectionMap[key] === 'string'
|
|
110
|
+
? { injection: injectionMap[key], order: 0 }
|
|
111
|
+
: injectionMap[key];
|
|
103
112
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
104
113
|
if (match) {
|
|
105
114
|
const hash = match[2];
|
|
@@ -146,22 +155,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
146
155
|
const moduleSource = getShaderModuleSource(module, stage, log);
|
|
147
156
|
// Add the module source, and a #define that declares it presence
|
|
148
157
|
assembledSource += moduleSource;
|
|
149
|
-
const injections = module.instance?.normalizedInjections[stage] || {};
|
|
150
|
-
for (const key in injections) {
|
|
151
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
152
|
-
if (match) {
|
|
153
|
-
const name = match[2];
|
|
154
|
-
const injectionType = name === 'decl' ? declInjections : mainInjections;
|
|
155
|
-
injectionType[key] = injectionType[key] || [];
|
|
156
|
-
injectionType[key].push(injections[key]);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
160
|
-
hookInjections[key].push(injections[key]);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
158
|
}
|
|
164
|
-
//
|
|
159
|
+
// Named hook injections must target a registered hook.
|
|
165
160
|
validateShaderHookInjections(hookFunctionMap, hookInjections, stage);
|
|
166
161
|
assembledSource += '// ----- MAIN SHADER SOURCE -------------------------';
|
|
167
162
|
// For injectShader
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble-glsl-shaders.js","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-glsl-shaders.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,2BAA2B,EAAC,uDAAoD;AAMxF,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC3B,oCAAiC;AAElC,OAAO,EAAoB,6BAA6B,EAAC,0CAAuC;AAChG,OAAO,EAEL,oBAAoB,EACpB,4BAA4B,EAC5B,cAAc,EACf,0BAAuB;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"assemble-glsl-shaders.js","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-glsl-shaders.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,2BAA2B,EAAC,uDAAoD;AAMxF,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC3B,oCAAiC;AAElC,OAAO,EAAoB,6BAA6B,EAAC,0CAAuC;AAChG,OAAO,EAEL,oBAAoB,EACpB,4BAA4B,EAC5B,cAAc,EACf,0BAAuB;AACxB,OAAO,EAGL,YAAY,EACZ,uBAAuB,EACxB,+BAA4B;AAG7B,OAAO,EAAC,MAAM,EAAC,2BAAwB;AACvC,OAAO,EAAC,aAAa,EAAC,yCAAsC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,8BAA2B;AAC5D,OAAO,EAAC,0CAA0C,EAAC,yCAAsC;AACzF,OAAO,EAAC,2CAA2C,EAAC,oCAAiC;AACrF,OAAO,EAAC,mBAAmB,EAAC,sDAAmD;AAC/E,OAAO,EAAC,mCAAmC,EAAC,yDAAsD;AAElG;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;;CAElD,C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IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -32,7 +32,6 @@ __export(assemble_wgsl_shaders_exports, {
|
|
|
32
32
|
getBindingRegistryKey: () => getBindingRegistryKey,
|
|
33
33
|
getUsedBindingsByGroupFromApplicationWGSL: () => getUsedBindingsByGroupFromApplicationWGSL,
|
|
34
34
|
getWGSLDeclarationInjections: () => getWGSLDeclarationInjections,
|
|
35
|
-
getWGSLModuleInjections: () => getWGSLModuleInjections,
|
|
36
35
|
getWGSLModuleNameAtIndex: () => getWGSLModuleNameAtIndex,
|
|
37
36
|
getWGSLShaderHooks: () => getWGSLShaderHooks,
|
|
38
37
|
isInApplicationWGSLSection: () => isInApplicationWGSLSection,
|
|
@@ -107,13 +106,16 @@ function assembleShaderWGSL(platformInfo, options) {
|
|
|
107
106
|
const pluginVaryingAssembly = (0, import_shader_plugin_varyings.assembleShaderPluginInterStageVariablesWGSL)(pluginVertexInputAssembly.source, vertexEntryPoint, fragmentEntryPoint, pluginInterStageVariables);
|
|
108
107
|
const coreSource = pluginVaryingAssembly.source;
|
|
109
108
|
let assembledSource = "";
|
|
110
|
-
const hookFunctionMap = (0, import_shader_hooks.normalizeShaderHooks)(hookFunctions);
|
|
109
|
+
const hookFunctionMap = (0, import_shader_hooks.normalizeShaderHooks)(hookFunctions, options.pluginHooks, "wgsl");
|
|
111
110
|
const hookInjections = {};
|
|
112
111
|
const declInjections = {};
|
|
113
112
|
const mainInjections = {};
|
|
114
113
|
(0, import_shader_assembly_shared.appendInjections)(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const applicationInjections = Array.isArray(inject) ? (0, import_shader_injections.resolveShaderInjections)(inject, "wgsl") : {};
|
|
115
|
+
(0, import_shader_assembly_shared.appendInjections)(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
116
|
+
const injectionMap = Array.isArray(inject) ? {} : inject;
|
|
117
|
+
for (const key in injectionMap) {
|
|
118
|
+
const injection = typeof injectionMap[key] === "string" ? { injection: injectionMap[key], order: 0 } : injectionMap[key];
|
|
117
119
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
118
120
|
if (match) {
|
|
119
121
|
const hash = match[2];
|
|
@@ -156,19 +158,6 @@ function assembleShaderWGSL(platformInfo, options) {
|
|
|
156
158
|
(0, import_shader_module.checkShaderModuleDeprecations)(module2, coreSource, log);
|
|
157
159
|
}
|
|
158
160
|
assembledSource += moduleSource;
|
|
159
|
-
const injections = getWGSLModuleInjections(module2);
|
|
160
|
-
for (const key in injections) {
|
|
161
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
162
|
-
if (match) {
|
|
163
|
-
const name = match[2];
|
|
164
|
-
const injectionType = name === "decl" ? declInjections : mainInjections;
|
|
165
|
-
injectionType[key] = injectionType[key] || [];
|
|
166
|
-
injectionType[key].push(injections[key]);
|
|
167
|
-
} else if ((0, import_shader_hooks.isShaderHookRegistered)(hookFunctionMap, key)) {
|
|
168
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
169
|
-
hookInjections[key].push(injections[key]);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
161
|
}
|
|
173
162
|
assembledSource += import_shader_assembly_shared.INJECT_SHADER_DECLARATIONS;
|
|
174
163
|
assembledSource = (0, import_shader_injections.injectShader)(assembledSource, stage, getWGSLDeclarationInjections(declInjections), false, "wgsl", { vertex: vertexEntryPoint, fragment: fragmentEntryPoint });
|
|
@@ -221,13 +210,6 @@ function appendGeneratedVaryingInjections(assembly, declarationInjections, mainI
|
|
|
221
210
|
});
|
|
222
211
|
}
|
|
223
212
|
}
|
|
224
|
-
function getWGSLModuleInjections(module2) {
|
|
225
|
-
var _a, _b;
|
|
226
|
-
return {
|
|
227
|
-
...((_a = module2.instance) == null ? void 0 : _a.normalizedInjections.vertex) || {},
|
|
228
|
-
...((_b = module2.instance) == null ? void 0 : _b.normalizedInjections.fragment) || {}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
213
|
function getWGSLDeclarationInjections(declarationInjections) {
|
|
232
214
|
const unifiedDeclarations = [
|
|
233
215
|
...declarationInjections["vs:#decl"] || [],
|
|
@@ -486,7 +468,6 @@ function formatWGSLSourceSnippet(source) {
|
|
|
486
468
|
getBindingRegistryKey,
|
|
487
469
|
getUsedBindingsByGroupFromApplicationWGSL,
|
|
488
470
|
getWGSLDeclarationInjections,
|
|
489
|
-
getWGSLModuleInjections,
|
|
490
471
|
getWGSLModuleNameAtIndex,
|
|
491
472
|
getWGSLShaderHooks,
|
|
492
473
|
isInApplicationWGSLSection,
|
|
@@ -3,7 +3,7 @@ import { type ShaderLayout } from "../../types.js";
|
|
|
3
3
|
import { type AssembleWGSLShaderOptions, type GetUniformsFunc, type WGSLBindingAssignment, type AssembleStageOptions, type WGSLApplicationRelocationState, type BindingRelocationContext, type WGSLRelocationParams } from "./shader-assembly-types.js";
|
|
4
4
|
import { PlatformInfo } from "./platform-info.js";
|
|
5
5
|
import { normalizeShaderHooks } from "./shader-hooks.js";
|
|
6
|
-
import { type
|
|
6
|
+
import { type ResolvedShaderInjection } from "./shader-injections.js";
|
|
7
7
|
import { type ShaderModule } from "../shader-module/shader-module.js";
|
|
8
8
|
import { type WGSLBindingDeclarationMatch } from "./wgsl-binding-scan.js";
|
|
9
9
|
export declare const RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT = 100;
|
|
@@ -32,15 +32,14 @@ export declare function assembleShaderWGSL(platformInfo: PlatformInfo, options:
|
|
|
32
32
|
source: string;
|
|
33
33
|
bindingAssignments: WGSLBindingAssignment[];
|
|
34
34
|
};
|
|
35
|
-
export declare function appendGeneratedVertexInputInjections(declarations: string, initialization: string, declarationInjections: Record<string,
|
|
35
|
+
export declare function appendGeneratedVertexInputInjections(declarations: string, initialization: string, declarationInjections: Record<string, ResolvedShaderInjection[]>, mainInjections: Record<string, ResolvedShaderInjection[]>): void;
|
|
36
36
|
export declare function appendGeneratedVaryingInjections(assembly: {
|
|
37
37
|
declarations: string;
|
|
38
38
|
vertexInitialization: string;
|
|
39
39
|
fragmentInitialization: string;
|
|
40
|
-
}, declarationInjections: Record<string,
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function getWGSLShaderHooks(hookFunctionMap: ReturnType<typeof normalizeShaderHooks>, hookInjections: Record<string, ShaderInjection[]>): string;
|
|
40
|
+
}, declarationInjections: Record<string, ResolvedShaderInjection[]>, mainInjections: Record<string, ResolvedShaderInjection[]>): void;
|
|
41
|
+
export declare function getWGSLDeclarationInjections(declarationInjections: Record<string, ResolvedShaderInjection[]>): Record<string, ResolvedShaderInjection[]>;
|
|
42
|
+
export declare function getWGSLShaderHooks(hookFunctionMap: ReturnType<typeof normalizeShaderHooks>, hookInjections: Record<string, ResolvedShaderInjection[]>): string;
|
|
44
43
|
export declare function getUsedBindingsByGroupFromApplicationWGSL(source: string): Map<number, Set<number>>;
|
|
45
44
|
export declare function relocateWGSLApplicationBindings(source: string): {
|
|
46
45
|
source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble-wgsl-shaders.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-wgsl-shaders.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,qBAAqB,EAAoC,gCAA6B;AACnG,OAAO,EAAC,KAAK,YAAY,EAAC,uBAAoB;AAE9C,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAC1B,mCAAgC;AAQjC,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAK7C,OAAO,
|
|
1
|
+
{"version":3,"file":"assemble-wgsl-shaders.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembly/assemble-wgsl-shaders.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,qBAAqB,EAAoC,gC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AC7C,UAAU,EAAE,MAAM,EAClB,wBAAwB,CAAC,EAAE,MAAM,EACjC,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,CA8BR;AAED,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,MAAM,EACb,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5C,MAAM,CASR;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAyBnE;AAED,wBAAgB,mCAAmC,CACjD,kBAAkB,EAAE,qBAAqB,EAAE,GAC1C,MAAM,CAWR;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAY1F;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGjF;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -9,8 +9,8 @@ import { assert } from "../utils/assert.js";
|
|
|
9
9
|
import { preprocess } from "../preprocessor/preprocessor.js";
|
|
10
10
|
import { assembleShaderPluginVertexInputsWGSL } from "./shader-plugin-vertex-inputs.js";
|
|
11
11
|
import { assembleShaderPluginInterStageVariablesWGSL } from "./shader-plugin-varyings.js";
|
|
12
|
-
import { normalizeShaderHooks, validateShaderHookInjections,
|
|
13
|
-
import { injectShader } from "./shader-injections.js";
|
|
12
|
+
import { normalizeShaderHooks, validateShaderHookInjections, getShaderHooks } from "./shader-hooks.js";
|
|
13
|
+
import { injectShader, resolveShaderInjections } from "./shader-injections.js";
|
|
14
14
|
import { checkShaderModuleDeprecations } from "../shader-module/shader-module.js";
|
|
15
15
|
import { getWGSLBindingDeclarationMatches, WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES, WGSL_BINDING_DECLARATION_REGEXES, replaceWGSLBindingDeclarationMatches, hasWGSLAutoBinding, MODULE_WGSL_BINDING_DECLARATION_REGEXES, getFirstWGSLAutoBindingDeclarationMatch } from "./wgsl-binding-scan.js";
|
|
16
16
|
export const RESERVED_APPLICATION_GROUP_0_BINDING_LIMIT = 100;
|
|
@@ -80,14 +80,23 @@ export function assembleShaderWGSL(platformInfo, options) {
|
|
|
80
80
|
// ${isVertex ? '' : FRAGMENT_SHADER_PROLOGUE}
|
|
81
81
|
// `
|
|
82
82
|
// `;
|
|
83
|
-
const hookFunctionMap = normalizeShaderHooks(hookFunctions);
|
|
83
|
+
const hookFunctionMap = normalizeShaderHooks(hookFunctions, options.pluginHooks, 'wgsl');
|
|
84
84
|
// Add source of dependent modules in resolved order
|
|
85
85
|
const hookInjections = {};
|
|
86
86
|
const declInjections = {};
|
|
87
87
|
const mainInjections = {};
|
|
88
88
|
appendInjections(pluginInjections, hookInjections, declInjections, mainInjections);
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const applicationInjections = Array.isArray(inject)
|
|
90
|
+
? resolveShaderInjections(inject, 'wgsl')
|
|
91
|
+
: {};
|
|
92
|
+
appendInjections(applicationInjections, hookInjections, declInjections, mainInjections);
|
|
93
|
+
const injectionMap = Array.isArray(inject)
|
|
94
|
+
? {}
|
|
95
|
+
: inject;
|
|
96
|
+
for (const key in injectionMap) {
|
|
97
|
+
const injection = typeof injectionMap[key] === 'string'
|
|
98
|
+
? { injection: injectionMap[key], order: 0 }
|
|
99
|
+
: injectionMap[key];
|
|
91
100
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
92
101
|
if (match) {
|
|
93
102
|
const hash = match[2];
|
|
@@ -137,22 +146,6 @@ export function assembleShaderWGSL(platformInfo, options) {
|
|
|
137
146
|
checkShaderModuleDeprecations(module, coreSource, log);
|
|
138
147
|
}
|
|
139
148
|
assembledSource += moduleSource;
|
|
140
|
-
const injections = getWGSLModuleInjections(module);
|
|
141
|
-
for (const key in injections) {
|
|
142
|
-
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
143
|
-
if (match) {
|
|
144
|
-
const name = match[2];
|
|
145
|
-
const injectionType = name === 'decl' ? declInjections : mainInjections;
|
|
146
|
-
injectionType[key] = injectionType[key] || [];
|
|
147
|
-
injectionType[key].push(injections[key]);
|
|
148
|
-
}
|
|
149
|
-
else if (isShaderHookRegistered(hookFunctionMap, key)) {
|
|
150
|
-
// `ShaderModule.inject` is not language-specific and often carries GLSL-only hook
|
|
151
|
-
// injections, so WGSL silently skips module injections into hooks it has not declared.
|
|
152
|
-
hookInjections[key] = hookInjections[key] || [];
|
|
153
|
-
hookInjections[key].push(injections[key]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
149
|
}
|
|
157
150
|
// For injectShader
|
|
158
151
|
assembledSource += INJECT_SHADER_DECLARATIONS;
|
|
@@ -208,12 +201,6 @@ export function appendGeneratedVaryingInjections(assembly, declarationInjections
|
|
|
208
201
|
});
|
|
209
202
|
}
|
|
210
203
|
}
|
|
211
|
-
export function getWGSLModuleInjections(module) {
|
|
212
|
-
return {
|
|
213
|
-
...(module.instance?.normalizedInjections.vertex || {}),
|
|
214
|
-
...(module.instance?.normalizedInjections.fragment || {})
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
204
|
export function getWGSLDeclarationInjections(declarationInjections) {
|
|
218
205
|
const unifiedDeclarations = [
|
|
219
206
|
...(declarationInjections['vs:#decl'] || []),
|