software-mansion / software-mansion/TypeGPU

[RFC] feat: Consistent `.$` in raw WGSL implemented functions

Open
#2,678 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.2k
Forks
122
Avg merge
3d 5h
Merged PRs (30d)
34

Description

After layout, you need to add .$ before accessing bound resources. This does not work for slots:

  it('allows for re-resolves of slotted functions', () => {
    const slot = tgpu.slot<number>(1);
    const helper = tgpu.fn([], d.u32)`() { return slot.$ }`.$uses({ slot }).with(slot, 2);

    const main = tgpu.fn([])`() {
  let x = helper();
  let y = helper();
}`.$uses({ helper });

    expect(tgpu.resolve([main])).toMatchInlineSnapshot(`
      "fn helper() -> u32 { return 2.$ }

      fn main() {
        let x = helper();
        let y = helper();
      }"
    `);
  });

Also, we need docs for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the inline test for re-resolves of slotted functions and trace tgpu.resolve together with .$uses({ slot }).with(slot, 2). Ensure the resolved helper emits 2.$ while calls from main remain valid, then add documentation covering the required .$ access after layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.