Entry Points
Functions annotated with @vertex
, @fragment
or @compute
are shader entry points.
Entry point names are not special, but must match the
entryPoint
name specified at pipeline creation time.
A WGSL module can contain multiple shader entry points.
@compute @workgroup_size(32)
fn my_awesome_compute_shader() {
}
@vertex
fn vertex_entry_point(@builtin(vertex_index) idx : u32) -> @builtin(position) vec4f {
return vec4f(f32(idx%2-1), f32(idx/2-1), 1, 1);
}
@fragment
fn fragment_main(@builtin(position) pos : vec4f) -> @location(0) vec4f {
return vec4(0, 1, 0, 1);
}
@compute @workgroup_size(16)
fn another_compute_entry_point() {
}