Commit Graph

142 Commits

Author SHA1 Message Date
Joshua Groves
e51cce7e5d Lock cbindgen to working revision 2019-01-20 15:47:54 -07:00
bors[bot]
0f592b4443 Merge #34
34: Basic windowing and presentation r=grovesNL a=kvark

- [x] native swapchain creation
- [x] native use of frames and presentation
- [x] native semaphore waits
- [x] rust wrapping
- [x] working examples

~~I may or may not bite the bullet and update gfx-rs here. Probably not :)~~

## Architecture

There is a bit of complexity here to manage all the synchronization and lifetimes properly. Essentially, presentation is exposed in Vulkan/gfx-rs as a separate hidden queue, so we inevitably run into the territory of using semaphores for synchronization, where previously we could ignore them for workloads on a single queue.

A swapchain has a fixed (at creation) number of frames, each represented by a texture plus view pair. When `get_next_texture` is called we acquire the next image index and return this pair. We wait for the associated fence to make sure the frame is no image used. We then associate a semaphore with this index for image availability.

The texture has extra information to link back to an image of the swapchain (which is `None` for regular textures). Whenever it's used, the command buffer collects that link to be used on submission, where it's just resolved to a semaphore that we wait on actual submission.

Presenting on a swapchain creates a temporary command buffer that we only use for transiting the swapchain image into presentable state. This small submission is useful for establishing a "ready" semaphore as well as a fence (waited in `get_next_image`). The "ready" semaphore is used immediately for native `present` call.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2019-01-19 13:31:35 +00:00
Dzmitry Malyshau
5deb6e2047 DX11 support 2019-01-17 23:03:11 -05:00
Dzmitry Malyshau
2221b112c7 Fix command buffer recycling 2019-01-17 21:11:01 -05:00
Dzmitry Malyshau
c868db2cc7 Windowing in the triangle example, more presentation bits 2019-01-17 09:42:59 -05:00
Dzmitry Malyshau
e32112a89a Swapchain exposed on Rust side 2019-01-16 09:15:56 -05:00
Dzmitry Malyshau
90154fb6f5 Wait for swapchain semaphores 2019-01-16 08:56:35 -05:00
Dzmitry Malyshau
ba8828eb5b Refactor includes, collect swapchain links on RP begin 2019-01-15 09:09:29 -05:00
Dzmitry Malyshau
b67a0bee0d Prenentation logic and bits of frame synchronization 2019-01-14 16:41:14 -05:00
Dzmitry Malyshau
630e86f120 Link textures to swap chains 2019-01-14 16:09:29 -05:00
Dzmitry Malyshau
1859141a99 Rename ActiveFrame to ActiveSubmission, progress with swapchain images 2019-01-14 16:05:55 -05:00
Dzmitry Malyshau
68cacd4829 native: basic surface and swapchain creation 2019-01-14 16:03:51 -05:00
bors[bot]
2d6bc1762b Merge #35
35: Update to current version of gfx-hal r=kvark a=porky11

I'll also push the transition to rust 2018 and some cleanup soon

Co-authored-by: porky11 <krapohl.f@gmx.de>
2019-01-13 03:51:26 +00:00
porky11
1c52a10c54 remove remaining unnecessary extern crate 2019-01-12 20:19:08 +01:00
porky11
4acd1edbc3 use macro explicitly instead of using macro_use 2019-01-12 20:17:04 +01:00
porky11
b61298a884 remove some unnecessary and 2019-01-12 20:11:27 +01:00
porky11
6f3499ecae port to 2018 edition 2019-01-12 19:58:24 +01:00
porky11
a5a5b88014 use rustfmt for formatting after edits 2019-01-12 19:15:48 +01:00
porky11
6675a4d3e4 update to current version of gfx 2019-01-12 19:03:17 +01:00
bors[bot]
fa37cdc9c2 Merge #33
33: Add `repr(transparent)` to buffer usage flags r=kvark a=grovesNL



Co-authored-by: Joshua Groves <josh@joshgroves.com>
2018-12-04 18:59:26 +00:00
Joshua Groves
446fdad33e Add repr(transparent) to buffer usage flags 2018-12-03 21:21:19 -07:00
bors[bot]
1144834ba8 Merge #32
32: Improve locking safety for Registry r=grovesNL a=kvark

This isn't ideal: we shouldn't be mutably locking anything for adding/removing objects in `local` path. But at least it makes it safe, for now.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2018-12-02 03:54:19 +00:00
Dzmitry Malyshau
f4bb1903bf Fix deadlock in barrier insertion 2018-12-01 22:53:21 -05:00
Dzmitry Malyshau
d4c415f666 Improve locking safety for Registry 2018-11-27 11:06:22 -05:00
bors[bot]
c440791ab2 Merge #30
30: Fix TextureId r=kvark a=Michael-Lfx



