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

Remove vertex_pulling_transfrom from PipelineCompilationOptions. #5773

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

bradwerth
Copy link
Contributor

@bradwerth bradwerth commented Jun 4, 2024

This option was only evaluated for Metal backends, and now it's required there so the option is going away. It is still configurable for tests via the PipelineOptions struct, deserialized from .ron files.

This also fixes some type problems with the unpack functions in writer.rs. Metal << operator extends operand to int-sized, which then has to be cast back down to the real size before as_type bit conversion.

Connections
N/A

Description
This is fully transitioning the Metal backend to use vertex pulling for all cases.

Testing
All existing Metal tests now use the vertex pulling transform.

Checklist

  • Run cargo fmt.
  • 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.

@bradwerth bradwerth requested review from a team as code owners June 4, 2024 19:14
@bradwerth bradwerth force-pushed the vertexPullByDefault branch from 7256a0f to d6614e0 Compare June 4, 2024 19:30
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.

I'm leaning towards approving this, but there are a couple of things I think we should resolve:

  • I have some questions about the Metal codegen changes; I didn't expect or understand them yet. This makes me uneasy; weren't we shipping something tested to be correct before? 🤔
  • I also noticed one incorrect thing with our usage of Vec::with_capacity that should be pretty trivial to resolve. EDIT: Resolved on my end!

naga/src/back/msl/mod.rs Show resolved Hide resolved
naga/src/back/msl/writer.rs Show resolved Hide resolved
naga/src/back/msl/writer.rs Outdated Show resolved Hide resolved
tests/tests/vertex_indices/mod.rs Outdated Show resolved Hide resolved
tests/tests/vertex_indices/mod.rs Outdated Show resolved Hide resolved
@cwfitzgerald
Copy link
Member

For a change like this, possibly before this lands, definitely before we release next (1 mo ish), we need to reach out to our users for gpu side performance testing. Obviously enabling should be the default, but if this forces significant regressions, we should be exposing a escape hatch to the user.

I also feel like we should have runtime vertex format tests now that we're polyfilling them on a platform.

@bradwerth
Copy link
Contributor Author

I'm leaning towards approving this, but there are a couple of things I think we should resolve:

* I have some questions about the Metal codegen changes; I didn't expect or understand them yet. This makes me uneasy; weren't we shipping something tested to be correct before? 🤔

We don't have complete test coverage of all the vertex formats. @cwfitzgerald notes in a commment on this PR that we should. I'll expand this PR to include a test update that exercises evertyhing, which will help justify the changes to the unpack functions.

@bradwerth bradwerth marked this pull request as draft June 24, 2024 16:27
@bradwerth
Copy link
Contributor Author

Converting to draft while I expand the test coverage of all the unpack functions.

@bradwerth bradwerth force-pushed the vertexPullByDefault branch 3 times, most recently from 62eae78 to 14f93b4 Compare June 28, 2024 23:56
@bradwerth bradwerth force-pushed the vertexPullByDefault branch 10 times, most recently from 03acd91 to bd58643 Compare July 15, 2024 18:58
@bradwerth bradwerth marked this pull request as ready for review July 15, 2024 19:29
@bradwerth bradwerth force-pushed the vertexPullByDefault branch from bd58643 to 2bf3d26 Compare July 15, 2024 19:50
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

This is great!

tests/tests/vertex_formats/mod.rs Outdated Show resolved Hide resolved
tests/tests/vertex_formats/mod.rs Outdated Show resolved Hide resolved
@teoxoy
Copy link
Member

teoxoy commented Jul 16, 2024

It took me a while to double-check the decimal to byte representations, maybe we can use rust's v.to_le_bytes() methods to improve the DX. Not a hard blocker though.

@cwfitzgerald
Copy link
Member

We can also use half and bytemuck, or other such things. These are tests, so new dependencies aren't a big deal.

@bradwerth bradwerth force-pushed the vertexPullByDefault branch from 2bf3d26 to e6e939f Compare July 17, 2024 18:28
@bradwerth
Copy link
Contributor Author

