Skip to content

Commit c7a22d9

Browse files
committed
Prefix structs and defines
1 parent 7e09d0e commit c7a22d9

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/utils/EffectShaderData.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ export class EffectShaderData implements ShaderData {
170170
}
171171

172172
const functionRegExp = /\w+\s+(\w+)\([\w\s,]*\)\s*{/g;
173+
const structRegExp = /struct\s+(\w*)/g;
174+
const defineRegExp = /^\s*#define\s+(\w*)/gm;
173175

174176
if(vertexShader !== null && effect.hasMainSupportFunction) {
175177

@@ -192,13 +194,24 @@ export class EffectShaderData implements ShaderData {
192194

193195
}
194196

195-
// Collect names of functions.
196197
for(const m of vertexShader.matchAll(functionRegExp)) {
197198

198199
names.add(m[1]);
199200

200201
}
201202

203+
for(const m of vertexShader.matchAll(structRegExp)) {
204+
205+
names.add(m[1]);
206+
207+
}
208+
209+
for(const m of vertexShader.matchAll(defineRegExp)) {
210+
211+
names.add(m[1]);
212+
213+
}
214+
202215
}
203216

204217
for(const m of fragmentShader.matchAll(functionRegExp)) {
@@ -207,6 +220,18 @@ export class EffectShaderData implements ShaderData {
207220

208221
}
209222

223+
for(const m of fragmentShader.matchAll(structRegExp)) {
224+
225+
names.add(m[1]);
226+
227+
}
228+
229+
for(const m of fragmentShader.matchAll(defineRegExp)) {
230+
231+
names.add(m[1]);
232+
233+
}
234+
210235
for(const d of effect.input.defines.keys()) {
211236

212237
// Ignore parameters of function-like macros.

0 commit comments

Comments
 (0)