Commit Graph

356 Commits

Author SHA1 Message Date
Lachlan Sneff
d9ecab0cdc Fix buffer mapping examples 2020-06-11 12:07:47 -04:00
bors[bot]
b1f3fbaab0 Merge #356
356: Add generic ranges to buffer mapping api and make it safe. r=kvark a=lachlansneff

[Rendered](https://charted.space/notes/wgpu-rs/wgpu/struct.Buffer.html)

The safety issues with the current api (being able to unmap while still holding a slice to mapped data) are fixed by having `get_mapped_range` and `get_mapped_range_mut` return `BufferView` and `BufferViewMut`, which notify the buffer that those ranges are no longer being used when they're dropped. `Buffer.unmap` asserts that the list of mapped ranges is empty, therefore it is safe.

Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
2020-06-10 17:46:36 +00:00
Lachlan Sneff
35dd34b4ec Add BufferView and BufferViewMut and fix safety issues with mapped range. 2020-06-09 20:03:28 -04:00
bors[bot]
7b866b1a1b Merge #354
354: Update to wgpu with shader validation r=cwfitzgerald a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/705

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-06-09 01:04:24 +00:00
Dzmitry Malyshau
9259d2e51d Update to wgpu with shader validation 2020-06-08 20:54:39 -04:00
bors[bot]
092d5bb6fd Merge #350
350: Implement Extensions Interface r=kvark a=cwfitzgerald

This implements https://github.com/gfx-rs/wgpu/pull/703 in wgpu-rs. Notable changes include the removal of the anisotropic field from the examples, in favor of the now mandatory `..Default::default()` syntax.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-06-08 05:21:23 +00:00
Connor Fitzgerald
b71c420f7a Implement extensions interface as described in wgpu#691 2020-06-08 01:20:00 -04:00
bors[bot]
45b79a21f1 Merge #353
353: Properly honor `mapped_at_creation` in `Device::create_buffer` r=cwfitzgerald a=kyren

The returned `Buffer` should immediately be mappable.  Fixes #351

Co-authored-by: kyren <kerriganw@gmail.com>
2020-06-06 21:15:07 +00:00
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
bors[bot]
d06470ea1e Merge #348
348: Add aribitrary texture size handling to the capture example r=me a=rukai

* User can specify width + height via arguments.
* Defaults to (100, 200) when no arguments. Odd values chosen to make it more likely to pick up issues when testing.
* Converts from bgra as I believe that is the most commonly supported format for swapchains?

Co-authored-by: Rukai <rubickent@gmail.com>
2020-06-06 04:57:59 +00:00
Rukai
f6123e4fe8 Add aribitrary texture size handling to the capture example 2020-06-06 14:56:08 +10:00
bors[bot]
b8bb84ac8f Merge #346
346: Add Makefile for shader compilation r=kvark a=HanKruiger

I couldn't find clear instructions on how to compile the shaders in the examples, and had to do some digging. So I added instructions to the README to hopefully save other people's time.

Sidenote: When I compile the shaders as they are now (with my instructions), I end up with different `.spv` shaders with (seemingly) equivalent behaviour. I expect this is due to a different version/environment of `glslang` (see below) but it could be a mistake on my part.

```
> glslangValidator --version        
Glslang Version: 8.13.3743
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 13.3743
GLSL Version: 4.60 glslang Khronos. 13.3743
SPIR-V Version 0x00010500, Revision 3
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 8
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100
```

Cheers!

Co-authored-by: Han Kruiger <HanKruiger@users.noreply.github.com>
2020-06-04 15:20:08 +00:00
Han Kruiger
bb164c279c Add makefile for shader compilation
Add example shader compilation instructions

Arbitrary depth directory wildcard like globs aren't a thing in make wildcards.

Add phony targets as prerequisites of .PHONY
2020-06-04 17:15:51 +02:00
bors[bot]
ff41d31200 Merge #347
347: Add User Matrix Link r=kvark a=cwfitzgerald

https://github.com/gfx-rs/wgpu/pull/698 but rusty.

Separated on a separate line, as it would otherwise wrap in an ugly way with the image.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-06-03 20:47:12 +00:00
Connor Fitzgerald
74e5d7d29c Add User Matrix Link 2020-06-03 16:40:43 -04:00
bors[bot]
231110fd2b Merge #345
345: Rustify the example's use of Extensions and SamplerDescriptor r=kvark a=cwfitzgerald

Implements https://github.com/gfx-rs/wgpu/pull/696.

This didn't change any content from #338, just interface, but I tested a couple examples and it seems to work okay.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-06-03 01:52:53 +00:00
Connor Fitzgerald
cf9d9d6656 Rustify the example's use of Extensions and SamplerDescriptor 2020-06-02 21:44:07 -04:00
bors[bot]
2370602b26 Merge #344
344: Use the new map-async r=kvark a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/675
It changes the API of mapping and removes `create_buffer_mapped`.
The new functionality is not implemented in Gecko yet, so this breaks the web target, for now.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-06-02 18:24:02 +00:00
Dzmitry Malyshau
63219a5a85 Use the new map-async 2020-06-02 14:23:34 -04:00
bors[bot]
73efa5f66b Merge #340
340: Read-only depth-stencil support r=kvark a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/685

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-06-02 00:25:50 +00:00
Dzmitry Malyshau
ac6f79cb72 Read-only depth-stencil support 2020-06-01 20:25:01 -04:00
bors[bot]
50d1eb6465 Merge #338
338: Add Extension/Limit Interface r=kvark a=cwfitzgerald

Follow up to https://github.com/gfx-rs/wgpu/pull/690.

This forwards the extension/limit access interface into wgpu-rs.

It appears that the web-sys doesn't actually implement any of the methods we need, so I had them return the defaults. `Device::limits` exists, but it returns `Object` not `GpuLimits`, so doesn't appear usable.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-06-01 17:19:04 +00:00
Connor Fitzgerald
c4819ccf7d Add Extension/Limit interface 2020-06-01 13:08:56 -04:00
bors[bot]
d7abf5c38a Merge #336
336: Update wgpu dependency r=kvark a=kvark

Includes a fix to #333

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-05-31 16:26:53 +00:00
Dzmitry Malyshau
5fdbd7a5ed Update wgpu dependency 2020-05-31 12:24:41 -04:00
Dzmitry Malyshau
bc07717f77 Enable X11 in Vulkan (#335)
* Enable X11 in Vulkan

* Fix Cargo comments
2020-05-31 11:40:33 -04:00
bors[bot]
0c69bdd850 Merge #323
323: Rename SwapChain::get_next_texture to SwapChain::get_next_frame, and return errors to the user. r=kvark a=AlphaModder

Depends on https://github.com/gfx-rs/wgpu/pull/668.

This creates a new type `SwapChainResult` just for the method. 
It also alters the signature of `Context::swap_chain_get_next_texture` to return 
```rust
(Option<Self::TextureViewId>, wgt::SwapChainStatus, Self::SwapChainOutputDetail)
```
which is a little ugly but I couldn't think of anything better. 

Co-authored-by: AlphaModder <quasiflux@gmail.com>
2020-05-31 05:19:03 +00: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
bors[bot]
e371a2e1b7 Merge #330
330: Add equality derives to `BindGroupLayoutEntry` r=kvark a=Kimundi



Co-authored-by: Marvin Löbel <loebel.marvin@gmail.com>
2020-05-29 21:03:01 +00:00
Marvin Löbel
dd087b810e Add equality derives to BindGroupLayoutEntry 2020-05-29 22:55:21 +02:00
bors[bot]
d12d1422a7 Merge #321
321: Update wgpu and use write_texture r=grovesNL a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/666

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-26 14:15:51 +00:00
Dzmitry Malyshau
686b4f71a6 Update wgpu and use write_texture 2020-05-26 10:10:32 -04:00
bors[bot]
4b16959e3e Merge #320
320: Fix typo in Friends section of README r=kvark a=jakbyte



Co-authored-by: jakbyte <jakbyte@protonmail.com>
2020-05-23 15:01:49 +00:00
jakbyte
b04f8ef3ac Fix typo in Friends section of README 2020-05-22 17:24:39 -04:00
bors[bot]
143861d361 Merge #315
315: Update wgpu-core rev r=urgent a=kvark

Fixes #314 

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-18 16:11:53 +00:00
Dzmitry Malyshau
2b9beebd3e Update wgpu-core rev 2020-05-18 12:11:02 -04:00
bors[bot]
c830faa06b Merge #311
311: Read WGPU_TRACE environment in the examples r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-05-15 21:50:15 +00:00
Dzmitry Malyshau
1e722a557e Read WGPU_TRACE environment in the examples 2020-05-15 17:49:16 -04:00
Dzmitry Malyshau
4cc94fe58e Disable GHA deploy temporarily 2020-05-14 10:12:47 -04:00
Dzmitry Malyshau
28c826182f Update wgpu and use write_buffer in the examples 2020-05-14 10:12:47 -04:00
bors[bot]
c14c8e0830 Merge #306
306: Improve example friendliness: Don't busy-redraw in examples r=kvark a=khoek

Looking around for solid Rust graphics libraries, I was a bit shocked when the `wgpu-rs` examples made my whole X desktop environment in Ubuntu laggy---maximizing/minimizing other windows or moving any of them had very noticeable latency when an example was running.

This almost turned me off, but after playing around I found that this was just because of the
```rust
match event {
            event::Event::MainEventsCleared => window.request_redraw(),
            ...
```
in all of the examples. Trying to add the least code possible I've replaced a `ControlFlow::Poll` with `ControlFlow::WaitUntil(...)` in the event loops and capped the redraws-per-second below 50, which completely solves this problem for me (plus the window resize response on the examples themselves are much improved, etc.).

I was just going for an unintrusive fix---this is by no means a perfect solution, but I think in the worst case it won't be any worse that what was there originally. Plus, I think it will make people like me who try to start by copying an example more likely to stick around in the short term.

Co-authored-by: Keeley Hoek <keeley@hoek.io>
2020-05-11 21:35:47 +00:00
Keeley Hoek
ab2f1c7d03 Don't busy-redraw in examples 2020-05-12 03:20:19 +10:00
bors[bot]
9c1e6b8611 Merge #302
302: Add BufferRange struct for #199 r=kvark a=paulkernfeld

- Use in set_index_buffer
- Use in set_vertex_buffer
- Use in BindingResource

Co-authored-by: Paul Kernfeld <paulkernfeld@gmail.com>
2020-05-10 21:50:06 +00: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
bors[bot]
89ee5bffd3 Merge #300
300: Properly free pass contents r=kvark a=kvark

Fixes #299

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-05-06 01:56:54 +00:00
Dzmitry Malyshau
17b46687ce Rustfmt pass on examples 2020-05-05 21:55:42 -04:00
Dzmitry Malyshau
7147340595 Free pass contents 2020-05-05 21:55:25 -04:00
bors[bot]
c5b14235d4 Merge #298
298: Added a screenshot for harmony. r=kvark a=StarArawn



Co-authored-by: John Mitchell <john.mitchell@mangolanguages.com>
2020-05-05 16:05:05 +00:00