@luma.gl/shaders 10.0.0-alpha.6 → 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/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
package/src/lib/shader-plugin.ts
CHANGED
|
@@ -21,131 +21,135 @@ export type ShaderPluginInjectionTarget =
|
|
|
21
21
|
export type ShaderPluginInjection = {
|
|
22
22
|
/** Named shader anchor or hook that receives this source. */
|
|
23
23
|
target: ShaderPluginInjectionTarget;
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/** GLSL source for this target. Omit to skip this injection when assembling GLSL. */
|
|
25
|
+
glsl?: string;
|
|
26
|
+
/** WGSL source for this target. Omit to skip this injection when assembling WGSL. */
|
|
27
|
+
wgsl?: string;
|
|
26
28
|
/** Relative injection order within the target. */
|
|
27
29
|
order?: number;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
|
-
/** Portable interpolation modes for ShaderPlugin
|
|
31
|
-
export type
|
|
32
|
+
/** Portable interpolation modes for ShaderPlugin inter-stage variables. */
|
|
33
|
+
export type ShaderPluginInterStageVariableInterpolation = 'smooth' | 'flat';
|
|
32
34
|
|
|
33
35
|
/** Cross-stage value contributed by a ShaderPlugin. */
|
|
34
|
-
export type
|
|
36
|
+
export type ShaderPluginInterStageVariable = {
|
|
35
37
|
/** Portable scalar or vector shader type. */
|
|
36
38
|
type: AttributeShaderType;
|
|
37
39
|
/** Defaults to smooth for floating-point types and flat for integer types. */
|
|
38
|
-
interpolation?:
|
|
40
|
+
interpolation?: ShaderPluginInterStageVariableInterpolation;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
|
-
/** Fully normalized ShaderPlugin
|
|
42
|
-
export type
|
|
43
|
+
/** Fully normalized ShaderPlugin inter-stage variable declaration. */
|
|
44
|
+
export type ResolvedShaderPluginInterStageVariable = {
|
|
43
45
|
type: AttributeShaderType;
|
|
44
|
-
interpolation:
|
|
46
|
+
interpolation: ShaderPluginInterStageVariableInterpolation;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
/**
|
|
48
|
-
export type
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
|
|
49
|
+
/** Reusable shader assembly descriptor with one portable interface and language-specific source. */
|
|
50
|
+
export type ShaderPlugin = {
|
|
51
|
+
/** Stable plugin identifier. */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Primary shader module. Supporting modules belong in its dependencies; omit for injection-only plugins. */
|
|
54
|
+
module?: ShaderModule<any, any, any>;
|
|
55
|
+
/** Boolean or numeric preprocessor defines added to shader assembly. */
|
|
56
|
+
defines?: Record<string, boolean | number>;
|
|
53
57
|
/** Named code injections added to shader assembly. */
|
|
54
58
|
injections?: ShaderPluginInjection[];
|
|
55
59
|
/** Shader-facing vertex inputs added by this plugin. Buffer ownership remains with the caller. */
|
|
56
60
|
vertexInputs?: Record<string, AttributeShaderType>;
|
|
57
61
|
/** Values transported from the selected vertex entry point to the fragment entry point. */
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/** Reusable cross-backend shader assembly descriptor. */
|
|
62
|
-
export type ShaderPlugin = ShaderPluginVariant & {
|
|
63
|
-
/** Stable plugin identifier. */
|
|
64
|
-
name: string;
|
|
65
|
-
/** GLSL-only shader assembly contributions. */
|
|
66
|
-
glsl?: ShaderPluginVariant;
|
|
67
|
-
/** WGSL-only shader assembly contributions. */
|
|
68
|
-
wgsl?: ShaderPluginVariant;
|
|
62
|
+
interStageVariables?: Record<string, ShaderPluginInterStageVariable>;
|
|
69
63
|
};
|
|
70
64
|
|
|
71
65
|
/** ShaderPlugin contributions resolved for one shader language. */
|
|
72
66
|
export type ResolvedShaderPlugins = {
|
|
73
67
|
/** Resolved shader modules in plugin declaration order. */
|
|
74
68
|
modules: ShaderModule[];
|
|
75
|
-
/** Resolved boolean preprocessor defines. */
|
|
76
|
-
defines: Record<string, boolean>;
|
|
69
|
+
/** Resolved boolean or numeric preprocessor defines. */
|
|
70
|
+
defines: Record<string, boolean | number>;
|
|
77
71
|
/** Resolved named code injections grouped by target. */
|
|
78
72
|
injections: Record<string, ShaderInjection[]>;
|
|
79
73
|
/** Resolved shader-facing vertex inputs in plugin declaration order. */
|
|
80
74
|
vertexInputs: Record<string, AttributeShaderType>;
|
|
81
|
-
/** Resolved
|
|
82
|
-
|
|
75
|
+
/** Resolved inter-stage variables in plugin declaration order. */
|
|
76
|
+
interStageVariables: Record<string, ResolvedShaderPluginInterStageVariable>;
|
|
83
77
|
};
|
|
84
78
|
|
|
85
79
|
const SHADER_PLUGIN_INJECTION_TARGET_REGEX =
|
|
86
80
|
/^(vs|fs):(?:#(?:decl|main-start|main-end)|[A-Za-z_][\w-]*)$/;
|
|
87
81
|
|
|
88
|
-
/** Resolve
|
|
82
|
+
/** Resolve plugin interfaces and select injection source for one shader language. */
|
|
89
83
|
export function resolveShaderPlugins(
|
|
90
84
|
plugins: readonly ShaderPlugin[] = [],
|
|
91
85
|
shaderLanguage: 'glsl' | 'wgsl'
|
|
92
86
|
): ResolvedShaderPlugins {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
const resolved: ResolvedShaderPlugins = {
|
|
88
|
+
modules: [],
|
|
89
|
+
defines: {},
|
|
90
|
+
injections: {},
|
|
91
|
+
vertexInputs: {},
|
|
92
|
+
interStageVariables: {}
|
|
93
|
+
};
|
|
98
94
|
|
|
99
95
|
for (const plugin of plugins) {
|
|
100
|
-
|
|
101
|
-
appendShaderPluginVariant(
|
|
102
|
-
{modules, defines, injections, vertexInputs, varyings},
|
|
103
|
-
plugin[shaderLanguage]
|
|
104
|
-
);
|
|
96
|
+
appendShaderPlugin(resolved, plugin, shaderLanguage);
|
|
105
97
|
}
|
|
98
|
+
const {vertexInputs, interStageVariables} = resolved;
|
|
106
99
|
|
|
107
|
-
for (const name of Object.keys(
|
|
100
|
+
for (const name of Object.keys(interStageVariables)) {
|
|
108
101
|
if (vertexInputs[name]) {
|
|
109
102
|
throw new Error(`ShaderPlugin name "${name}" cannot be both a vertex input and a varying`);
|
|
110
103
|
}
|
|
111
104
|
}
|
|
112
105
|
|
|
113
|
-
return
|
|
106
|
+
return resolved;
|
|
114
107
|
}
|
|
115
108
|
|
|
116
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Preserve explicit module inputs while appending plugin modules by first-seen name.
|
|
111
|
+
* Optional diagnostics report distinct descriptors sharing a name, without changing selection.
|
|
112
|
+
* Descriptor identity is checked; equivalent independently-created descriptors also report a conflict.
|
|
113
|
+
*/
|
|
117
114
|
export function mergeShaderPluginModules(
|
|
118
115
|
modules: readonly ShaderModule[] = [],
|
|
119
|
-
pluginModules: readonly ShaderModule[] = []
|
|
116
|
+
pluginModules: readonly ShaderModule[] = [],
|
|
117
|
+
options: {onConflict?: (name: string, selected: ShaderModule, ignored: ShaderModule) => void} = {}
|
|
120
118
|
): ShaderModule[] {
|
|
121
119
|
const mergedModules: ShaderModule[] = [...modules];
|
|
122
|
-
const
|
|
120
|
+
const selectedModules = new Map<string, ShaderModule>();
|
|
121
|
+
for (const module of mergedModules) {
|
|
122
|
+
const selected = selectedModules.get(module.name);
|
|
123
|
+
if (selected && selected !== module) options.onConflict?.(module.name, selected, module);
|
|
124
|
+
if (!selected) selectedModules.set(module.name, module);
|
|
125
|
+
}
|
|
123
126
|
|
|
124
127
|
for (const pluginModule of pluginModules) {
|
|
125
|
-
|
|
128
|
+
const selected = selectedModules.get(pluginModule.name);
|
|
129
|
+
if (selected && selected !== pluginModule) {
|
|
130
|
+
options.onConflict?.(pluginModule.name, selected, pluginModule);
|
|
131
|
+
}
|
|
132
|
+
if (!selected) {
|
|
126
133
|
mergedModules.push(pluginModule);
|
|
127
|
-
|
|
134
|
+
selectedModules.set(pluginModule.name, pluginModule);
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
return mergedModules;
|
|
132
139
|
}
|
|
133
140
|
|
|
134
|
-
function
|
|
141
|
+
function appendShaderPlugin(
|
|
135
142
|
resolved: ResolvedShaderPlugins,
|
|
136
|
-
|
|
143
|
+
plugin: ShaderPlugin,
|
|
144
|
+
shaderLanguage: 'glsl' | 'wgsl'
|
|
137
145
|
): void {
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (variant.modules?.length) {
|
|
143
|
-
resolved.modules.push(...variant.modules);
|
|
146
|
+
if (plugin.module) {
|
|
147
|
+
resolved.modules.push(plugin.module);
|
|
144
148
|
}
|
|
145
|
-
if (
|
|
146
|
-
Object.assign(resolved.defines,
|
|
149
|
+
if (plugin.defines) {
|
|
150
|
+
Object.assign(resolved.defines, plugin.defines);
|
|
147
151
|
}
|
|
148
|
-
for (const [name, type] of Object.entries(
|
|
152
|
+
for (const [name, type] of Object.entries(plugin.vertexInputs || {})) {
|
|
149
153
|
assertShaderPluginInterfaceName(name, 'vertex input');
|
|
150
154
|
const existingType = resolved.vertexInputs[name];
|
|
151
155
|
if (existingType && existingType !== type) {
|
|
@@ -155,10 +159,10 @@ function appendShaderPluginVariant(
|
|
|
155
159
|
}
|
|
156
160
|
resolved.vertexInputs[name] = type;
|
|
157
161
|
}
|
|
158
|
-
for (const [name, varying] of Object.entries(
|
|
162
|
+
for (const [name, varying] of Object.entries(plugin.interStageVariables || {})) {
|
|
159
163
|
assertShaderPluginInterfaceName(name, 'varying');
|
|
160
|
-
const normalizedVarying =
|
|
161
|
-
const existingVarying = resolved.
|
|
164
|
+
const normalizedVarying = normalizeShaderPluginInterStageVariable(name, varying);
|
|
165
|
+
const existingVarying = resolved.interStageVariables[name];
|
|
162
166
|
if (
|
|
163
167
|
existingVarying &&
|
|
164
168
|
(existingVarying.type !== normalizedVarying.type ||
|
|
@@ -170,17 +174,20 @@ function appendShaderPluginVariant(
|
|
|
170
174
|
`"${normalizedVarying.type}/${normalizedVarying.interpolation}"`
|
|
171
175
|
);
|
|
172
176
|
}
|
|
173
|
-
resolved.
|
|
177
|
+
resolved.interStageVariables[name] = normalizedVarying;
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
for (const injection of
|
|
180
|
+
for (const injection of plugin.injections || []) {
|
|
181
|
+
const source = injection[shaderLanguage];
|
|
182
|
+
if (source === undefined) continue;
|
|
177
183
|
assertNamedShaderPluginInjectionTarget(injection.target);
|
|
178
184
|
if (!resolved.injections[injection.target]) {
|
|
179
185
|
resolved.injections[injection.target] = [];
|
|
180
186
|
}
|
|
181
187
|
const injections = resolved.injections[injection.target];
|
|
182
188
|
injections.push({
|
|
183
|
-
|
|
189
|
+
pluginName: plugin.name,
|
|
190
|
+
injection: source,
|
|
184
191
|
order: injection.order ?? 0
|
|
185
192
|
});
|
|
186
193
|
}
|
|
@@ -192,10 +199,10 @@ function assertShaderPluginInterfaceName(name: string, kind: 'vertex input' | 'v
|
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
|
|
195
|
-
function
|
|
202
|
+
function normalizeShaderPluginInterStageVariable(
|
|
196
203
|
name: string,
|
|
197
|
-
varying:
|
|
198
|
-
):
|
|
204
|
+
varying: ShaderPluginInterStageVariable
|
|
205
|
+
): ResolvedShaderPluginInterStageVariable {
|
|
199
206
|
const {primitiveType} = shaderTypeDecoder.getAttributeShaderTypeInfo(varying.type);
|
|
200
207
|
const integerType = primitiveType === 'i32' || primitiveType === 'u32';
|
|
201
208
|
const interpolation = varying.interpolation || (integerType ? 'flat' : 'smooth');
|
|
@@ -36,7 +36,7 @@ export class WGSLShaderAssembler extends ShaderAssembler {
|
|
|
36
36
|
entryPoints: ShaderTranspilerEntryPoints;
|
|
37
37
|
} {
|
|
38
38
|
const modules = this._getModuleList(props.modules); // Combine with default modules
|
|
39
|
-
const hookFunctions = this._hookFunctions
|
|
39
|
+
const hookFunctions = [...this._hookFunctions, ...(props.hookFunctions || [])];
|
|
40
40
|
const translated = this._transpileShader(
|
|
41
41
|
props,
|
|
42
42
|
modules,
|
|
@@ -100,50 +100,38 @@ fn clip_isInBounds(coordinates: vec2<f32>) -> bool {
|
|
|
100
100
|
/** Coordinate-system-neutral instance and geometry clipping. */
|
|
101
101
|
export const clipShaderPlugin: ShaderPlugin = {
|
|
102
102
|
name: 'clip',
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
module: clipShaderModule,
|
|
104
|
+
interStageVariables: {
|
|
105
105
|
clipCoordinates: {type: 'vec2<f32>', interpolation: 'smooth'}
|
|
106
106
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
injection: `\
|
|
107
|
+
injections: [
|
|
108
|
+
{
|
|
109
|
+
target: 'vs:CLIP_POSITION',
|
|
110
|
+
glsl: `\
|
|
112
111
|
clipCoordinates = geometryCoordinates;
|
|
113
112
|
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_INSTANCE} &&
|
|
114
113
|
!clip_isInBounds(instanceCoordinates)) {
|
|
115
114
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
target: 'fs:CLIP_COLOR',
|
|
120
|
-
injection: `\
|
|
121
|
-
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
122
|
-
!clip_isInBounds(clipCoordinates)) {
|
|
123
|
-
discard;
|
|
124
|
-
}`
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
},
|
|
128
|
-
wgsl: {
|
|
129
|
-
injections: [
|
|
130
|
-
{
|
|
131
|
-
target: 'vs:CLIP_POSITION',
|
|
132
|
-
injection: `\
|
|
115
|
+
}`,
|
|
116
|
+
wgsl: `\
|
|
133
117
|
clipCoordinates = geometryCoordinates;
|
|
134
118
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_INSTANCE} &&
|
|
135
119
|
!clip_isInBounds(instanceCoordinates)) {
|
|
136
120
|
*position = vec4<f32>(2.0, 2.0, 2.0, 1.0);
|
|
137
121
|
}`
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
target: 'fs:CLIP_COLOR',
|
|
125
|
+
glsl: `\
|
|
126
|
+
if (clipState.enabled != 0 && clipState.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
127
|
+
!clip_isInBounds(clipCoordinates)) {
|
|
128
|
+
discard;
|
|
129
|
+
}`,
|
|
130
|
+
wgsl: `\
|
|
142
131
|
if (clipUniforms.enabled != 0 && clipUniforms.mode == ${CLIP_MODE_GEOMETRY} &&
|
|
143
132
|
!clip_isInBounds(clipCoordinates)) {
|
|
144
133
|
discard;
|
|
145
134
|
}`
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
135
|
+
}
|
|
136
|
+
]
|
|
149
137
|
};
|
|
@@ -78,30 +78,21 @@ fn filter_isVisible(value: f32) -> bool {
|
|
|
78
78
|
/** Scalar inclusive-range filtering for shaders that expose the `FILTER_POSITION` vertex hook. */
|
|
79
79
|
export const filterShaderPlugin: ShaderPlugin = {
|
|
80
80
|
name: 'filter',
|
|
81
|
-
|
|
81
|
+
module: filterShaderModule,
|
|
82
82
|
vertexInputs: {
|
|
83
83
|
filterValues: 'f32'
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
injection: `\
|
|
85
|
+
injections: [
|
|
86
|
+
{
|
|
87
|
+
target: 'vs:FILTER_POSITION',
|
|
88
|
+
glsl: `\
|
|
90
89
|
if (!filter_isVisible(filterValues)) {
|
|
91
90
|
position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
wgsl: {
|
|
97
|
-
injections: [
|
|
98
|
-
{
|
|
99
|
-
target: 'vs:FILTER_POSITION',
|
|
100
|
-
injection: `\
|
|
91
|
+
}`,
|
|
92
|
+
wgsl: `\
|
|
101
93
|
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
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {ShaderModule} from '../../../lib/shader-module/shader-module';
|
|
6
6
|
|
|
7
|
-
import {fp64ify, fp64LowPart, fp64ifyMatrix4} from '
|
|
7
|
+
import {fp64ify, fp64LowPart, fp64ifyMatrix4} from './fp64-utils';
|
|
8
8
|
import {fp64arithmeticShader} from './fp64-arithmetic-glsl';
|
|
9
9
|
import {fp64arithmeticWGSL} from './fp64-arithmetic-wgsl';
|
|
10
10
|
import {fp64functionShader} from './fp64-functions-glsl';
|
package/src/types.ts
CHANGED
|
@@ -35,13 +35,81 @@ export type UniformFormat =
|
|
|
35
35
|
| 'mat4x3<f32>'
|
|
36
36
|
| 'mat4x4<f32>';
|
|
37
37
|
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
export {type PrimitiveDataType} from './types/primitive-data-types';
|
|
39
|
+
export {
|
|
40
|
+
type AttributeShaderType,
|
|
41
|
+
type VariableShaderType,
|
|
42
|
+
type CompositeShaderType,
|
|
43
|
+
type StructShaderType,
|
|
44
|
+
type ArrayShaderType,
|
|
45
|
+
type AttributeShaderTypeAlias,
|
|
46
|
+
type VariableShaderTypeAlias,
|
|
47
|
+
type AttributeShaderTypeT,
|
|
48
|
+
type VariableShaderTypeT,
|
|
49
|
+
type AttributeShaderTypeAliasT,
|
|
50
|
+
type VariableShaderTypeAliasT
|
|
51
|
+
} from './types/shader-types';
|
|
52
|
+
export {
|
|
53
|
+
getVariableShaderTypeInfo,
|
|
54
|
+
getAttributeShaderTypeInfo,
|
|
55
|
+
makeShaderAttributeType,
|
|
56
|
+
resolveAttributeShaderTypeAlias,
|
|
57
|
+
resolveVariableShaderTypeAlias,
|
|
58
|
+
type VariableShaderTypeInfo,
|
|
59
|
+
type AttributeShaderTypeInfo,
|
|
60
|
+
ShaderTypeDecoder,
|
|
61
|
+
shaderTypeDecoder,
|
|
62
|
+
WGSL_ATTRIBUTE_TYPE_ALIAS_MAP,
|
|
63
|
+
WGSL_VARIABLE_TYPE_ALIAS_MAP
|
|
64
|
+
} from './types/shader-type-decoder';
|
|
65
|
+
export {
|
|
66
|
+
makeShaderBlockLayout,
|
|
67
|
+
getLeafLayoutInfo,
|
|
68
|
+
isCompositeShaderTypeStruct,
|
|
69
|
+
type ShaderBlockLayoutEntry,
|
|
70
|
+
type ShaderBlockLayoutOptions,
|
|
71
|
+
type ShaderBlockLayout
|
|
72
|
+
} from './types/shader-block-layout';
|
|
73
|
+
export {
|
|
74
|
+
type ShaderLayout,
|
|
75
|
+
type ComputeShaderLayout,
|
|
76
|
+
type AttributeDeclaration,
|
|
77
|
+
type BindingDeclaration,
|
|
78
|
+
type UniformBufferBindingLayout,
|
|
79
|
+
type UniformBlockLayout,
|
|
80
|
+
type UniformInfo,
|
|
81
|
+
type StorageBufferBindingLayout,
|
|
82
|
+
type TextureBindingLayout,
|
|
83
|
+
type ExternalTextureBindingLayout,
|
|
84
|
+
type SamplerBindingLayout,
|
|
85
|
+
type StorageTextureBindingLayout,
|
|
86
|
+
type VaryingBinding,
|
|
87
|
+
type UniformBlockBinding,
|
|
88
|
+
type UniformBinding
|
|
89
|
+
} from './types/shader-layout';
|
|
90
|
+
export {
|
|
91
|
+
type TextureFormat,
|
|
92
|
+
type TextureFormatDepthStencil,
|
|
93
|
+
type TextureFormatColor,
|
|
94
|
+
type TextureFormatColorUncompressed,
|
|
95
|
+
type TextureFormatUnorm8,
|
|
96
|
+
type TextureFormatSnorm8,
|
|
97
|
+
type TextureFormatUint8,
|
|
98
|
+
type TextureFormatSint8,
|
|
99
|
+
type TextureFormatUnorm16,
|
|
100
|
+
type TextureFormatSnorm16,
|
|
101
|
+
type TextureFormatUint16,
|
|
102
|
+
type TextureFormatSint16,
|
|
103
|
+
type TextureFormatFloat16,
|
|
104
|
+
type TextureFormatUint32,
|
|
105
|
+
type TextureFormatSint32,
|
|
106
|
+
type TextureFormatFloat32,
|
|
107
|
+
type TextureFormatPacked16,
|
|
108
|
+
type TextureFormatPacked32,
|
|
109
|
+
type TextureFormatCompressed,
|
|
110
|
+
type CompressedTextureFormat
|
|
111
|
+
} from './types/texture-formats';
|
|
112
|
+
export {type CompareFunction, type SamplerProps} from './types/sampler-props';
|
|
45
113
|
export {alignTo} from './types/align-to';
|
|
46
114
|
|
|
47
115
|
/** Resource values remain opaque until an execution adapter binds them. */
|
package/src/wgsl.ts
CHANGED
|
@@ -20,4 +20,15 @@ export {
|
|
|
20
20
|
type ShaderBindingDebugRow
|
|
21
21
|
} from './lib/shader-assembly/wgsl-binding-debug';
|
|
22
22
|
|
|
23
|
-
export
|
|
23
|
+
export {
|
|
24
|
+
maskWGSLComments,
|
|
25
|
+
getWGSLBindingDeclarationMatches,
|
|
26
|
+
replaceWGSLBindingDeclarationMatches,
|
|
27
|
+
hasWGSLAutoBinding,
|
|
28
|
+
getFirstWGSLAutoBindingDeclarationMatch,
|
|
29
|
+
WGSL_BINDABLE_VARIABLE_PATTERN,
|
|
30
|
+
MODULE_WGSL_BINDING_DECLARATION_REGEXES,
|
|
31
|
+
WGSL_BINDING_DECLARATION_REGEXES,
|
|
32
|
+
WGSL_EXPLICIT_BINDING_DECLARATION_REGEXES,
|
|
33
|
+
type WGSLBindingDeclarationMatch
|
|
34
|
+
} from './lib/shader-assembly/wgsl-binding-scan';
|