Well, however the bytes are specified, the checksums are verifying that they compute to the correct values.

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

We should resolve #5773 (comment).

@bradwerth
Copy link
Contributor Author

It took me a while to double-check the decimal to byte representations, maybe we can use rust's v.to_le_bytes() methods to improve the DX. Not a hard blocker though.

The syntax for this is just markedly worse. Since the numbers are a mix of 2-byte, 4-byte, and 6-byte, and 8-byte values, it's not easy to flatten them into a single u8 array/Vec since there's no way to flatten those differently-types iterators. We end up with syntax like this:

let input_block_0 = &mut Vec::<u8>::new();
input_block_0.extend_from_slice(&0xC0C0C0C0u32.to_le_bytes()); // Unorm8x4 (0.5, 0.5, 0.5, 0.5)
input_block_0.extend_from_slice(&0xC000C000u32.to_le_bytes()); // Unorm16x2 (0.5, 0.5)
input_block_0.extend_from_slice(&0x4000400040004000u64.to_le_bytes()); // Unorm16x4 (0.25, 0.25, 0.25, 0.25)
input_block_0.extend_from_slice(&0x7F7F7F7Fu32.to_le_bytes()); // Snorm8x4 (1, 1, 1, 1)
input_block_0.extend_from_slice(&0xC000C000u32.to_le_bytes()); // Snorm16x2 (-1, -1)
input_block_0.extend_from_slice(&0x7FFF7FFF7FFF7FFFu64.to_le_bytes()); // Snorm16x4 (1, 1, 1, 1)
input_block_0.extend_from_slice(&0xFFFFu32.to_le_bytes()[0..2]); // Unorm8x2 (1, 1)
input_block_0.extend_from_slice(&0xC0C0u32.to_le_bytes()[0..2]); // Snorm8x2 (-1, -1)

I don't think this is improving readability. It's also actually wrong -- I got at least one of those values encoded incorrectly and it's messing up the checksums. I strongly urge that we leave the byte specification as-is. Re-open if you disagree.

@bradwerth bradwerth closed this Jul 18, 2024
@bradwerth
Copy link
Contributor Author

Didn't mean to close, sorry.

@bradwerth bradwerth reopened this Jul 18, 2024
@bradwerth
Copy link
Contributor Author

I don't think this is improving readability. It's also actually wrong -- I got at least one of those values encoded incorrectly and it's messing up the checksums. I strongly urge that we leave the byte specification as-is. Re-open if you disagree.

The error is trivial upon reflection: the C0s should be 80s. I still think the syntax is worse.

@bradwerth bradwerth force-pushed the vertexPullByDefault branch 2 times, most recently from 286a148 to e0387ca Compare July 18, 2024 20:25
@bradwerth bradwerth requested a review from teoxoy July 18, 2024 20:43
@bradwerth bradwerth force-pushed the vertexPullByDefault branch from e0387ca to 680d38a Compare July 18, 2024 23:12
This option was only evaluated for Metal backends, and now it's required
there so the option is going away. It is still configurable for tests
via the PipelineOptions struct, deserialized from .ron files.

This also fixes some type problems with the unpack functions in
writer.rs. Metal << operator extends operand to int-sized, which then
has to be cast back down to the real size before as_type bit conversion.
The math for the snorm values is corrected, in some cases using the
metal unpack_snorm2x16_to_float function because we can't directly
cast a bit-shifted ushort value to half.
@bradwerth bradwerth force-pushed the vertexPullByDefault branch from 680d38a to 33ff180 Compare July 18, 2024 23:37
@teoxoy teoxoy dismissed ErichDonGubler’s stale review July 19, 2024 15:13

Comments were addressed

@teoxoy teoxoy merged commit 6cd3874 into gfx-rs:trunk Jul 19, 2024
27 checks passed
@bradwerth bradwerth deleted the vertexPullByDefault branch July 19, 2024 16:30
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.

5 participants