Skip to content

Commit

Permalink
chore(shadertools): Use published wgsl_reflect module (#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Mar 29, 2024
1 parent 530f29d commit e0edd3f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3,401 deletions.
3 changes: 2 additions & 1 deletion modules/shadertools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"dependencies": {
"@math.gl/core": "^4.0.0",
"@math.gl/types": "^4.0.0"
"@math.gl/types": "^4.0.0",
"wgsl_reflect": "^1.0.1"
},
"gitHead": "c636c34b8f1581eed163e94543a8eb1f4382ba8e"
}
10 changes: 5 additions & 5 deletions modules/shadertools/src/lib/wgsl/get-shader-layout-wgsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) vis.gl contributors

import {ShaderAttributeType, ShaderLayout, log} from '@luma.gl/core';
import {WgslReflect} from '../../libs/wgsl-reflect/wgsl_reflect.module.js';
import {WgslReflect} from 'wgsl_reflect';

/**
* Parse a ShaderLayout from WGSL shader source code.
Expand All @@ -23,10 +23,10 @@ export function getShaderLayoutFromWGSL(source: string): ShaderLayout {

for (const uniform of parsedWGSL.uniforms) {
const members = [];
for (const member of uniform.type.members) {
for (const attribute of (uniform.type as any)?.members || []) {
members.push({
name: member.name,
type: getType(member.type)
name: attribute.name,
type: getType(attribute.type)
});
}

Expand All @@ -53,7 +53,7 @@ export function getShaderLayoutFromWGSL(source: string): ShaderLayout {

shaderLayout.attributes.push({
name: wgslAttribute.name,
location: wgslAttribute.location,
location: Number(wgslAttribute.location),
type
});
}
Expand Down
Loading

0 comments on commit e0edd3f

Please sign in to comment.