Skip to content

Allow simpler input and outputs #76

Description

@SirLynix

Currently, a struct has to be used to specify inputs and outputs.

[nzsl_version("1.1")]
module;

const vertPos = array[vec2[f32]](
	vec2[f32](-1.0, -3.0),
	vec2[f32](-1.0, 1.0),
	vec2[f32]( 3.0, 1.0)
);

struct Input
{
    [builtin(vertex_index)] vert_index: i32
}

struct Output
{
    [builtin(position)] pos: vec4[f32] 
}

[entry(vert)]
fn main(input: Input) -> Output
{
    let output: Output;
    output.pos = vec4[f32](position, 0.0, 1.0);

    return output;
}

To simplify code we could allow some simpler syntax, perhaps something like

[entry(vert)]
fn main(vert_index: i32 @vertex_index) -> vec4[f32] @position 
{
    return vec4[f32](position, 0.0, 1.0);
}

However this syntax is pretty heavy and will make the parser/AST more complex to support attributes on parameters and return type, does anyone have a better idea?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions