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

Add 1-component ({s,u}{int,norm}{8,16}, float16) and unorm8x4-bgra vertex formats #6632

Merged
merged 5 commits into from
Dec 16, 2024

Conversation

nolanderc
Copy link
Contributor

@nolanderc nolanderc commented Nov 29, 2024

Connections
Closes #6614

Description

When adding the translations from wgpu::VertexFormat to the various backends, I did my best to choose the appropriate formats, but I'm not too familiar with DX12 or Metal, so please, take some extra time to verify those.

Testing
N/A

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@nolanderc nolanderc requested a review from a team as a code owner November 29, 2024 09:21
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

As I have a big change coming in that conflicts with this, I'm going to rebase so each commit can land separately.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Ah wait, hold on, metal is a lot more complicated unfortunately, as we don't use normal vertex formats, we manually transform to using vertex pulling.

First step is that I would add tests for all these new formats in https://github.com/gfx-rs/wgpu/blob/e23146aa3e8f5de0820cec108a9c1aa967454a3b/tests/tests/vertex_formats/mod.rs. This can probably join one of the other sets of tests.

Second step is to add support for these formats in naga -

fn write_unpacking_function(
. If you need mac testing help or any support, please let us know on the wgpu dev matrix in the readme.

I would appreciate the webgpu update as a separate PR, as this has a bit of work left still.

@ErichDonGubler ErichDonGubler self-assigned this Dec 2, 2024
@nolanderc nolanderc force-pushed the vertex-format-1-component branch 2 times, most recently from 4f77000 to faac144 Compare December 2, 2024 19:59
@nolanderc nolanderc requested a review from a team as a code owner December 2, 2024 20:23
@nolanderc nolanderc force-pushed the vertex-format-1-component branch 5 times, most recently from 7fdb5dc to d788e62 Compare December 2, 2024 21:47
@nolanderc
Copy link
Contributor Author

This should now be good to go @cwfitzgerald @ErichDonGubler

Comment on lines -296 to +320
Sint32x4 = 29,
Sint32x4 = 38,
/// Three unsigned 10-bit integers and one 2-bit integer, packed into a 32-bit integer (u32). [0, 1024] converted to float [0, 1] `vec4<f32>` in shaders.
#[cfg_attr(
any(feature = "serialize", feature = "deserialize"),
serde(rename = "unorm10-10-10-2")
)]
Unorm10_10_10_2 = 34,
#[cfg_attr(feature = "serde", serde(rename = "unorm10-10-10-2"))]
Unorm10_10_10_2 = 43,
/// Four unsigned 8-bit integers, packed into a 32-bit integer (u32). [0, 255] converted to float [0, 1] `vec4<f32>` in shaders.
#[cfg_attr(feature = "serde", serde(rename = "unorm8x4-bgra"))]
Unorm8x4Bgra = 44,
Copy link
Member

Choose a reason for hiding this comment

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

question: @gfx-rs/naga: This code has a 5-slot gap for texture indices here. Is there a reason that this gap should continue to exist, given these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed the gap in the previous code corresponded to the missing Float64 formats. I suppose having the enum discriminant values be a 1:1 mapping between those in wpgu_types and msl could be yield more efficient conversions between the two, or similar, so I just left it as is.

@@ -4005,6 +4005,13 @@ template <typename A>
) -> Result<(String, u32, u32), Error> {
Copy link
Member

Choose a reason for hiding this comment

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

question: @gfx-rs/naga: Why do we not re-use the output of wgpu_core::VertexFormat::size here? 🤔 I feel like it should be the same in all cases, but I admittedly haven't analyzed for divergences.

@ErichDonGubler ErichDonGubler self-assigned this Dec 10, 2024
Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

LGTM. I have questions that I've noted above, but they're not blocking. I will try testing this in CTS on Firefox first before merging, since I have a patch stack ready-but-WIP on the Firefox side. If somebody else needs this, I'm happy to merge earlier.

@cwfitzgerald, did you still want to review this?

@ErichDonGubler ErichDonGubler force-pushed the vertex-format-1-component branch from 664d2a0 to 5b1e5d7 Compare December 10, 2024 22:12
@ErichDonGubler ErichDonGubler dismissed cwfitzgerald’s stale review December 10, 2024 22:18

Feedback supposedly handled?

@cwfitzgerald
Copy link
Member

I'll take a cursory look.

@ErichDonGubler ErichDonGubler force-pushed the vertex-format-1-component branch from 5b1e5d7 to b1aac0e Compare December 12, 2024 13:04
@ErichDonGubler ErichDonGubler merged commit 21ff968 into gfx-rs:trunk Dec 16, 2024
27 checks passed
@ErichDonGubler
Copy link
Member

I don't think it makes sense to leave this to get stale after being reviewed, so I'm going to merge it. @cwfitzgerald, if you find something you'd like addressed, I'm happy to review a follow-up PR!

@cwfitzgerald
Copy link
Member

Nah this fell off my radar, merging was the right choice.

@nolanderc nolanderc deleted the vertex-format-1-component branch December 19, 2024 12:28
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.

1-component ({s,u}{int,norm}{8,16}, float16) and unorm8x4-bgra vertex formats are missing
3 participants