Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Default entryPoints to shader modules #4342

@greggman

Description

@greggman

Maybe this was already discussed but, as it is, you always have to specify entry points when creating a pipeline. After having written a bunch of WebGPU, it seems like it would be nice if there were some defaults.

In other words, these 2 lines

  const pipeline = device.createRenderPipeline({
    layout: 'auto',
    vertex: {
      module: shaderModule,
      entryPoint: 'myVSMain',    // <-------------------
    },
    fragment: {
      module: shaderModule,
      entryPoint: 'myFSMain',    // <-------------------
      ...
    },
  });

If there were a default "entryPoint" for each stage then these lines would not be needed and would make the api a tiny bit less tedious.

4 ideas

  1. The defaults could be something like vertexMain, fragmentMain, computeMain

  2. If the attribute is considered part of the name then just main

    In other words, @compute fn main(...) is different from @vertex main fn(...) because
    of the attribute specifying what type of shader it is so if in createXXXPipeline you don't specify an entry point then it looks for main with a correct attribute for the stage.

  3. The default is the first compatible function.

    In this idea, using the attributes again @compute vs @fragment vs @vertex. If no entryPoint is specified, find the first function that has the required attribute, the name is irrelevant.

  4. The default is the only compatible function

    This idea is the same as # 3 except if there are 2 or more compatible functions you get an error "More than one compatible function. You must specify an entryPoint"

I know it's not a big deal. I just thought I ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions