Skip to content

Commit

Permalink
Remove builtins from entry function arguments in tgpu-gen (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhawryluk authored Nov 6, 2024
1 parent e3fe10b commit 85a9279
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/tgpu-gen/gen.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,12 @@ function generateFunction(func, wgsl, options) {
: 'fn';

const inputs = `[${func.arguments
.flatMap((arg) => (arg.type ? [generateType(arg.type, options)] : []))
.flatMap((arg) =>
arg.type &&
arg.type.attributes?.find((attr) => attr.name === 'builtin') === undefined
? [generateType(arg.type, options)]
: [],
)
.join(', ')}]`;

const output = func.returnType
Expand Down
2 changes: 1 addition & 1 deletion packages/tgpu-gen/tests/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn mainVert(@builtin(instance_index) ii: u32, @location(0) v: vec2f) -> VertexOu

expect(generate(wgsl)).toContain(`\
export const mainVert = tgpu
.vertexFn([d.u32, d.location(0, d.vec2f)], VertexOutput)
.vertexFn([d.location(0, d.vec2f)], VertexOutput)
.does(/* wgsl */ \`(@builtin(instance_index) ii: u32, @location(0) v: vec2f) -> VertexOutput {
let instanceInfo = trianglePos[ii];
Expand Down

0 comments on commit 85a9279

Please sign in to comment.