Commit Graph

359 Commits

Author SHA1 Message Date
bors[bot]
55eec80920 [rs] Merge #360
360: Implement TEXTURE_BINDING_ARRAY extension r=kvark a=cwfitzgerald

This extends https://github.com/gfx-rs/wgpu/pull/711 into wgpu-rs.

Notable changes: 
- Added an example showing off both this extension and the future descriptor indexing extension.
- Changed the framework so there is a static function showing what extensions you need. This is provided by the trait,, which defaults to no extensions, so existing examples and new ones don't have to care about extensions.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-06-11 20:37:46 +00:00
Connor Fitzgerald
200025e3cc [rs] Implement TEXTURE_BINDING_ARRAY extension 2020-06-11 16:36:53 -04:00
bors[bot]
9842d2065f [rs] Merge #366
366: Fix buffer mapping examples r=cwfitzgerald a=lachlansneff

Fixes #364 

Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
2020-06-11 16:09:55 +00:00
Lachlan Sneff
5216fd3285 [rs] Fix buffer mapping examples 2020-06-11 12:07:47 -04:00
bors[bot]
031f6f58c5 [rs] 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
785f26bab3 [rs] Add BufferView and BufferViewMut and fix safety issues with mapped range. 2020-06-09 20:03:28 -04:00
bors[bot]
72eb0c7450 [rs] 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
30c8b64883 [rs] Update to wgpu with shader validation 2020-06-08 20:54:39 -04:00
bors[bot]
5f567e227a [rs] 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
28c0b8f3a3 [rs] Implement extensions interface as described in wgpu#691 2020-06-08 01:20:00 -04:00
bors[bot]
e655053b56 [rs] 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
cb6931f87b [rs] 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]
8e96559672 [rs] 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
9f7775f98c [rs] Add aribitrary texture size handling to the capture example 2020-06-06 14:56:08 +10:00
bors[bot]
50cd507ca1 [rs] 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
969642cb75 [rs] 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]
8fedb8e9bc [rs] 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
028f7a2003 [rs] Add User Matrix Link 2020-06-03 16:40:43 -04:00
bors[bot]
d8e8268392 [rs] 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
ed17f0abbb [rs] Rustify the example's use of Extensions and SamplerDescriptor 2020-06-02 21:44:07 -04:00
bors[bot]
94c262642f [rs] 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
3138509e56 [rs] Use the new map-async 2020-06-02 14:23:34 -04:00
bors[bot]
5514ac149f [rs] 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
197f4f943e [rs] Read-only depth-stencil support 2020-06-01 20:25:01 -04:00
bors[bot]
7699f1b3c7 [rs] 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
60260ffcdc [rs] Add Extension/Limit interface 2020-06-01 13:08:56 -04:00
bors[bot]
2d53aaa9c1 [rs] 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
fb938c222b [rs] Update wgpu dependency 2020-05-31 12:24:41 -04:00
Dzmitry Malyshau
d3fcd4711c [rs] Enable X11 in Vulkan (#335)
* Enable X11 in Vulkan

* Fix Cargo comments
2020-05-31 11:40:33 -04:00
bors[bot]
d065ecffe7 [rs] 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
c538a53cf0 [rs] 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]
f0ccd9d81f [rs] 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
de5ef8f1f2 [rs] Add equality derives to BindGroupLayoutEntry 2020-05-29 22:55:21 +02:00
bors[bot]
605fe735b6 [rs] 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
09d8e4b64c [rs] Update wgpu and use write_texture 2020-05-26 10:10:32 -04:00
bors[bot]
bd4804b88a [rs] 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
239be51348 [rs] Fix typo in Friends section of README 2020-05-22 17:24:39 -04:00
bors[bot]
d8e2f384f3 [rs] 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
0b124826a4 [rs] Update wgpu-core rev 2020-05-18 12:11:02 -04:00
bors[bot]
9691649fc5 [rs] 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
07fb340ec4 [rs] Read WGPU_TRACE environment in the examples 2020-05-15 17:49:16 -04:00
Dzmitry Malyshau
cfd17fdcbd [rs] Disable GHA deploy temporarily 2020-05-14 10:12:47 -04:00
Dzmitry Malyshau
c548050b47 [rs] Update wgpu and use write_buffer in the examples 2020-05-14 10:12:47 -04:00
bors[bot]
fe904b0706 [rs] 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
469b416632 [rs] Don't busy-redraw in examples 2020-05-12 03:20:19 +10:00
bors[bot]
1de6a6c084 [rs] 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
445786d474 [rs] 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]
c985df9fc8 [rs] 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
a3e6e1024f [rs] 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]
8e2486f172 [rs] 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