-
Notifications
You must be signed in to change notification settings - Fork 186
Conversation
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.
It's both sad and relieving that we can't use a trait:
- sad because it's harder to guarantee the implementations match perfectly
- relieving because the users don't need to suffer :)
And now hello-triangle is able to run on the web too: (it's upside-down due to gfx-rs/wgpu#519) |
@@ -60,7 +62,7 @@ async fn run() { | |||
}), | |||
primitive_topology: wgpu::PrimitiveTopology::TriangleList, | |||
color_states: &[wgpu::ColorStateDescriptor { | |||
format: wgpu::TextureFormat::Bgra8UnormSrgb, | |||
format: wgpu::TextureFormat::Bgra8Unorm, |
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.
Oh interesting. Is it now the case that Bgra8Unorm
is assumed to be sRGB?
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.
Nope both Bgra8Unorm
and Bgra8UnormSrgb
still exist – this is just a temporary hack for the hello-triangle example because Chrome Canary didn't seem to allow me to use Bgra8UnormSrgb
for the swapchain :) I haven't looked into it yet but a swapchain with Bgra8UnormSrgb
is supposed to work fine in browsers as far as I know.
f33513d
to
4c2744b
Compare
If you want to use async traits there is async-trait. Supports a wide range of usecases but has it's limitations. |
1565ef7
to
4545236
Compare
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 is autogenerated code-style review, new suggestions: 14
All examples are available at http://joshgroves.com/gfx/wgpu/examples/?example=hello-triangle for now. Each example is built in Both Chrome Canary and Firefox Nightly have issues running all examples at the moment, but eventually all examples should work fine 🤞 |
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 is autogenerated code-style review, new suggestions: 14
No luck on Safari here either. |
@expenses I also forgot to mention that these examples are currently using SPIR-V, which won't work in Safari. We'll eventually need to support WGSL here, which will allow Safari to run them (once WebGPU support is ready in Safari in general) |
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 is autogenerated code-style review, new suggestions: 4
bors r=kvark |
@kvark I need to merge this manually due to https://forum.bors.tech/t/resource-not-accessible-by-integration/408/3 – I'm updating the CI actions but bors isn't allowed to merge those changes |
🎉 |
For anyone interested in continuing to follow the progress here, I'll keep updating the examples at http://joshgroves.com/gfx/wgpu/examples/. Some of the recent fixes from @kvark should be landing in Firefox Nightly soon (enable WebGPU using the instructions above) which should get most of these examples working. |
Should |
@Keavon yeah, we should be able to remove that and clarify that both native and wasm are supported now 👍 Would you like to submit a PR to update it? |
I haven't been following this closely enough to know what would be most appropriate to write so I'd probably feel better not doing the PR myself. |
Maybe we could replace it with something like
|
This branch has a bunch of WIP changes as I work through #101
The branch is still very unstable but any feedback about the approach so far would be great.
I tried to use a backend trait initially (with associated types and functions) but it didn't work great here. For example,
async fn
can't be used on traits yet.Instead, with the current approach we have to manually ensure that all type signatures match. This seems mostly ok because we wrap most types/functions in wgpu-rs anyway, but we do have to be careful wherever we directly expose types. For example, if an exposed type is
Copy
in one backend and not the other, we'd probably have to newtype them (probably relevant for all of theXyzId
types).