Co-authored-by: Michael-Lai fx <cihv2@163.com>
2018-11-12 13:53:43 +00:00
Michael-Lai fx
860e68b59b
Fix TextureId 2018-11-12 21:52:36 +08:00
bors[bot]
d341ec6450 Merge #29
29: Add no_mangle to extern "C" fn r=grovesNL a=Michael-Lfx



Co-authored-by: Michael-Lai fx <cihv2@163.com>
2018-11-12 06:20:47 +00:00
Michael-Lai fx
0a4a71b345
Add no_mangle to extern "C" fn 2018-11-12 11:41:34 +08:00
bors[bot]
aab47ae499 Merge #28
28: Dependencies/makefile update r=kvark a=grovesNL

- Update gfx and add `unwrap`s for now
- Because we're not actively the allocator yet, disable rendy-memory temporarily (until the latest gfx-hal feature is merged and we can start bumping its commit number)
- Use git dependency for cbindgen until the bitflags changes are ready
- Disable C examples in root Makefile until wgpu.h generation is complete

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2018-11-11 20:55:06 +00:00
Joshua Groves
d3f8c082f1 Skip C examples for now 2018-11-11 12:44:28 -07:00
Joshua Groves
0c1cf3621a Update gfx 2018-11-11 12:36:37 -07:00
Joshua Groves
d92f222078 Use git dependency for cbindgen 2018-11-11 12:32:19 -07:00
Joshua Groves
f4cd450687 Disable rendy temporarily 2018-11-11 12:02:40 -07:00
bors[bot]
cf2e62becb Merge #27
27: Resource lifetime tracking r=grovesNL a=kvark

Fixes #26

This change ends up being much more serious and intrusive, but hopefully manage-able. The idea is that the native layer would have explicit deletion calls exposed, but would still guarantee that resources live for as long as they are used by either CPU or GPU. The device, in order to guarantee that, keeps track of resources associated with fences and walks through them for clean up.

Maintaining the actual ref-counts per object up-to-date is one of the most challenging tasks. I choose to use the existing `Stored` structure to host it, so that we are forced to clone the refcounts, and it's difficult to screw up. I still had to provide the "old" semantics under the new name of `WeaklyStored` though, and we should be careful about it.

TODO:
  - [ ] review and test
  - [x] fix transition API once more, so that command buffers are stitched properly and resources are tracked by the device
  - [ ] update the Rust layer, using RAII
  - [ ] update the examples

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2018-11-04 22:53:04 +00:00
Dzmitry Malyshau
a04df23a10 Track resources used in commands by the device 2018-11-02 22:00:11 -04:00
Dzmitry Malyshau
d597e97db8 Rewrite the consume() to use the last usage properly 2018-11-02 21:44:17 -04:00
Dzmitry Malyshau
b03d7de335 Actual cleanup of resources on submission 2018-11-02 16:45:10 -04:00
Dzmitry Malyshau
39186c9c7b Add reference counting to objects 2018-11-02 16:45:10 -04:00
bors[bot]
c1eb437b25 Merge #25
25: Proper render pass support r=grovesNL a=kvark

This PR implements the API scheme of https://github.com/gpuweb/gpuweb/pull/102 and caches both render passes and framebuffers properly in the device.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2018-10-31 12:56:54 +00:00
Dzmitry Malyshau
9aa5977c22 Bindings update with the new cbindgen 0.6.7 2018-10-30 22:02:07 -04:00
Dzmitry Malyshau
6b9be3c08e Fully adopt bitflags for ShaderStageFlags and ColorWriteFlags 2018-10-30 21:51:16 -04:00
Dzmitry Malyshau
4f07ce8248 Cache framebuffers by the Device 2018-10-30 21:23:22 -04:00
Dzmitry Malyshau
d206de2049 Use render pass cache at the begin_render_pass 2018-10-30 16:47:44 -04:00
Dzmitry Malyshau
fee276afa5 Cache render passes on Device level 2018-10-30 16:37:36 -04:00
bors[bot]
5dcfd2bd6e Merge #24
24: Actually begin render passes r=grovesNL a=kvark

For now, we create the render pass and the frame buffer in place. Of course, we'd need to cache it properly, but this is blocked on W3C discussions on the API side.

With this PR, the Rust example is able to create a texture and run a render pass on it, all without a single Vulkan validation error 🎉 

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2018-10-28 22:22:49 +00:00
Dzmitry Malyshau
f3cfd2e09c Transition between command buffers 2018-10-26 22:15:48 -04:00
Dzmitry Malyshau
879cd64b30 Texture view creation in Rust and the example 2018-10-26 12:04:20 -04:00
Dzmitry Malyshau
1137ad2f70 native: Texture view creation 2018-10-26 11:47:01 -04:00
Dzmitry Malyshau
ef4ee9c29d Expose create_texture in Rust 2018-10-25 22:35:52 -04:00
Dzmitry Malyshau
de4f2b70eb Framebuffer creation and actual begin_render_pass 2018-10-25 22:29:27 -04:00