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

Move some types into shared wgpu-types crate #514

Merged
merged 2 commits into from
Mar 11, 2020
Merged

Move some types into shared wgpu-types crate #514

merged 2 commits into from
Mar 11, 2020

Conversation

grovesNL
Copy link
Collaborator

@grovesNL grovesNL commented Mar 10, 2020

As we discussed a while ago, we need to be able to share some types between wgpu-core/wgpu-native/wgpu-remote/wgpu-rs.

The problem is that we want to avoid a dependency on wgpu-core and wgpu-native when building wgpu-rs for the wasm32-unknown-unknown target. We can avoid this by moving all shared types into a separate crate which is exposed on all targets.

Let me know if we should use some other approach or organize the types somehow. This isn't complete yet, but it might be easier to integrate this over several PRs instead of diverging my branch too far.

@grovesNL grovesNL requested a review from kvark March 10, 2020 02:32
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.

Nice work! A few corrections are needed

@@ -0,0 +1,506 @@
use std::{io, slice};
Copy link
Member

Choose a reason for hiding this comment

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

let's have a license header like we do in wgpu source files, so that we don't have a problem vendoring this in Gecko

#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Backend {
Copy link
Member

Choose a reason for hiding this comment

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

This one doesn't sounds like you'd want from the Web side?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I debated whether to include this here. It's part of the public API wgpu-rs, so it's slightly easier to include another BrowserWebGpu variant (possibly even BrowserWebGl later) instead of trying to redefine Backend for the wasm32 target.

wgpu-core/Cargo.toml Show resolved Hide resolved
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.

ship it!
bors r+

bors bot added a commit that referenced this pull request Mar 10, 2020
514: Move some types into shared wgpu-types crate r=kvark a=grovesNL

As we discussed a while ago, we need to be able to share some types between wgpu-core/wgpu-native/wgpu-remote/wgpu-rs.

The problem is that we want to avoid a dependency on wgpu-core and wgpu-native when building [wgpu-rs for the wasm32-unknown-unknown target](gfx-rs/wgpu-rs#101). We can avoid this by moving all shared types into a separate crate which is exposed on all targets.

Let me know if we should use some other approach or organize the types somehow. This isn't complete yet, but it might be easier to integrate this over several PRs instead of diverging my branch too far.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
@bors
Copy link
Contributor

bors bot commented Mar 10, 2020

Build failed

@grovesNL
Copy link
Collaborator Author

@kvark did you want to take another look at the updated Cargo.tomls? I think we need it to be something like this for serde (at least for now without introducing a separate feature)

path = "../wgpu-types"
package = "wgpu-types"
version = "0.1"
features = ["serde"]
Copy link
Member

Choose a reason for hiding this comment

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

so serde is now unconditional? that seems wrong - native users don't need it

@@ -71,7 +72,7 @@ pub enum PresentMode {
#[derive(Clone, Debug)]
Copy link
Contributor

@aloucks aloucks Mar 11, 2020

Choose a reason for hiding this comment

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

Should the SwapChainDescriptor and PresentMode move as well?

I didn't do an exhaustive check, but I would think it should be everything re-exported here:

https://github.com/gfx-rs/wgpu-rs/blob/master/src/lib.rs#L19-L84

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah most likely, this PR isn't comprehensive because I didn't want this branch to diverge too much. I'm just moving types across whenever I need to use them with the web-sys backend (gfx-rs/wgpu-rs#193), so there will be some smaller PRs later

@grovesNL
Copy link
Collaborator Author

@kvark I added a serde1 feature to workaround this, and added a few more types

@aloucks
Copy link
Contributor

aloucks commented Mar 11, 2020

@kvark I added a serde1 feature to workaround this, and added a few more types

You could make the feature name serde with the serde crate attribute and package renaming.

Example: https://github.com/RustCrypto/RSA/pull/41/files

@grovesNL
Copy link
Collaborator Author

Interesting, let's try doing that instead. Thanks!

@aloucks
Copy link
Contributor

aloucks commented Mar 11, 2020

need to update the attributes too:

- #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
+ #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))]

@kvark
Copy link
Member

kvark commented Mar 11, 2020

@grovesNL please proceed when ready, unless you have specific spots that need a look/review.

@grovesNL
Copy link
Collaborator Author

bors r=kvark

bors bot added a commit that referenced this pull request Mar 11, 2020
514: Move some types into shared wgpu-types crate r=kvark a=grovesNL

As we discussed a while ago, we need to be able to share some types between wgpu-core/wgpu-native/wgpu-remote/wgpu-rs.

The problem is that we want to avoid a dependency on wgpu-core and wgpu-native when building [wgpu-rs for the wasm32-unknown-unknown target](gfx-rs/wgpu-rs#101). We can avoid this by moving all shared types into a separate crate which is exposed on all targets.

Let me know if we should use some other approach or organize the types somehow. This isn't complete yet, but it might be easier to integrate this over several PRs instead of diverging my branch too far.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
@kvark
Copy link
Member

kvark commented Mar 11, 2020

Funny how we are getting 2x more crates in the repo between 0.4 and 0.5 releases :)

@grovesNL
Copy link
Collaborator Author

It looks like bors couldn't authenticate with GitHub for some reason:

{{:badmatch,
  {:error, :post_commit_status, 401,
   "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}"}},
 [
   {BorsNG.GitHub, :post_commit_status!, 2,
    [file: 'lib/github/github.ex', line: 227]},
   {BorsNG.Worker.Batcher, :maybe_complete_batch, 1,
    [file: 'lib/worker/batcher.ex', line: 535]},
   {BorsNG.Worker.Batcher, :handle_cast, 2,
    [file: 'lib/worker/batcher.ex', line: 90]},
   {:gen_server, :try_dispatch, 4,
    [file: 'gen_server.erl', line: 637]},
   {:gen_server, :handle_msg, 6,
    [file: 'gen_server.erl', line: 711]},
   {:proc_lib, :init_p_do_apply, 3,
    [file: 'proc_lib.erl', line: 249]}
 ]}

I guess we should try again – I don't think we configure bors credentials manually anywhere.

bors retry

@bors
Copy link
Contributor

bors bot commented Mar 11, 2020

Build succeeded

@bors bors bot merged commit a74de20 into gfx-rs:master Mar 11, 2020
@grovesNL grovesNL deleted the wasm1 branch March 11, 2020 04:00
kvark added a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
514: Release version 0.6 r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
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