Commit Graph
100 Commits
Author SHA1 Message Date
Dzmitry Malyshau 686b4f71a6 Update wgpu and use write_texture 2020-05-26 10:10:32 -04:00
Dzmitry Malyshau 28c826182f Update wgpu and use write_buffer in the examples 2020-05-14 10:12:47 -04:00
Paul Kernfeld 1172a186b1 Add Buffer.slice fn for #199
This fn is used for set_index_buffer, set_vertex_buffer, and
BindingResource
2020-05-10 17:37:19 -04:00
bors[bot]andkyren 9f19533462 Merge #272
272: Force the wasm32 types to match Send / Sync with the native types r=kvark a=kyren

This is potentially a controversial change so this is just a draft to discuss it.

Currently, when building wgpu on wasm32, none of the interface types are Send or Sync, whereas on any other platform they are generally Send and Sync and this can cause a lot of pain, especially in the presence of async.

This PR is the nuclear option: lie and forcibly declare nearly all interface types to be Send or Send + Sync.

I think I understand the situation with proposed wasm32 threading a bit better now, and as of right now at least with my current understanding, it seems to me unlikely that javascript values held by rust could *ever* be sent transparently to another worker.  The mechanism that rust apparently will use to implement transparent threading will be to use `SharedArrayBuffer` to share memory between multiple workers.  Javascript provides a way for certain (serializable) objects to be shared with with other workers through `worker.postMessage()`, so Javascript has *some* story for sending javascript values to other threads, but only plain rust values that exist solely in the `SharedArrayBuffer` memory are send-able under this scheme.  I've looked briefly through some of the wasm proposals like the interface types proposal, but I don't have a good sense if there's any proposed mechanism at all for interface types and threads to interact at all.

If that's true that's really unfortunate because it seems like any thread safe API shared by native and web is doomed to mismatch.  This is even more unfortunate because many of the webgpu types in the draft standard are marked as 'Serializable', meaning that they *are* actually safe to send to another worker via `postMessage`, but there does not appear to be a planned way for rust to do this transparently.

I definitely could be misunderstanding the situation though and even if I am understanding it, the situation may have since changed.  I also don't know the timing here, I don't know what the eventual timing of wasm32 threading support will be vs webgpu support and interface types support.  *Right now* this PR is almost certainly sound, but there's definitely a possible future where it becomes unsound, and even maybe a possible future where it becomes unsound but then could later be made sound again.

Co-authored-by: kyren <kerriganw@gmail.com>
2020-05-07 04:09:14 +00:00
kyren c37a3233e9 Force the wasm32 types to match Send / Sync with the native types
There are several things in this commit:

1) Add `Send` or `Send + Sync` bounds to most of the associated types in `Context`.
2) Force most of the handle types and future types returned by the web backend to be Send / Sync
3) Make `BufferReadMapping` and `BufferWriteMapping` `Send` again on native by
   making the associated detail types implement `Send`.
2020-05-06 23:02:27 -04:00
Dzmitry Malyshau f3ff8d33ae Update wgpu with the BGL fix 2020-05-05 00:04:24 -04:00
Dzmitry Malyshau 4413c4648d Update for wgpu-core 2020-04-30 15:52:16 -04:00
Dzmitry Malyshau e30a428190 Port the Web backend to the Context trait 2020-04-26 19:18:24 -04:00
Dzmitry Malyshau 0d85635008 Move everything into Context trait, remove async 2020-04-26 19:18:24 -04:00
Dzmitry Malyshau ba95354734 Rewire the backend system to remove wgpu-native step
Main change here is the introduction of the Context trait.
The "direct" implementation of it goes straight to wgpu-core.

This commit also has small improvements:
- consuming command buffers on submit
- Instance type
- proper call to destructors
2020-04-26 19:18:24 -04:00
Aron Granberg 567cb16f7c Improve docs for BindingType 2020-04-22 15:07:11 +02:00
Joshua Groves d1197c0c2e Fix some remaining TODOs in the web backend 2020-04-18 01:04:28 -02:30
Joshua Groves 643481ed81 Expose more functions on the web backend 2020-04-18 01:04:28 -02:30
Joshua Groves bf49c1a4f1 Update to latest winit and wasm-bindgen 2020-04-18 01:04:28 -02:30
Joshua Groves b34c0af749 Only expose adapter info on native 2020-04-18 01:04:28 -02:30
Joshua Groves a6473b52b9 Get capture mostly working
`File::create` isn't available on wasm, so we can't actually write the
output image anywhere unless we target something else as the file
system (e.g. local storage)
2020-04-18 01:04:28 -02:30
Joshua Groves 2829bd3f00 Get skybox working 2020-04-18 01:04:28 -02:30
Joshua Groves 7a6fab83c4 Get cube working 2020-04-18 01:04:28 -02:30
Joshua Groves e1eaa6ca26 Add web backend 2020-04-18 01:04:28 -02:30
StarToaster 40a19ebe66 Removed zerocopy and replaced it with bytemuck. 2020-04-17 10:07:24 -04:00
Dzmitry Malyshau 1678a267cb Update wgpu for texture descriptor changes 2020-04-14 01:13:47 -04:00
bors[bot]andLachlan Sneff 1c1dc8c573 Merge #254
254: Specify expected structure for draw_indirect and draw_indexed_indirect r=kvark a=lachlansneff

