Skip to content

feat: Shell-less entry function wrappers #2032

@iwoplaza

Description

@iwoplaza

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions