software-mansion / software-mansion/TypeGPU

fix: Stop overloading `d.location` for vertex `shaderLocation`

Open
#2,806 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

fix: Stop overloading d.location for vertex shaderLocation

In WGSL, decorators like @size or @align can only decorate struct members.

Issue #2754 pointed out that we could pass decorators to arrayOf(), which usually had no effect and was misleading.

PR #2781 partially fixed this by rejecting non-@location decorations on array element types. @location remains allowed as an exception, because it is used with vertexLayout.

Problem

d.location currently means two different things depending on context:

  • On a struct / IO member, it maps to the WGSL @location attribute.
  • In a vertexLayout, decorating an array element with d.location sets the pipeline’s shaderLocation attribute.

Moreover, due to this exception, d.location can always be passed to arrayOf(), which might be misleading.

Proposal

Make decorators single-purpose and find another way to pass shaderLocation to the vertexLayout, so arrayOf() no longer needs a special case for @location.

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 by tracing how d.location flows through arrayOf() and vertexLayout, comparing struct or IO member handling with vertex shaderLocation handling. The work is done when decorators are single-purpose, vertexLayout still receives shaderLocation, and arrayOf() no longer needs a special case for @location.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.