software-mansion / software-mansion/TypeGPU
feat: Shell-less entry function wrappers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 122
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
This depends on #1835 being done, but I was wondering how viable it would be to allow for a workflow where entry functions can still be defined separately from the render pipeline, yet benefit from not having to setup a shell.
const vertex = tgpu.vertexFn(({ $vertexIndex }) => {
'use gpu';
const pos = [
d.vec2f(0.0, 0.5),
d.vec2f(-0.5, -0.5),
d.vec2f(0.5, -0.5),
];
const uv = [
d.vec2f(0.5, 1.0),
d.vec2f(0.0, 0.0),
d.vec2f(1.0, 0.0),
];
return {
$position: d.vec4f(pos[$vertexIndex], 0, 1),
uv: uv[$vertexIndex],
};
});
const fragment = tgpu.fragmentFn<typeof vertexFn>(({ uv }) => {
'use gpu';
return getGradientColor((uv.x + uv.y) / 2);
});
const pipeline = root.createRenderPipeline({ vertex, fragment });
I'm not yet sure how attribute type information would be provided to a vertex function, but we can figure that out while prototyping this feature.
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
Start by reading the prerequisite issue #1835, then prototype the separate vertexFn and fragmentFn entry functions shown in this issue. Done means entry functions can be passed directly to createRenderPipeline without a shell, with a decided approach for providing vertex attribute type information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100