From 85a9279f2d751d0d742090c26fa4d47c281cd46b Mon Sep 17 00:00:00 2001 From: Marcin Hawryluk <70582973+mhawryluk@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:43:24 +0100 Subject: [PATCH] Remove builtins from entry function arguments in tgpu-gen (#532) --- packages/tgpu-gen/gen.mjs | 7 ++++++- packages/tgpu-gen/tests/functions.test.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/tgpu-gen/gen.mjs b/packages/tgpu-gen/gen.mjs index b7825081..def50385 100644 --- a/packages/tgpu-gen/gen.mjs +++ b/packages/tgpu-gen/gen.mjs @@ -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 diff --git a/packages/tgpu-gen/tests/functions.test.ts b/packages/tgpu-gen/tests/functions.test.ts index 8fe7efab..b67263fb 100644 --- a/packages/tgpu-gen/tests/functions.test.ts +++ b/packages/tgpu-gen/tests/functions.test.ts @@ -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];