Commit Graph

114 Commits

Author SHA1 Message Date
kyren
42de0b2769 Properly honor mapped_at_creation in Device::create_buffer
The returned `Buffer` should immediately be mappable.  Fixes #351
2020-06-06 15:55:15 -04:00
Rukai
f6123e4fe8 Add aribitrary texture size handling to the capture example 2020-06-06 14:56:08 +10:00
Connor Fitzgerald
cf9d9d6656 Rustify the example's use of Extensions and SamplerDescriptor 2020-06-02 21:44:07 -04:00
Dzmitry Malyshau
63219a5a85 Use the new map-async 2020-06-02 14:23:34 -04:00
Dzmitry Malyshau
ac6f79cb72 Read-only depth-stencil support 2020-06-01 20:25:01 -04:00
Connor Fitzgerald
c4819ccf7d Add Extension/Limit interface 2020-06-01 13:08:56 -04:00
AlphaModder
91d46ecc2b Rename SwapChain::get_next_texture to SwapChain::get_next_frame, and have it return errors to the user. 2020-05-30 18:41:31 -07:00
Marvin Löbel
dd087b810e Add equality derives to BindGroupLayoutEntry 2020-05-29 22:55:21 +02:00
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]
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
7147340595 Free pass contents 2020-05-05 21:55:25 -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
b7883e485c Small comment on WebGPU backend bit, readme update 2020-04-27 00:11:22 -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
9952801e2f Add labels to mapped descriptors where possible 2020-04-18 01:04:28 -02:30
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
8ee80efe59 Get shadow mostly working
Some of the implementation is still missing in Canary
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]
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]
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]
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