From fd50d6e55396c1cd14dff14fcdfdd8663930afd1 Mon Sep 17 00:00:00 2001 From: Iwo Plaza Date: Thu, 7 May 2026 11:46:37 +0200 Subject: [PATCH] fix: Inter struct copies --- packages/typegpu/tests/struct.test.ts | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/typegpu/tests/struct.test.ts b/packages/typegpu/tests/struct.test.ts index 14dc0984aa..e434091f00 100644 --- a/packages/typegpu/tests/struct.test.ts +++ b/packages/typegpu/tests/struct.test.ts @@ -421,6 +421,43 @@ describe('struct', () => { }" `); }); + + it('copies?', () => { + const Boid = d.struct({ + pos: d.vec3f, + vel: d.vec3f, + }); + + const Boid2 = d.struct({ + pos: d.vec3f, + vel: d.vec3f, + }); + + function main() { + 'use gpu'; + const boid = Boid(); + const boid2 = Boid2(boid); + return boid2; + } + + expect(tgpu.resolve([main])).toMatchInlineSnapshot(` + "struct Boid { + pos: vec3f, + vel: vec3f, + } + + struct Boid2 { + pos: vec3f, + vel: vec3f, + } + + fn main() -> Boid2 { + var boid = Boid(); + var boid2 = boid; + return boid2; + }" + `); + }); }); describe('WgslStruct', () => {