@luma.gl/shadertools 9.3.6 → 9.4.0-alpha.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/dist/dist.dev.js +6555 -2373
- package/dist/dist.min.js +2984 -237
- package/dist/index.cjs +4356 -268
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/preprocessor/preprocessor.d.ts +11 -1
- package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -1
- package/dist/lib/preprocessor/preprocessor.js +47 -2
- package/dist/lib/preprocessor/preprocessor.js.map +1 -1
- package/dist/lib/shader-assembler.d.ts +10 -10
- package/dist/lib/shader-assembler.d.ts.map +1 -1
- package/dist/lib/shader-assembler.js +36 -20
- package/dist/lib/shader-assembler.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.d.ts +28 -7
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.js +133 -15
- package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/platform-info.d.ts +2 -0
- package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.d.ts +1 -1
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-hooks.js +6 -3
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.d.ts +4 -1
- package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -1
- package/dist/lib/shader-assembly/shader-injections.js +68 -11
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -1
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts +15 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.js +412 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.js.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts +12 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js +237 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js.map +1 -0
- package/dist/lib/shader-module/shader-module.d.ts +3 -0
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js.map +1 -1
- package/dist/lib/shader-module/shader-pass-pipeline.d.ts +14 -0
- package/dist/lib/shader-module/shader-pass-pipeline.d.ts.map +1 -0
- package/dist/lib/shader-module/shader-pass-pipeline.js +5 -0
- package/dist/lib/shader-module/shader-pass-pipeline.js.map +1 -0
- package/dist/lib/shader-module/shader-pass.d.ts +21 -4
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/lib/shader-plugin.d.ts +68 -0
- package/dist/lib/shader-plugin.d.ts.map +1 -0
- package/dist/lib/shader-plugin.js +98 -0
- package/dist/lib/shader-plugin.js.map +1 -0
- package/dist/lib/utils/assert.js +1 -1
- package/dist/lib/utils/assert.js.map +1 -1
- package/dist/modules/color/float-colors.d.ts +111 -5
- package/dist/modules/color/float-colors.d.ts.map +1 -1
- package/dist/modules/color/float-colors.js +200 -34
- package/dist/modules/color/float-colors.js.map +1 -1
- package/dist/modules/engine/clip/clip.d.ts +12 -0
- package/dist/modules/engine/clip/clip.d.ts.map +1 -0
- package/dist/modules/engine/clip/clip.js +129 -0
- package/dist/modules/engine/clip/clip.js.map +1 -0
- package/dist/modules/engine/filter/filter.d.ts +12 -0
- package/dist/modules/engine/filter/filter.d.ts.map +1 -0
- package/dist/modules/engine/filter/filter.js +88 -0
- package/dist/modules/engine/filter/filter.js.map +1 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts +3 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts.map +1 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.js +1892 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.js.map +1 -0
- package/dist/modules/geospatial/dggs/dggs.d.ts +6 -0
- package/dist/modules/geospatial/dggs/dggs.d.ts.map +1 -0
- package/dist/modules/geospatial/dggs/dggs.js +10 -0
- package/dist/modules/geospatial/dggs/dggs.js.map +1 -0
- package/dist/modules/lighting/water-material/water-material.d.ts +28 -0
- package/dist/modules/lighting/water-material/water-material.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-material.js +179 -0
- package/dist/modules/lighting/water-material/water-material.js.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts +3 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.js +232 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.js.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts +2 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.js +230 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.js.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -1
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -1
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +268 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +50 -3
- package/src/lib/preprocessor/preprocessor.ts +68 -3
- package/src/lib/shader-assembler.ts +49 -20
- package/src/lib/shader-assembly/assemble-shaders.ts +242 -30
- package/src/lib/shader-assembly/platform-info.ts +2 -0
- package/src/lib/shader-assembly/shader-hooks.ts +7 -3
- package/src/lib/shader-assembly/shader-injections.ts +96 -11
- package/src/lib/shader-assembly/shader-plugin-varyings.ts +524 -0
- package/src/lib/shader-assembly/shader-plugin-vertex-inputs.ts +279 -0
- package/src/lib/shader-module/shader-module.ts +3 -0
- package/src/lib/shader-module/shader-pass-pipeline.ts +19 -0
- package/src/lib/shader-module/shader-pass.ts +29 -4
- package/src/lib/shader-plugin.ts +214 -0
- package/src/lib/utils/assert.ts +1 -1
- package/src/modules/color/float-colors.ts +272 -37
- package/src/modules/engine/clip/clip.ts +149 -0
- package/src/modules/engine/filter/filter.ts +107 -0
- package/src/modules/geospatial/dggs/dggs-wgsl.ts +1892 -0
- package/src/modules/geospatial/dggs/dggs.ts +12 -0
- package/src/modules/lighting/water-material/water-material.ts +234 -0
- package/src/modules/lighting/water-material/water-shaders-glsl.ts +233 -0
- package/src/modules/lighting/water-material/water-shaders-wgsl.ts +230 -0
- package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +268 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { shaderTypeDecoder } from '@luma.gl/core';
|
|
5
|
+
/** Generate GLSL vertex input declarations contributed by shader plugins. */
|
|
6
|
+
export function getShaderPluginVertexInputDeclarationsGLSL(source, vertexInputs) {
|
|
7
|
+
const declarations = [];
|
|
8
|
+
for (const [name, type] of Object.entries(vertexInputs)) {
|
|
9
|
+
assertGLSLVertexInputIsNew(source, name);
|
|
10
|
+
declarations.push(`in ${getGLSLAttributeType(type)} ${name};`);
|
|
11
|
+
}
|
|
12
|
+
return declarations.join('\n');
|
|
13
|
+
}
|
|
14
|
+
/** Add WGSL plugin inputs to the selected vertex entry point. */
|
|
15
|
+
export function assembleShaderPluginVertexInputsWGSL(source, vertexEntryPoint, vertexInputs) {
|
|
16
|
+
const entries = Object.entries(vertexInputs);
|
|
17
|
+
if (entries.length === 0) {
|
|
18
|
+
return { source, declarations: '', initialization: '' };
|
|
19
|
+
}
|
|
20
|
+
const functionRange = getWGSLFunctionParameterRange(source, vertexEntryPoint);
|
|
21
|
+
const parameterSource = source.slice(functionRange.openParenthesis + 1, functionRange.closeParenthesis);
|
|
22
|
+
const interfaceInfo = getWGSLVertexInterfaceInfo(source, parameterSource);
|
|
23
|
+
const usedLocations = new Set(interfaceInfo.locations);
|
|
24
|
+
const generatedParameters = [];
|
|
25
|
+
const declarations = [];
|
|
26
|
+
const initialization = [];
|
|
27
|
+
for (const [name, type] of entries) {
|
|
28
|
+
if (interfaceInfo.names.has(name) || hasWGSLModuleVariable(source, name)) {
|
|
29
|
+
throw new Error(`ShaderPlugin vertex input "${name}" conflicts with an existing WGSL shader input or variable`);
|
|
30
|
+
}
|
|
31
|
+
const location = getFirstUnusedLocation(usedLocations);
|
|
32
|
+
usedLocations.add(location);
|
|
33
|
+
const parameterName = `_luma_${name}`;
|
|
34
|
+
generatedParameters.push(`@location(${location}) ${parameterName}: ${type}`);
|
|
35
|
+
declarations.push(`var<private> ${name}: ${type};`);
|
|
36
|
+
initialization.push(`${name} = ${parameterName};`);
|
|
37
|
+
}
|
|
38
|
+
const separator = parameterSource.trim() ? ',\n ' : '\n ';
|
|
39
|
+
const suffix = parameterSource.trim() ? '' : '\n';
|
|
40
|
+
const injectedParameters = `${parameterSource}${separator}${generatedParameters.join(',\n ')}${suffix}`;
|
|
41
|
+
const transformedSource = source.slice(0, functionRange.openParenthesis + 1) +
|
|
42
|
+
injectedParameters +
|
|
43
|
+
source.slice(functionRange.closeParenthesis);
|
|
44
|
+
return {
|
|
45
|
+
source: transformedSource,
|
|
46
|
+
declarations: declarations.join('\n'),
|
|
47
|
+
initialization: initialization.join('\n')
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function getGLSLAttributeType(type) {
|
|
51
|
+
const { primitiveType, components } = shaderTypeDecoder.getAttributeShaderTypeInfo(type);
|
|
52
|
+
const scalarType = primitiveType === 'i32' ? 'int' : primitiveType === 'u32' ? 'uint' : 'float';
|
|
53
|
+
if (components === 1) {
|
|
54
|
+
return scalarType;
|
|
55
|
+
}
|
|
56
|
+
const prefix = scalarType === 'int' ? 'i' : scalarType === 'uint' ? 'u' : '';
|
|
57
|
+
return `${prefix}vec${components}`;
|
|
58
|
+
}
|
|
59
|
+
function assertGLSLVertexInputIsNew(source, name) {
|
|
60
|
+
const escapedName = escapeRegExp(name);
|
|
61
|
+
const declaration = new RegExp(`\\b(?:in|attribute)\\s+(?:(?:lowp|mediump|highp)\\s+)?[A-Za-z_][A-Za-z0-9_]*\\s+${escapedName}\\s*(?:\\[|;)`);
|
|
62
|
+
if (declaration.test(source)) {
|
|
63
|
+
throw new Error(`ShaderPlugin vertex input "${name}" conflicts with an existing GLSL input`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getWGSLFunctionParameterRange(source, entryPoint) {
|
|
67
|
+
const functionPattern = new RegExp(`\\bfn\\s+${escapeRegExp(entryPoint)}\\s*\\(`, 'g');
|
|
68
|
+
const match = functionPattern.exec(source);
|
|
69
|
+
if (!match) {
|
|
70
|
+
throw new Error(`ShaderPlugin vertex inputs require WGSL vertex entry point "${entryPoint}"`);
|
|
71
|
+
}
|
|
72
|
+
const openParenthesis = source.indexOf('(', match.index);
|
|
73
|
+
const closeParenthesis = findMatchingDelimiter(source, openParenthesis, '(', ')');
|
|
74
|
+
if (closeParenthesis < 0) {
|
|
75
|
+
throw new Error(`Unable to parse WGSL vertex entry point "${entryPoint}" parameters`);
|
|
76
|
+
}
|
|
77
|
+
return { openParenthesis, closeParenthesis };
|
|
78
|
+
}
|
|
79
|
+
function getWGSLVertexInterfaceInfo(source, parameterSource) {
|
|
80
|
+
const locations = getWGSLLocations(parameterSource);
|
|
81
|
+
const names = new Set(getWGSLDeclaredNames(parameterSource));
|
|
82
|
+
const parameterTypes = getWGSLParameterTypes(parameterSource);
|
|
83
|
+
for (const parameterType of parameterTypes) {
|
|
84
|
+
const structBody = getWGSLStructBody(source, parameterType);
|
|
85
|
+
if (structBody === null) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
locations.push(...getWGSLLocations(structBody));
|
|
89
|
+
for (const name of getWGSLDeclaredNames(structBody)) {
|
|
90
|
+
names.add(name);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { locations, names };
|
|
94
|
+
}
|
|
95
|
+
function getWGSLLocations(source) {
|
|
96
|
+
const locations = [];
|
|
97
|
+
const locationPattern = /@location\s*\(\s*(\d+)\s*\)/g;
|
|
98
|
+
let match = locationPattern.exec(source);
|
|
99
|
+
while (match) {
|
|
100
|
+
locations.push(Number(match[1]));
|
|
101
|
+
match = locationPattern.exec(source);
|
|
102
|
+
}
|
|
103
|
+
return locations;
|
|
104
|
+
}
|
|
105
|
+
function getWGSLDeclaredNames(source) {
|
|
106
|
+
const names = [];
|
|
107
|
+
const namePattern = /(?:^|,)\s*(?:@[A-Za-z_][\w]*(?:\([^)]*\))?\s*)*([A-Za-z_][\w]*)\s*:/gm;
|
|
108
|
+
let match = namePattern.exec(source);
|
|
109
|
+
while (match) {
|
|
110
|
+
names.push(match[1]);
|
|
111
|
+
match = namePattern.exec(source);
|
|
112
|
+
}
|
|
113
|
+
return names;
|
|
114
|
+
}
|
|
115
|
+
function getWGSLParameterTypes(source) {
|
|
116
|
+
const types = [];
|
|
117
|
+
const typePattern = /:\s*([A-Za-z_][\w]*)\b/g;
|
|
118
|
+
let match = typePattern.exec(source);
|
|
119
|
+
while (match) {
|
|
120
|
+
types.push(match[1]);
|
|
121
|
+
match = typePattern.exec(source);
|
|
122
|
+
}
|
|
123
|
+
return types;
|
|
124
|
+
}
|
|
125
|
+
function getWGSLStructBody(source, structName) {
|
|
126
|
+
const structPattern = new RegExp(`\\bstruct\\s+${escapeRegExp(structName)}\\s*\\{`, 'g');
|
|
127
|
+
const match = structPattern.exec(source);
|
|
128
|
+
if (!match) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const openBrace = source.indexOf('{', match.index);
|
|
132
|
+
const closeBrace = findMatchingDelimiter(source, openBrace, '{', '}');
|
|
133
|
+
return closeBrace < 0 ? null : source.slice(openBrace + 1, closeBrace);
|
|
134
|
+
}
|
|
135
|
+
function hasWGSLModuleVariable(source, name) {
|
|
136
|
+
const escapedName = escapeRegExp(name);
|
|
137
|
+
const variablePattern = new RegExp(`\\b(?:var(?:<[^>]+>)?|let|const)\\s+${escapedName}\\b`, 'g');
|
|
138
|
+
let match = variablePattern.exec(source);
|
|
139
|
+
while (match) {
|
|
140
|
+
if (getBraceDepthAt(source, match.index) === 0) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
match = variablePattern.exec(source);
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
function getFirstUnusedLocation(usedLocations) {
|
|
148
|
+
let location = 0;
|
|
149
|
+
while (usedLocations.has(location)) {
|
|
150
|
+
location++;
|
|
151
|
+
}
|
|
152
|
+
return location;
|
|
153
|
+
}
|
|
154
|
+
function findMatchingDelimiter(source, openIndex, openCharacter, closeCharacter) {
|
|
155
|
+
let depth = 0;
|
|
156
|
+
let blockCommentDepth = 0;
|
|
157
|
+
let lineComment = false;
|
|
158
|
+
for (let index = openIndex; index < source.length; index++) {
|
|
159
|
+
const character = source[index];
|
|
160
|
+
const nextCharacter = source[index + 1];
|
|
161
|
+
if (lineComment) {
|
|
162
|
+
if (character === '\n')
|
|
163
|
+
lineComment = false;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (blockCommentDepth > 0) {
|
|
167
|
+
if (character === '/' && nextCharacter === '*') {
|
|
168
|
+
blockCommentDepth++;
|
|
169
|
+
index++;
|
|
170
|
+
}
|
|
171
|
+
else if (character === '*' && nextCharacter === '/') {
|
|
172
|
+
blockCommentDepth--;
|
|
173
|
+
index++;
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (character === '/' && nextCharacter === '/') {
|
|
178
|
+
lineComment = true;
|
|
179
|
+
index++;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (character === '/' && nextCharacter === '*') {
|
|
183
|
+
blockCommentDepth = 1;
|
|
184
|
+
index++;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (character === openCharacter)
|
|
188
|
+
depth++;
|
|
189
|
+
if (character === closeCharacter && --depth === 0)
|
|
190
|
+
return index;
|
|
191
|
+
}
|
|
192
|
+
return -1;
|
|
193
|
+
}
|
|
194
|
+
function getBraceDepthAt(source, endIndex) {
|
|
195
|
+
let depth = 0;
|
|
196
|
+
let blockCommentDepth = 0;
|
|
197
|
+
let lineComment = false;
|
|
198
|
+
for (let index = 0; index < endIndex; index++) {
|
|
199
|
+
const character = source[index];
|
|
200
|
+
const nextCharacter = source[index + 1];
|
|
201
|
+
if (lineComment) {
|
|
202
|
+
if (character === '\n')
|
|
203
|
+
lineComment = false;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (blockCommentDepth > 0) {
|
|
207
|
+
if (character === '/' && nextCharacter === '*') {
|
|
208
|
+
blockCommentDepth++;
|
|
209
|
+
index++;
|
|
210
|
+
}
|
|
211
|
+
else if (character === '*' && nextCharacter === '/') {
|
|
212
|
+
blockCommentDepth--;
|
|
213
|
+
index++;
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (character === '/' && nextCharacter === '/') {
|
|
218
|
+
lineComment = true;
|
|
219
|
+
index++;
|
|
220
|
+
}
|
|
221
|
+
else if (character === '/' && nextCharacter === '*') {
|
|
222
|
+
blockCommentDepth = 1;
|
|
223
|
+
index++;
|
|
224
|
+
}
|
|
225
|
+
else if (character === '{') {
|
|
226
|
+
depth++;
|
|
227
|
+
}
|
|
228
|
+
else if (character === '}') {
|
|
229
|
+
depth--;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return depth;
|
|
233
|
+
}
|
|
234
|
+
function escapeRegExp(value) {
|
|
235
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=shader-plugin-vertex-inputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-plugin-vertex-inputs.js","sourceRoot":"","sources":["../../../src/lib/shader-assembly/shader-plugin-vertex-inputs.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,iBAAiB,EAA2B,MAAM,eAAe,CAAC;AAQ1E,6EAA6E;AAC7E,MAAM,UAAU,0CAA0C,CACxD,MAAc,EACd,YAAiD;IAEjD,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,YAAY,CAAC,IAAI,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,oCAAoC,CAClD,MAAc,EACd,gBAAwB,EACxB,YAAiD;IAEjD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAC,CAAC;IACxD,CAAC;IAED,MAAM,aAAa,GAAG,6BAA6B,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAClC,aAAa,CAAC,eAAe,GAAG,CAAC,EACjC,aAAa,CAAC,gBAAgB,CAC/B,CAAC;IACF,MAAM,aAAa,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,SAAS,KAAK,GAAG,IAAI,aAAa,KAAK,GAAG,EAAE,CAAC;YACtD,iBAAiB,GAAG,CAAC,CAAC;YACtB,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YAC7B,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YAC7B,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -9,6 +9,8 @@ export type UniformInfo = {
|
|
|
9
9
|
export type ShaderModuleBindingLayout = {
|
|
10
10
|
name: string;
|
|
11
11
|
group: number;
|
|
12
|
+
/** Which shader stages can access this binding. Uses GPUShaderStage bit flags. */
|
|
13
|
+
visibility?: number;
|
|
12
14
|
};
|
|
13
15
|
type BindingKeys<T> = {
|
|
14
16
|
[K in keyof T]: T[K] extends UniformValue ? never : K;
|
|
@@ -55,6 +57,7 @@ export type ShaderModule<PropsT extends Record<string, any> = Record<string, any
|
|
|
55
57
|
defaultUniforms?: Required<UniformsT>;
|
|
56
58
|
/** Function that maps props to uniforms & bindings */
|
|
57
59
|
getUniforms?: (props: Partial<PropsT>, prevUniforms?: UniformsT) => Partial<UniformsT & BindingsT>;
|
|
60
|
+
/** Boolean or numeric preprocessor defines contributed by this shader module. */
|
|
58
61
|
defines?: Record<string, boolean | number>;
|
|
59
62
|
/** Injections */
|
|
60
63
|
inject?: Record<string, string | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,uBAAoB;AAC1C,OAAO,EACL,QAAQ,EACR,aAAa,EAGd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E,YAAY,EAAE,GAAG,IAAI,CAErE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CA2CjE;AAED,uCAAuC;AACvC,wBAAgB,uBAAuB,CACrC,aAAa,SAAS,YAAY,CAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CACzC,EAED,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,WAAW,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GACtC,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,wBAAwB,CAAC,CAYpD;AAwBD,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,GAAG,GACP,IAAI,CAUN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.js","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAGL,kBAAkB,EAClB,sBAAsB,EACvB,iCAA8B;AAE/B,OAAO,EAAkB,mBAAmB,EAAC,gDAA6C;
|
|
1
|
+
{"version":3,"file":"shader-module.js","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAGL,kBAAkB,EAClB,sBAAsB,EACvB,iCAA8B;AAE/B,OAAO,EAAkB,mBAAmB,EAAC,gDAA6C;AAmG1F,oBAAoB;AAEpB,MAAM,UAAU,uBAAuB,CAAC,OAAuB;IAC7D,OAAO,CAAC,GAAG,CAAC,CAAC,MAAoB,EAAE,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,sBAAsB,CA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,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UniformValue } from "../utils/uniform-types.js";
|
|
2
|
+
import type { ShaderPass, ShaderPassInputSource, ShaderPassRenderTarget } from "./shader-pass.js";
|
|
3
|
+
export type ShaderPassPipelineStep<TargetNameT extends string = string> = {
|
|
4
|
+
shaderPass: ShaderPass<any, any, any, any>;
|
|
5
|
+
inputs?: Record<string, ShaderPassInputSource<TargetNameT>>;
|
|
6
|
+
output?: 'previous' | TargetNameT;
|
|
7
|
+
uniforms?: Record<string, UniformValue>;
|
|
8
|
+
};
|
|
9
|
+
export type ShaderPassPipeline<TargetNameT extends string = string> = {
|
|
10
|
+
name: string;
|
|
11
|
+
renderTargets?: Record<TargetNameT, ShaderPassRenderTarget>;
|
|
12
|
+
steps: ShaderPassPipelineStep<TargetNameT>[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=shader-pass-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-pass-pipeline.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,kCAA+B;AACzD,OAAO,KAAK,EAAC,UAAU,EAAE,qBAAqB,EAAE,sBAAsB,EAAC,yBAAsB;AAE7F,MAAM,MAAM,sBAAsB,CAAC,WAAW,SAAS,MAAM,GAAG,MAAM,IAAI;IACxE,UAAU,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,MAAM,GAAG,MAAM,IAAI;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;IAC5D,KAAK,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-pass-pipeline.js","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass-pipeline.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import type { Binding } from '@luma.gl/core';
|
|
1
|
+
import type { Binding, TextureFormat } from '@luma.gl/core';
|
|
2
2
|
import type { PickBindings, PickUniforms, ShaderModule } from "./shader-module.js";
|
|
3
3
|
import type { UniformValue } from "../utils/uniform-types.js";
|
|
4
|
+
export type ShaderPassRenderTarget = {
|
|
5
|
+
/** Width and height scale relative to the renderer output size. */
|
|
6
|
+
scale?: [number, number];
|
|
7
|
+
/** Render target format. Defaults to the device preferred color format. */
|
|
8
|
+
format?: TextureFormat;
|
|
9
|
+
/** Resource lifetime. History targets retain their last successfully rendered value. */
|
|
10
|
+
lifetime?: 'transient' | 'history';
|
|
11
|
+
/** Initial value used after construction, resize, or an explicit history reset. */
|
|
12
|
+
initialize?: 'original' | {
|
|
13
|
+
clearColor: [number, number, number, number];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type ShaderPassInputSource<TargetNameT extends string = string> = 'original' | 'previous' | TargetNameT;
|
|
4
17
|
/**
|
|
5
18
|
* A ShaderPass is a ShaderModule that can be run "standalone" (e.g. post processing effects)
|
|
6
19
|
* It adds additional information on how to run the module.
|
|
7
20
|
* A ShaderPass can require one or more sub passes.
|
|
8
21
|
*/
|
|
9
|
-
export type ShaderPass<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT
|
|
22
|
+
export type ShaderPass<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT>, RenderTargetNameT extends string = never> = ShaderModule<PropsT, UniformsT, BindingsT> & {
|
|
10
23
|
/** A shader pass can run multiple sub passes */
|
|
11
|
-
passes?: ShaderSubPass<UniformsT>[];
|
|
24
|
+
passes?: ShaderSubPass<UniformsT, Extract<keyof BindingsT, string>, RenderTargetNameT>[];
|
|
12
25
|
};
|
|
13
26
|
/** Information on how to run a specific sub pass */
|
|
14
|
-
export type ShaderSubPass<UniformsT extends Record<string, UniformValue> = Record<string, UniformValue
|
|
27
|
+
export type ShaderSubPass<UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingNameT extends string = string, RenderTargetNameT extends string = string> = {
|
|
15
28
|
/**
|
|
16
29
|
* Action indicates whether this pass:
|
|
17
30
|
* - filters the color in each pixel (provides a `<pass.name>_filterColor()` shader function)
|
|
@@ -21,5 +34,9 @@ export type ShaderSubPass<UniformsT extends Record<string, UniformValue> = Recor
|
|
|
21
34
|
sampler?: boolean;
|
|
22
35
|
filter?: boolean;
|
|
23
36
|
uniforms?: UniformsT;
|
|
37
|
+
/** Mapping from shader binding name to the logical texture source. */
|
|
38
|
+
inputs?: Partial<Record<BindingNameT | 'sourceTexture', ShaderPassInputSource<RenderTargetNameT>>>;
|
|
39
|
+
/** Output target for this sub pass. Defaults to the shared "previous" chain. */
|
|
40
|
+
output?: 'previous' | RenderTargetNameT;
|
|
24
41
|
};
|
|
25
42
|
//# sourceMappingURL=shader-pass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,2BAAwB;AAC9E,OAAO,KAAK,EAAC,YAAY,EAAC,kCAA+B;AAEzD,MAAM,MAAM,sBAAsB,GAAG;IACnC,mEAAmE;IACnE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACnC,mFAAmF;IACnF,UAAU,CAAC,EAAE,UAAU,GAAG;QAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAC,CAAC;CAC1E,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,WAAW,SAAS,MAAM,GAAG,MAAM,IACjE,UAAU,GACV,UAAU,GACV,WAAW,CAAC;AAEhB;;;;GAIG;AACH,MAAM,MAAM,UAAU,CACpB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EACrE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EAChE,iBAAiB,SAAS,MAAM,GAAG,KAAK,IACtC,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG;IAC/C,gDAAgD;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,EAAE,iBAAiB,CAAC,EAAE,CAAC;CAG1F,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,aAAa,CACvB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7E,YAAY,SAAS,MAAM,GAAG,MAAM,EACpC,iBAAiB,SAAS,MAAM,GAAG,MAAM,IACvC;IACF;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CACd,MAAM,CAAC,YAAY,GAAG,eAAe,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CACjF,CAAC;IACF,gFAAgF;IAChF,MAAM,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC;CACzC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ShaderInjection } from "./shader-assembly/shader-injections.js";
|
|
2
|
+
import type { ShaderModule } from "./shader-module/shader-module.js";
|
|
3
|
+
import { type AttributeShaderType } from '@luma.gl/core';
|
|
4
|
+
/** Named shader anchor or hook target accepted by ShaderPlugin injections. */
|
|
5
|
+
export type ShaderPluginInjectionTarget = 'vs:#decl' | 'vs:#main-start' | 'vs:#main-end' | 'fs:#decl' | 'fs:#main-start' | 'fs:#main-end' | `vs:${string}` | `fs:${string}`;
|
|
6
|
+
/** Named shader source injection contributed by a ShaderPlugin. */
|
|
7
|
+
export type ShaderPluginInjection = {
|
|
8
|
+
/** Named shader anchor or hook that receives this source. */
|
|
9
|
+
target: ShaderPluginInjectionTarget;
|
|
10
|
+
/** Shader source to inject at the target. */
|
|
11
|
+
injection: string;
|
|
12
|
+
/** Relative injection order within the target. */
|
|
13
|
+
order?: number;
|
|
14
|
+
};
|
|
15
|
+
/** Portable interpolation modes for ShaderPlugin varyings. */
|
|
16
|
+
export type ShaderPluginVaryingInterpolation = 'smooth' | 'flat';
|
|
17
|
+
/** Cross-stage value contributed by a ShaderPlugin. */
|
|
18
|
+
export type ShaderPluginVarying = {
|
|
19
|
+
/** Portable scalar or vector shader type. */
|
|
20
|
+
type: AttributeShaderType;
|
|
21
|
+
/** Defaults to smooth for floating-point types and flat for integer types. */
|
|
22
|
+
interpolation?: ShaderPluginVaryingInterpolation;
|
|
23
|
+
};
|
|
24
|
+
/** Fully normalized ShaderPlugin varying declaration. */
|
|
25
|
+
export type ResolvedShaderPluginVarying = {
|
|
26
|
+
type: AttributeShaderType;
|
|
27
|
+
interpolation: ShaderPluginVaryingInterpolation;
|
|
28
|
+
};
|
|
29
|
+
/** Shared or backend-specific shader assembly contributions. */
|
|
30
|
+
export type ShaderPluginVariant = {
|
|
31
|
+
/** Shader modules added to shader assembly. */
|
|
32
|
+
modules?: ShaderModule[];
|
|
33
|
+
/** Boolean preprocessor defines added to shader assembly. */
|
|
34
|
+
defines?: Record<string, boolean>;
|
|
35
|
+
/** Named code injections added to shader assembly. */
|
|
36
|
+
injections?: ShaderPluginInjection[];
|
|
37
|
+
/** Shader-facing vertex inputs added by this plugin. Buffer ownership remains with the caller. */
|
|
38
|
+
vertexInputs?: Record<string, AttributeShaderType>;
|
|
39
|
+
/** Values transported from the selected vertex entry point to the fragment entry point. */
|
|
40
|
+
varyings?: Record<string, ShaderPluginVarying>;
|
|
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;
|
|
50
|
+
};
|
|
51
|
+
/** ShaderPlugin contributions resolved for one shader language. */
|
|
52
|
+
export type ResolvedShaderPlugins = {
|
|
53
|
+
/** Resolved shader modules in plugin declaration order. */
|
|
54
|
+
modules: ShaderModule[];
|
|
55
|
+
/** Resolved boolean preprocessor defines. */
|
|
56
|
+
defines: Record<string, boolean>;
|
|
57
|
+
/** Resolved named code injections grouped by target. */
|
|
58
|
+
injections: Record<string, ShaderInjection[]>;
|
|
59
|
+
/** Resolved shader-facing vertex inputs in plugin declaration order. */
|
|
60
|
+
vertexInputs: Record<string, AttributeShaderType>;
|
|
61
|
+
/** Resolved cross-stage varyings in plugin declaration order. */
|
|
62
|
+
varyings: Record<string, ResolvedShaderPluginVarying>;
|
|
63
|
+
};
|
|
64
|
+
/** Resolve shared and backend-specific contributions from shader plugins. */
|
|
65
|
+
export declare function resolveShaderPlugins(plugins: readonly ShaderPlugin[] | undefined, shaderLanguage: 'glsl' | 'wgsl'): ResolvedShaderPlugins;
|
|
66
|
+
/** Preserve explicit module inputs while appending plugin modules by first-seen name. */
|
|
67
|
+
export declare function mergeShaderPluginModules(modules?: readonly ShaderModule[], pluginModules?: readonly ShaderModule[]): ShaderModule[];
|
|
68
|
+
//# sourceMappingURL=shader-plugin.d.ts.map
|
|
@@ -0,0 +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,MAAM,eAAe,CAAC;AAE1E,8EAA8E;AAC9E,MAAM,M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AC;IACb,+CAA+C;IAC/C,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,2DAA2D;IAC3D,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC9C,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAClD,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;CACvD,CAAC;AAKF,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,YAAY,EAAE,YAAK,EACrC,cAAc,EAAE,MAAM,GAAG,MAAM,GAC9B,qBAAqB,CAsBvB;AAED,yFAAyF;AACzF,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,SAAS,YAAY,EAAO,EACrC,aAAa,GAAE,SAAS,YAAY,EAAO,GAC1C,YAAY,EAAE,CAYhB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { shaderTypeDecoder } from '@luma.gl/core';
|
|
5
|
+
const SHADER_PLUGIN_INJECTION_TARGET_REGEX = /^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;
|
|
6
|
+
/** Resolve shared and backend-specific contributions from shader plugins. */
|
|
7
|
+
export function resolveShaderPlugins(plugins = [], shaderLanguage) {
|
|
8
|
+
const modules = [];
|
|
9
|
+
const defines = {};
|
|
10
|
+
const injections = {};
|
|
11
|
+
const vertexInputs = {};
|
|
12
|
+
const varyings = {};
|
|
13
|
+
for (const plugin of plugins) {
|
|
14
|
+
appendShaderPluginVariant({ modules, defines, injections, vertexInputs, varyings }, plugin);
|
|
15
|
+
appendShaderPluginVariant({ modules, defines, injections, vertexInputs, varyings }, plugin[shaderLanguage]);
|
|
16
|
+
}
|
|
17
|
+
for (const name of Object.keys(varyings)) {
|
|
18
|
+
if (vertexInputs[name]) {
|
|
19
|
+
throw new Error(`ShaderPlugin name "${name}" cannot be both a vertex input and a varying`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { modules, defines, injections, vertexInputs, varyings };
|
|
23
|
+
}
|
|
24
|
+
/** Preserve explicit module inputs while appending plugin modules by first-seen name. */
|
|
25
|
+
export function mergeShaderPluginModules(modules = [], pluginModules = []) {
|
|
26
|
+
const mergedModules = [...modules];
|
|
27
|
+
const seenModuleNames = new Set(mergedModules.map(module => module.name));
|
|
28
|
+
for (const pluginModule of pluginModules) {
|
|
29
|
+
if (!seenModuleNames.has(pluginModule.name)) {
|
|
30
|
+
mergedModules.push(pluginModule);
|
|
31
|
+
seenModuleNames.add(pluginModule.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return mergedModules;
|
|
35
|
+
}
|
|
36
|
+
function appendShaderPluginVariant(resolved, variant) {
|
|
37
|
+
if (!variant) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (variant.modules?.length) {
|
|
41
|
+
resolved.modules.push(...variant.modules);
|
|
42
|
+
}
|
|
43
|
+
if (variant.defines) {
|
|
44
|
+
Object.assign(resolved.defines, variant.defines);
|
|
45
|
+
}
|
|
46
|
+
for (const [name, type] of Object.entries(variant.vertexInputs || {})) {
|
|
47
|
+
assertShaderPluginInterfaceName(name, 'vertex input');
|
|
48
|
+
const existingType = resolved.vertexInputs[name];
|
|
49
|
+
if (existingType && existingType !== type) {
|
|
50
|
+
throw new Error(`ShaderPlugin vertex input "${name}" has conflicting types "${existingType}" and "${type}"`);
|
|
51
|
+
}
|
|
52
|
+
resolved.vertexInputs[name] = type;
|
|
53
|
+
}
|
|
54
|
+
for (const [name, varying] of Object.entries(variant.varyings || {})) {
|
|
55
|
+
assertShaderPluginInterfaceName(name, 'varying');
|
|
56
|
+
const normalizedVarying = normalizeShaderPluginVarying(name, varying);
|
|
57
|
+
const existingVarying = resolved.varyings[name];
|
|
58
|
+
if (existingVarying &&
|
|
59
|
+
(existingVarying.type !== normalizedVarying.type ||
|
|
60
|
+
existingVarying.interpolation !== normalizedVarying.interpolation)) {
|
|
61
|
+
throw new Error(`ShaderPlugin varying "${name}" has conflicting declarations ` +
|
|
62
|
+
`"${existingVarying.type}/${existingVarying.interpolation}" and ` +
|
|
63
|
+
`"${normalizedVarying.type}/${normalizedVarying.interpolation}"`);
|
|
64
|
+
}
|
|
65
|
+
resolved.varyings[name] = normalizedVarying;
|
|
66
|
+
}
|
|
67
|
+
for (const injection of variant.injections || []) {
|
|
68
|
+
assertNamedShaderPluginInjectionTarget(injection.target);
|
|
69
|
+
if (!resolved.injections[injection.target]) {
|
|
70
|
+
resolved.injections[injection.target] = [];
|
|
71
|
+
}
|
|
72
|
+
const injections = resolved.injections[injection.target];
|
|
73
|
+
injections.push({
|
|
74
|
+
injection: injection.injection,
|
|
75
|
+
order: injection.order ?? 0
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function assertShaderPluginInterfaceName(name, kind) {
|
|
80
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) || name.startsWith('_luma_')) {
|
|
81
|
+
throw new Error(`ShaderPlugin ${kind} "${name}" must be a valid non-reserved identifier`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function normalizeShaderPluginVarying(name, varying) {
|
|
85
|
+
const { primitiveType } = shaderTypeDecoder.getAttributeShaderTypeInfo(varying.type);
|
|
86
|
+
const integerType = primitiveType === 'i32' || primitiveType === 'u32';
|
|
87
|
+
const interpolation = varying.interpolation || (integerType ? 'flat' : 'smooth');
|
|
88
|
+
if (integerType && interpolation === 'smooth') {
|
|
89
|
+
throw new Error(`ShaderPlugin integer varying "${name}" must use flat interpolation`);
|
|
90
|
+
}
|
|
91
|
+
return { type: varying.type, interpolation };
|
|
92
|
+
}
|
|
93
|
+
function assertNamedShaderPluginInjectionTarget(target) {
|
|
94
|
+
if (!SHADER_PLUGIN_INJECTION_TARGET_REGEX.test(target)) {
|
|
95
|
+
throw new Error(`ShaderPlugin injection target "${target}" must be a named shader anchor or hook`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=shader-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-plugin.js","sourceRoot":"","sources":["../../src/lib/shader-plugin.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,iBAAiB,EAA2B,MAAM,eAAe,CAAC;AA8E1E,MAAM,oCAAoC,GACxC,6DAA6D,CAAC;AAEhE,6EAA6E;AAC7E,MAAM,UAAU,oBAAoB,CAClC,UAAmC,EAAE,EACrC,cAA+B;IAE/B,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAsC,EAAE,CAAC;IACzD,MAAM,YAAY,GAAwC,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAgD,EAAE,CAAC;IAEjE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,yBAAyB,CAAC,EAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAC,EAAE,MAAM,CAAC,CAAC;QAC1F,yBAAyB,CACvB,EAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAC,EACtD,MAAM,CAAC,cAAc,CAAC,CACvB,CAAC;IACJ,CA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B,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,aAAa,EAAC,CAAC;AAC7C,CAAC;AAED,SAAS,sCAAsC,CAAC,MAAmC;IACjF,IAAI,CAAC,oCAAoC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CACb,kCAAkC,MAAM,yCAAyC,CAClF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/lib/utils/assert.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
// Recommendation is to ignore message but current test suite checks
|
|
4
|
+
// Recommendation is to ignore message but current test suite checks against the
|
|
5
5
|
// message so keep it for now.
|
|
6
6
|
export function assert(condition, message) {
|
|
7
7
|
if (!condition) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/lib/utils/assert.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/lib/utils/assert.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,gFAAgF;AAChF,8BAA8B;AAC9B,MAAM,UAAU,MAAM,CAAC,SAAkB,EAAE,OAAgB;IACzD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,IAAI,gCAAgC,CAAC,CAAC;QACrE,KAAK,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|