80: Typed mapping of buffers r=kvark a=swiftcoder
Add a sprinkling of generics to remove the need for unsafe code to typecast slices resulting from mapping buffers.
Co-authored-by: Tristam MacDonald <tristam@trist.am>
81: Buffer tracking and unmapping r=kvark a=swiftcoder
Adds preliminary transitioning of buffers to mapped state.
Adds buffer unmapping to the cube sample.
Modifies wgpu_queue_submit to not hold a write lock on the device during callbacks (this could definitely be cleaner, but I'm not sure which direction to take refactoring here).
Co-authored-by: Tristam MacDonald <tristam@trist.am>
Adds preliminary transitioning of buffers to mapped state.
Adds buffer unmapping to the cube sample.
Modifies wgpu_queue_submit to not hold a write lock on the device during callbacks.
59: Map buffers async r=kvark a=swiftcoder
This is not ready to merge. It works well enough for the example, but looking for some early feedback.
In particular:
- It's not really async, since gfx-hal's mapping APIs seem to all be immediate.
- Async callbacks in Rust are really unpleasant due to lifetimes, so maybe it's just as well they aren't async.
- There is no validation and no real error handling here yet.
Co-authored-by: Tristam MacDonald <swiftcoder@gmail.com>
71: Shadow example r=grovesNL a=kvark
~~I believe all the nuts and bolts are in place, just figuring out some details of making the shadow match between the rendering and sampling (hence the WIP).~~
Most importantly, this PR includes crucial fixes and improvements of our resource tracking, plus a few fixes in the bind group and texture creation code.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
69: Swapchain resize r=kvark a=kvark
Based on #67
Here are the steps (as outlined on Gitter) that this PR follows:
1. create a dummy frame in the swapchain (`SwapChain::outdated`). We return it when we aren't able to acquire a real frame. No synchronization is done atm, but shouldn't be anything critical there.
2. handle the errors on acquire and present, use the dummy frame where needed. Presentation errors are just ignored, while acquiring errors are forcing the dummy frame. The idea is that the user would know about a swapchain resize from some kind of event loop / WSI, and thus they'd know when they should actually re-create it.
3. associate surface with a swapchain. We merge the IDs since there can't be multiple swapchains on the same surface in the near future. Merging simplifies a lot of things in the implementation, but this is to be revised for sure once we get a better look on the browser integration.
4. when the swapchain is re-created, consume the old one associated with a surface.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
70: Allow creating a surface by passing a metal layer. r=kvark a=seivan
This is useful if you're using `SDL2`
```rust
let canvas = window.into_canvas().build().unwrap();
let metal_layer = unsafe { sdl2::sys::SDL_RenderGetMetalLayer(canvas.raw()) };
let surface = instance.create_surface_with_metal_layer(metal_layer);
```
For now, Metal only - but could be useful in the future if there was a trait or a facade to use for setting up a surface. The intention is to support other window backends without depending on them directly as a dependency.
Co-authored-by: Seivan Heidari <seivan.heidari@icloud.com>
This is useful if you're using `SDL2`
```rust
let canvas = window.into_canvas().build().unwrap();
let metal_layer = unsafe { sdl2::sys::SDL_RenderGetMetalLayer(canvas.raw()) };
let surface = instance.create_surface_with_metal_layer(metal_layer);
```
62: Separate object identity from storage r=grovesNL a=kvark
This turned out to be a giant change touching multiple parts... with main goal to prepare for wgpu-remote. The basic incompatibility I found is that the client side needs to know the IDs and manage them, while the server side needs to access the actual objects by those IDs. This change moves the `IdentityManager` out, while still making it convenient for the local bindings to use it the old way.
The actions for creating a buffer remotely would be:
1. client allocates a new ID
2. client sends the descriptor and ID to the server
3. server creates an actual backend object from the descriptor
4. server associates it with the given ID
While doing that, I also decided to bring the local/remote registries closer together. There isn't much benefit from representing an ID with a pointer in local mode. Locking is still the same (at least, it's hugely problematic to make it different and maintain both paths sanely), and the cache utilization is better when they are stored sequentially. This simplification leaded to the renaming and refactoring of "registry/mod.rs" to just "hub.rs".
Total list of changes:
- separate object identity from storage, this affects all the entry points creating items. They are now split into a public-visible "_impl()" method that just creates something, and the old creation is only visible under "local" feature now, using that helper. The sequence of actions on remote is different, as described above.
- unified local/remote registries
- "local" feature instead of "remote"
- removed blend and depth/stencil interfaces in favor of structs inside the pipeline descriptors
- pipeline descriptors are update to reflect the IDL (shader stages, rasterization state, color states, etc)
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>