Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valid: Check regular functions don't have bindings #2050

Merged
merged 1 commit into from
Sep 10, 2022

Conversation

JCapucho
Copy link
Collaborator

@JCapucho JCapucho commented Sep 7, 2022

Checks that all arguments and return types have no bindings in regular functions.

Closes #2037

@JCapucho JCapucho changed the title valid: Verify binding appears in valid place valid: Check regular functions don't have bindings Sep 7, 2022
@jimblandy
Copy link
Member

Interesting. I thought this program would be forbidden by WGSL, but the spec doesn't seem to say it is:

struct Foo {
   @location(0) x: f32,
};

fn f(arg: Foo) -> f32 {
   return arg.x;
}

Tint accepts the program.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks good, but the error messages need to be clarified:

src/valid/function.rs Outdated Show resolved Hide resolved
src/valid/function.rs Outdated Show resolved Hide resolved
@JCapucho
Copy link
Collaborator Author

Interesting. I thought this program would be forbidden by WGSL, but the spec doesn't seem to say it is:

struct Foo {
   @location(0) x: f32,
};

fn f(arg: Foo) -> f32 {
   return arg.x;
}

Tint accepts the program.

I guess this is to allow for programs like:

struct Foo {
   @location(0) x: f32,
};

@vertex
fn vs_main(foo: Foo) -> @location(0) vec4<f32> {
  let a = f(foo);
  return vec4<f32>(a);
}

fn f(arg: Foo) -> f32 {
    return arg.x;
}

Checks that all arguments and return types have no bindings in regular functions.
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic - thank you very much!

@jimblandy jimblandy merged commit ff69053 into gfx-rs:master Sep 10, 2022
@JCapucho JCapucho deleted the valid-interface branch September 10, 2022 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reject @location in non-entry-point function argments
2 participants