software-mansion / software-mansion/TypeGPU
fix: Repeat call in `d.mat4x4f.translation`
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 122
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
it('...', () => {
const myVar = tgpu.privateVar(d.u32);
const helper = () => {
'use gpu';
myVar.$++;
return myVar.$;
};
const main = () => {
'use gpu';
const t = d.mat4x4f.translation(d.vec3f(helper()));
};
expect(tgpu.resolve([main])).toMatchInlineSnapshot(`
"var<private> myVar: u32;
fn helper() -> u32 {
myVar++;
return myVar;
}
fn main() {
let t = mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, vec3f(f32(helper())).x, vec3f(f32(helper())).y, vec3f(f32(helper())).z, 1);
}"
`);
});
Either delegate to another function, or find a way to detect this case and throw
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided test using d.mat4x4f.translation, helper(), and tgpu.resolve. Trace the implementation of d.mat4x4f.translation and the generated shader expression, then either delegate the repeated evaluation or reject this case; done means helper() is not emitted three times or the unsupported case throws clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100