Replies: 3 comments
-
We have since reworked a couple of ideas around typed entry functions, and how builtins should be exposed to entry functions.
For vertex and fragment shader entries, there are two arguments to pass when defining the shell. const vertexMain = tgpu
.vertexFn({ idx: builtin.vertexIndex }, { pos: builtin.position, uv: vec2f })
const fragmentMain = tgpu
.fragmentFn(
{
pos: builtin.position /* TODO: Remove once builtins are properly purged from the types */,
uv: vec2f,
},
vec4f,
); So for there, the first argument means 'input', and the second one means 'output'. This however does not apply to compute shader entries. const mainInitWorld = tgpu
.computeFn([builtin.globalInvocationId], { workgroupSize: [1] }) Since compute functions do not have an output, and they have an additional configuration of 'workgroupSize', the 'in', 'out' scheme no longer applies. Possible solutions to unify the APIsRecord instead of arg listconst vertexMain = tgpu
.vertexFn({
in: { idx: builtin.vertexIndex },
out: { pos: builtin.position, uv: vec2f },
})
const fragmentMain = tgpu
.fragmentFn({
in: {
pos: builtin.position /* TODO: Remove once builtins are properly purged from the types */,
uv: vec2f,
},
out: vec4f,
});
const mainInitWorld = tgpu
.computeFn({
in: { gid: builtin.globalInvocationId },
workgroupSize: [1],
})
|
Beta Was this translation helpful? Give feedback.
-
I like the idea with record as argument. It makes the functions more readable at a glance which could be an issue at the moment. More often than not the data type will be a struct so I don't think we have to worry about clutter. |
Beta Was this translation helpful? Give feedback.
-
I like the proposal with passing a record instead of positional arguments too. it adds a little visual complexity, but makes it more readable |
Beta Was this translation helpful? Give feedback.
-
Entry functions
Compute entry functions
Vertex & Fragment entry functions
Pipelines
createComputePipeline
createRenderPipeline
Example
Beta Was this translation helpful? Give feedback.
All reactions