software-mansion / software-mansion/TypeGPU
Implement `blend_src` attribute.
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 122
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
Spec: https://www.w3.org/TR/WGSL/#blend-src-attr
https://www.w3.org/TR/webgpu/#dom-gpufeaturename-dual-source-blending
Rules:
dual-source-blendingextension has to be enabled,- Can only appear as an attribute for a member of a fragment shader output struct.
- The struct containing members with this attribute has to have exactly two entries (one with @blend_str(0), and the other with @blend_str(1)).
- All the members must have same data type.
Are degrees of freedom are:
- The shared type both members will have.
- The names of both members.
Potential API:
import tgpu from 'typegpu';
import * as d from 'typegpu/data';
// Default names
/* TgpuDualSourceBlend<vec4f, 'src0', 'src1'> */
const FragmentOutput = d.dualSourceBlend(d.vec4f);
// Custom names, useful for WGSL -> JS generation
/* TgpuDualSourceBlend<vec4f, 'a', 'b'> */
const FragmentOutput = d.dualSourceBlend(d.vec4f, 'a', 'b');
const fragmentFn = tgpu.fragmentFn({
in: {},
out: FragmentOutput,
})(() => {
// ...
return {
a: d.vec4f(),
b: d.vec4f(),
};
});
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 with the WGSL blend-src attribute and WebGPU dual-source blending specifications, then trace the proposed data.dualSourceBlend API and its use as the fragmentFn output type. Define the supported type and member-name behavior from the issue, enforce the extension, placement, two-entry, index, and shared-type rules, and verify the example output shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100