~~Based on https://www.khronos.org/opengl/wiki/Vertex_Rendering#Indirect_rendering.~~ Turns out the opengl docs are wrong. Based on https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDrawIndirectCommand.html.

Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
2020-04-12 16:14:15 +00:00
Lachlan Sneff 0025ca0d34 Fix documentation based on vulkan docs 2020-04-12 10:56:15 -04:00
Lachlan Sneff 496d25db69 Specified expected structure for draw_indirect and draw_indexed_indirect 2020-04-11 23:33:31 -04:00
Hackpoetic a6e81dc703 cargo fmt the code and tweak format rules 2020-04-10 22:56:24 -04:00
bors[bot]andJoshua Groves 2ea2572905 Merge #249
249: Derive `Default` for `CommandEncoderDescriptor` r=kvark a=grovesNL

Fixes #243

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-04-09 13:29:16 +00:00
Héctor Ramón Jiménez 0f2bc33b7f Fix RenderPass::set_vertex_buffer doc link 2020-04-09 06:07:20 +02:00
Joshua Groves 64b765947a Derive Default for CommandEncoderDescriptor 2020-04-09 00:55:45 -02:30
Dzmitry Malyshau 0f71647c1a Update to wgpu-core with Option<Id> 2020-04-04 23:32:37 -04:00
William Lundstedt 4c85a733ec Implement Send and Sync for BufferReadMapping and BufferWriteMapping 2020-04-03 14:59:09 +02:00
Dzmitry Malyshau b93e942b58 Update to latest wgpu, duplicate RequestAdapterOptions 2020-04-02 00:29:24 -04:00
Joshua Groves 31e80d99b3 Update to latest wgpu 2020-03-30 07:58:06 -04:00
aloucks d91b78bdfb Add VertexStateDescriptor (#221)
The vertex state properties are now bundled in the VertexStateDescriptor
which matches the spec.

Fixes #220
2020-03-28 10:45:18 -04:00
Lachlan Sneff ea6bcd03e2 Rewrite GpuFuture to avoid blocking and to use less space
Remove odd patching matching

Replace std::sync::Mutex with spin::Mutex in GpuFuture

Reduce GpuFuture usage to one explicit allocation instead of two

Fix examples to poll the device in the background when using map_read or map_write

Remove device.poll from GpuFuture::poll and document future invariants

Massively simplify examples

Use Arc::clone(...) instead of arc.clone()

Switch println to log::info
2020-03-27 00:16:35 -04:00
Lachlan Sneff 12fcdb6671 Cleanup user-interface around async buffer mapping 2020-03-23 00:07:54 -04:00
bors[bot]andAaron Loucks 7b15e24eae Merge #210
210: Update WGPU deps to rev 08e8d406c1 r=kvark a=aloucks

I also moved the `path` chunks in `Cargo.toml` to a single `[patch]` section so that it's one block to commment/uncomment for local development. 

Co-authored-by: Aaron Loucks <aloucks@cofront.net>
2020-03-23 01:03:33 +00:00
Rukai 111f6c4f75 Improve BufferCopyView documentation 2020-03-22 23:24:43 +11:00
Aaron Loucks 277505e9c9 Update WGPU deps to rev 08e8d406c1 2020-03-20 21:48:25 -04:00
Lachlan Sneff dcccbd8107 Note that get_next_texture will error if a previous output is still alive. 2020-03-20 14:34:17 -04:00
Lachlan Sneff 4618852f88 Remove lifetime from SwapChainOutput 2020-03-19 11:43:38 -04:00
Joshua Groves b3e4253df1 Return futures from request adapter/request device 2020-03-16 16:35:51 -02:30
Joshua Groves d1371dbe37 Remove Hash for ID types 2020-03-16 08:53:51 -02:30
bors[bot]andmitchmindtree a96a5faa24 Merge #200
200: Derive `Hash` and `PartialEq` for unique identifier wrapper types r=kvark a=mitchmindtree

This is particularly useful downstream for distinguishing between
instances of these types.

I was unsure about `Device` as I noticed it has a `Temp` field that
looks like it might eventually store some non-PartialEq/Hash-friendly
fields.

Let me know if you'd like me to add a derive for `Device` or if there
are any issues with those I have updated.

Co-authored-by: mitchmindtree <mitchell.nordine@gmail.com>
2020-03-15 23:18:13 +00:00
Aaron Loucks 2425312660 Add note that slot refers to the index in RenderPipelineDescriptor::vertex_buffers
Also fixed intra-doc links for `set_vertex_buffer`.
2020-03-15 15:38:31 -04:00
mitchmindtree cf5fcc4037 Derive Hash and PartialEq for unique identifier wrapper types
This is particularly useful downstream for distinguishing between
instances of these types.

I was unsure about `Device` as I noticed it has a `Temp` field that
looks like it might eventually store some non-PartialEq/Hash-friendly
fields.

Let me know if you'd like me to add a derive for `Device` or if there
are any issues with those I have updated.
2020-03-15 18:43:16 +01:00
Dzmitry Malyshau d842432d17 Update for the latest spec changes 2020-03-15 11:25:06 -04:00
Aaron Loucks 89fda33142 Reexport Backend and DeviceType from wgpu-core
These types are exposed on the `AdaptorInfo` struct.
2020-03-04 22:22:26 -05:00
daxpedda a9c7a0f5ef Expose enumerate_adapters. 2020-02-26 16:35:31 +01:00
Diggory Hardy dca51ce676 Add vertex_attr_array macro 2020-02-20 09:32:38 +00:00
Dzmitry Malyshau 17214fe986 wgpu update with DynamicOffset 2020-02-16 21:49:56 -05:00