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

Derive Serialize and Deserialize for all IR types #48

Closed
wants to merge 2 commits into from

Conversation

paulkernfeld
Copy link
Contributor

@paulkernfeld paulkernfeld commented May 1, 2020

Add serialize and deserialize Cargo features, a step towards #32

Copy link
Contributor

@monocodus monocodus bot 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 an autogenerated code review, new suggestions: 3

The .monocodus config not found in your repo. Default config is used.
Check config documentation here

src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
Copy link
Contributor

@monocodus monocodus bot 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 an autogenerated code review, no new suggestions, fix old one

The .monocodus config not found in your repo. Default config is used.
Check config documentation here

@paulkernfeld
Copy link
Contributor Author

The build should pass as soon as a version of rspirv containing gfx-rs/rspirv#123 is released.

@paulkernfeld
Copy link
Contributor Author

I'm not sure of the best way to handle the Monocodus fmt errors; the commit suggestions from the Monocodus bot produced invalid code. Possible solutions:

  1. Ignore the Monocodus bot and merge the code
  2. Try to fix only the fmt errors that Monocodus detected
  3. Run cargo fmt on all of src/lib.rs
  4. Run cargo fmt on the whole project (probably in a separate PR)

@kvark
Copy link
Member

kvark commented May 1, 2020

Sorry about that! Please don't mix formatting into the PR, we'll do it separately. Monocodus is a fairly new thing we are testing, and it just got an ability to be configured. I disabled the formatting check for now.

Copy link
Member

@kvark kvark 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!
We also need some CI coverage for these features

Cargo.toml Outdated Show resolved Hide resolved
@paulkernfeld
Copy link
Contributor Author

Yeah, good point! I added two tests.

Copy link
Member

@kvark kvark 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!
I think it looks good now. Just 1.5 concerns there.
Also, let's squash the commits to a state where each commit can individually pass the CI, i.e. you could interactively rebase, and at each point push the commit here, so that CI starts working on it.

name: "atan2",
arguments: [
(
index: 5,
Copy link
Member

Choose a reason for hiding this comment

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

It looks to me that most of the space in this RON is dedicated to Handle<> serialization.
Would you be open to augment it a bit in the same way wgpu deals with Ids?
See https://github.com/gfx-rs/wgpu/blob/0a0ef9a1000a4d327209570dd2606008b133a2e3/wgpu-core/src/id.rs#L22-L29

In this case, it would need to look like Id(index)

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 gave this a shot but I had trouble getting serde_derive to work with the PhantomData. Do you think it should be possible with serde_derive? Or possibly I could try implementing Serialize and Deserialize by hand for Handle<T>?

Copy link
Member

Choose a reason for hiding this comment

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

The code I linked to does almost precisely this, it also has PhantomData. Implementing the traits manually is also OK to me, but I think the same approach as linked is slightly easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right. I'll take another look to see what I am getting wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All right, I implemented and tested the concise handle serialization, then pushed it onto this PR. Fun trick 😀

tests/convert.rs Outdated Show resolved Hide resolved
@kvark
Copy link
Member

kvark commented May 1, 2020

Let's squash some more, given one of the commits is "Add poor man's snapshot test for serialization". Maybe even squash everything? Would be easier to confirm CI is happy with each commit, this way

- Add serialize and deserialize Cargo features
- Add round-trip serde tests for Handle and Module
@paulkernfeld
Copy link
Contributor Author

All right, I squashed into a single commit. BTW in case you missed it due to the long PR history, the build is currently failing because it's waiting on a deploy of gfx-rs/rspirv#123.

Now the ron representation of a Handle just looks like Handle(42)
@kvark
Copy link
Member

kvark commented Jun 9, 2020

@paulkernfeld just checking, this is still blocked?

@paulkernfeld
Copy link
Contributor Author

@kvark thanks for checking in! It looks like this is still blocked on a release of spirv_headers that includes the serde feature that was merged in gfx-rs/rspirv#125.

@paulkernfeld
Copy link
Contributor Author

Ah, it's actually now separate serialize and deserialize features but I think otherwise my comment is true.

@lachlansneff
Copy link
Contributor

@paulkernfeld Are you still working on this? If not, I'd be happy to take over.

@kvark
Copy link
Member

kvark commented Aug 13, 2020

Replaced by #125

@kvark kvark closed this Aug 13, 2020
@paulkernfeld
Copy link
Contributor Author

@lachlansneff thanks for picking up the torch on this! I lost track of it.

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.

3 participants