-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add per-vertex stuff #8591
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
base: trunk
Are you sure you want to change the base?
Add per-vertex stuff #8591
Conversation
|
My references: Vulkan |
inner-daemons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaving a bunch of comments here for my future self and because I want to have a better understanding of the code before I adopt it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to be worrying about GLSL output, especially if this is only for Vulkan accepted GLSL
| "invariant" => TokenValue::Invariant, | ||
| "flat" => TokenValue::Interpolation(crate::Interpolation::Flat), | ||
| "noperspective" => TokenValue::Interpolation(crate::Interpolation::Linear), | ||
| "pervertexEXT" => TokenValue::Interpolation(crate::Interpolation::PerVertex), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we need to be parsing this for GLSL. If its super simple then why not, but otherwise I'll probably ignore or remove it.
| #[error("The `PER_VERTEX` capability must be enabled to use per-vertex fragment inputs.")] | ||
| PerVertexNotAllowed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably just be a MissingCapability error
| #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] | ||
| #[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
| pub struct Capabilities: u32 { | ||
| pub struct Capabilities: u64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been waiting for the day!
| .parameters( | ||
| TestParameters::default() | ||
| .test_features_limits() | ||
| .features(wgpu::Features::SHADER_BARYCENTRICS), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably also needs the other feature
| ) | ||
| .run_async(barycentric); | ||
|
|
||
| async fn barycentric(ctx: TestingContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functino is quite long. In particular, I've been advised for some of my own tests to avoid vertex buffers and just generate the vertices in the fragment shader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its based off of the barycentric test (and i forgot to rename it, its copy pasta lol) which in turn is based off of the triangle indexing test. Generating vertices in the shader would make the shader more complicated, idk.
| // These tests render two triangles to a 2x2 render target. The first triangle | ||
| // in the vertex buffer covers the bottom-left pixel, the second triangle | ||
| // covers the top-right pixel. | ||
| // XY layout of the render target, with two triangles: | ||
| // | ||
| // (-1,1) (0,1) (1,1) | ||
| // +-------+-------+ | ||
| // | |o-----o| | ||
| // | | \ / | | ||
| // | | \ / | | ||
| // | | o | | ||
| // (-1,0) +-------+-------+ (1,0) | ||
| // | o | | | ||
| // | / \ | | | ||
| // | / \ | | | ||
| // |o-----o| | | ||
| // +-------+-------+ | ||
| // (-1,-1) (0,-1) (1,-1) | ||
| // | ||
| // The fragment shader outputs color based on per-vertex position: | ||
| // | ||
| // return vec4(z[0], z[1], z[2], 1.0); | ||
| // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the reason for 2 triangles related to which vertex comes in index 1 or something? I'm not sure why we need 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One should be fine, i just wanted to have more assertion on the ordering of the per-vertex attributes being consistent between platforms. It is something i am a bit worried about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a triangle strip topology or something would be a better test?
Connections
CC @atlv24 for doing the work so far, this is based off their branch here.
Description
Adds per-vertex stuff to the fragment shader as a follow-up to barycentric coordinates, allowing you to do your own stuff for interpolations.
Testing
Explain how this change is tested.
Squash or Rebase?
Squash
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.