Commit Graph

3316 Commits

Author SHA1 Message Date
Connor Fitzgerald
ebf049bcee
Adjust limits for WARP on CI 2021-07-29 09:24:07 -04:00
Connor Fitzgerald
3c8de92ba0
Run reftests on WARP 2021-07-29 09:24:03 -04:00
bors[bot]
c1a305c006
Merge #1744
1744: hal/dx12: fix depth formats and pipeline layout r=kvark a=kvark

**Connections**
Closes #1727

**Description**
There were 2 problems. One was that the reversing of the pipeline layout was done wrong (again). I don't know how it still worked on one of my machines :/
The other was that the backend relied on the depth format reinterpretation without using a typeless format. This is OK on higher-level platforms, but we should be doing it more careful. I tried to approach this maximally efficient: we only use the typeless format if all of the following are true:
  1. it's a depth/stencil format
  2. it needs to be seen as SRV/UAV

So in the case of a simple depth texture, we are still going to be using a fully-qualified format, and therefore get all of the benefit of HW compression on it.

**Testing**
Ran the examples on Intel


Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2021-07-29 05:15:43 +00:00
Dzmitry Malyshau
3a004ecf9a hal/dx12: fix depth formats and pipeline layout 2021-07-29 01:13:37 -04:00
bors[bot]
b79c910b0f
Merge #1741
1741: Improve Docs for DownlevelFlags r=cwfitzgerald a=zicklag

**Connections**
None

**Description**
Clarifies the documentation on the `DownlevelFlags`, and wraps the documentation of some of the flags to 100 chars.

**Testing**
Tested on Ubuntu 20.04


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-29 00:05:59 +00:00
Zicklag
88c58d2b20 Improve Docs for DownlevelFlags 2021-07-28 19:00:43 -05:00
bors[bot]
258e685ecb
Merge #1742
1742: Mention WGPU_ADAPTER_NAME Env Var in WGPU README r=cwfitzgerald a=zicklag

**Connections**
None

**Description**
Mentions the new `WGPU_ADAPTER_NAME` environment variable in the WGPU readme.

**Testing**



Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-28 20:13:58 +00:00
Zicklag
89b1dbcb5a Mention WGPU_ADAPTER_NAME Env Var in WGPU README 2021-07-28 14:08:44 -05:00
bors[bot]
efba648c35
Merge #1737
1737: Use Bitshift Style for All Bitflag Consts r=cwfitzgerald a=zicklag

**Connections**
None exactly, but somewhat related to https://github.com/gfx-rs/wgpu/pull/1686 as I was going to put some of this change into that PR, but am splitting it out for ease of review.

**Description**
This is purely code-style related, but it makes it easier to read bitflag constants and much eaiser to add bitflags in the future.

**Testing**
Tested on Ubuntu 20.04


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-28 16:31:50 +00:00
Zicklag
fd460fa1e4 Use Bitshift Style for All Bitflag Consts
This makes existing bitflags easier to read and makes it eaiser to add
new flags later.
2021-07-28 11:28:54 -05:00
bors[bot]
b8d5c9d9ac
Merge #1738
1738: Rename texture usage names according to binding r=kvark a=kvark

**Connections**
Matches https://github.com/gpuweb/gpuweb/pull/1989

**Description**
The `SAMPLED` usage name was confusing because integer and MSAA textures can't be sampled (with a sampler), but fetching data from them is under this usage.

**Testing**
No need


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-28 04:22:21 +00:00
Dzmitry Malyshau
552a5f138e Rename texture usage names 2021-07-28 00:17:54 -04:00
bors[bot]
5c2461fd53
Merge #1722
1722: Document coordinate systems in README r=cwfitzgerald a=MichaelMMacLeod

I had to do a bit of digging to find information about coordinate systems in
wgpu (asking on Matrix). This commit adds a table of coordinate systems to help
clarify the issue.

The table comes from the DX12 backend documentation of gfx-rs:
https://github.com/gfx-rs/gfx/tree/master/src/backend/dx12

**Connections**
(none)

**Description**
It was difficult for me to find information about what coordinate systems wgpu uses. This commit addresses this issue by adding documentation about wgpu's coordinate systems to the README.

**Testing**
This is purely a documentation change (I have written no tests).

If you want to see how the table looks on Github, check out my fork at https://github.com/MichaelMMacLeod/wgpu/tree/add-coords-to-readme


Co-authored-by: Michael MacLeod <michaelmmacleod@gmail.com>
2021-07-28 03:51:16 +00:00
bors[bot]
451cd217bb
Merge #1729
1729: Handle Multi-threaded EGL Context Access r=cwfitzgerald,kvark a=zicklag

**Connections**
https://github.com/gfx-rs/wgpu/discussions/1630, https://github.com/bevyengine/bevy/issues/841

**Description**
Implements the synchronization necessary to use the GL backend from multiple threads. Accomplishes this by using a mutex around the GL context with extra wrapping to bind and unbind the EGL context when locking and unlocking.

**Testing**
Tested on Ubunty 20.04 with a fork of the Bevy game engine and the WGPU examples ( not that the examples test the multi-threading ).

## Remaining Issues

There is only one Bevy example I cannot get to run yet and it's the `load_gltf` example. It fails with a shader translation error:

```
Jul 26 20:36:50.949 ERROR naga:🔙:glsl: Conflicting samplers for _group_3_binding_10    
Jul 26 20:36:50.950  WARN wgpu::backend::direct: Shader translation error for stage FRAGMENT: A image was used with multiple samplers    
Jul 26 20:36:50.950  WARN wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga    
Jul 26 20:36:50.950 ERROR wgpu::backend::direct: wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
    Internal error in FRAGMENT shader: A image was used with multiple samplers
```

Interestingly, I think the shader in question doesn't have a `group(3), binding(10)` anywhere that I know of so I'm going to have to drill down a bit more and find out exactly which shader translation is failing more.

This could potentially be fixed in a separate PR. I think the rest of this PR is rather straight-forward and the fix for the error above is probably mostly unrelated to the primary changes made in this PR.

Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-27 19:43:12 +00:00
Zicklag
671e393fa1 Handle Multi-threaded EGL Context Access
Implements the synchronization necessary to use the GL backend from
multiple threads.
2021-07-27 14:02:39 -05:00
bors[bot]
9ce884c384
Merge #1732
1732: Fix Tests on DX12/GL r=kvark a=cwfitzgerald

**Connections**

Marks #1730 as known failure

Closes #1695

**Description**

This fixes up tests on both DX12 and GL

**Testing**

Tests


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-07-27 13:10:45 +00:00
bors[bot]
2940347ba3
Merge #1731
1731: hal/dx12: support base vertex/instance r=cwfitzgerald a=kvark

**Connections**
Fixes #1725
Depends on https://github.com/gfx-rs/naga/pull/1141, https://github.com/gfx-rs/d3d12-rs/pull/34, and https://github.com/gfx-rs/d3d12-rs/pull/35 (thanks `@msiglreith` for quick reviews!).

**Description**
We allocate one root parameter covering the special constant buffer view with root constants. We set the root constants for each draw, but only on change.

This PR does *not* handle the indirect case. I'll follow-up with this.

**Testing**
Not thoroughly tested, but `@cwfitzgerald` already implemented a test for this, and this PR enables it on DX12.
Also, examples still seem to work :)


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-27 13:01:30 +00:00
Dzmitry Malyshau
69f808c54a hal/dx12: support base vertex/instance 2021-07-27 08:59:41 -04:00
Connor Fitzgerald
d6a8ab7b34
Allow vertex_storage_textures to be 0 2021-07-27 02:37:15 -04:00
Connor Fitzgerald
eb33efb110
Mark WARP as known failure on water 2021-07-27 02:15:46 -04:00
bors[bot]
6cfe8bdb28
Merge #1724
1724: hal/dx12: compact register allocation, naga update r=kvark a=kvark

**Connections**
Heavily depends on https://github.com/gfx-rs/naga/pull/1136

**Description**
Makes DX12 to run all of the examples 🎉 .

**Testing**
Re-enables DX12 in `PRIMARY` set, which also enables the reference tests on it.

![wgpu-dx12-shadow](https://user-images.githubusercontent.com/107301/126940717-aefad5b2-1eba-4523-ba6a-53a5744ba313.JPG)



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-26 06:14:05 +00:00
Dzmitry Malyshau
405cf57955 hal/dx12: compact register allocation, naga update 2021-07-26 02:01:14 -04:00
bors[bot]
3eb3eed8cf
Merge #1609
1609: [Vulkan] Initialize wgpu objects from raw handles r=kvark a=zarik5

**Connections**
This PR is a successor of https://github.com/gfx-rs/gfx/pull/3762

**Description**
The `handle_is_external` flag mechanism was not enough to ensure safety, when for example the Instance is wrapped in `Arc<>` and a library cannot keep track of all its clones. This is the case with the bevy render rewrite. The solution was to let wgpu be in charge of destroying the handles, but it also has to keep a reference to a "drop guard" which is always dropped after the handle is destroyed. For the OpenXR integration, this drop guard will be `xr::Instance`.

For now this is just a proof of concept. Only instance creation is handled, and there is even type error in `wgc::Instance::from_hal()`.

I have a few concerns:
* Is it ok to expose `hal::Instance` from the wgpu crate? Or should the user pass all the parameters so `hal::Instance` can be constructed internally? This second options is more disruptive, since the wgpu-types crate would need to import all platform-specific crates to define the structure/enum to hold the raw handles.
* Without counting the call to create the `hal::Instance`, there are 4 indirection calls to save the raw instance. Can this be optimized in any way?

Do you think it is possible to merge wgpu-hal into wgpu-core? This could help with reducing the distance from the surface level API to the platform specific APIs even more.

**Testing**
Vulkan/Android (Oculus Quest) using [this sample](https://github.com/zarik5/openxrs/blob/wgpu-test/openxr/examples/vulkan.rs).


Co-authored-by: Riccardo Zaglia <riccardo.zaglia5@gmail.com>
2021-07-26 05:03:13 +00:00
bors[bot]
ee9e1452d5
Merge #1717
1717: Work Around Fastclear Bug for Web and Native GL r=cwfitzgerald,kvark a=zicklag

**Connections**
Resolves #1627 

**Description**
Works around Mesa fastclear bug by doing a manual shader clear on effected platforms

**Testing**
Tested on Mesa Intel(R) UHD Graphics (CML GT2) (Gl)


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-26 04:57:17 +00:00
Riccardo Zaglia
2657849977 [Vulkan] Initialize wgpu objects from raw handles 2021-07-25 21:51:40 +02:00
Zicklag
0a66eef822 Work Around Fastclear Bug for Web and Native GL 2021-07-24 15:36:49 -05:00
Michael MacLeod
fd33ac36d4
Document coordinate systems in README
I had to do a bit of digging to find information about coordinate systems in
wgpu (asking on Matrix). This commit adds a table of coordinate systems to help
clarify the issue.

The table comes from the DX12 backend documentation of gfx-rs:
https://github.com/gfx-rs/gfx/tree/master/src/backend/dx12

Remove trailing newlines from README

Host coordinate images locally
2021-07-24 13:17:04 -07:00
bors[bot]
dd1be1ff62
Merge #1721
1721: Tweak Water Example to Show Off Water Shader a bit More r=cwfitzgerald a=zicklag

**Connections**
None

**Description**
Tweaks the water shader example terain and camera to show off the cool water shader a little bit more. 😄


https://user-images.githubusercontent.com/25393315/126842645-e353c0eb-57fc-4b8e-9e0d-901f08c7e9f7.mp4



**Testing**
Tested on vulkan and GL on linux.


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-24 20:16:51 +00:00
Zicklag
7fab8e213c Tweak Water Example to Show Off Water Shader More 2021-07-24 15:04:42 -05:00
bors[bot]
d5a477fe60
Merge #1719
1719: hal/dx12: pass null to mapping rects r=kvark a=kvark

**Connections**
See https://github.com/baldurk/renderdoc/issues/2323

**Description**
Passing NULL rects is better for tooling, as it turns out.

**Testing**
Ran the examples


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 16:24:12 +00:00
Dzmitry Malyshau
2158cdd43b hal/dx12: pass null to mapping rects 2021-07-23 12:19:59 -04:00
bors[bot]
5dd3f6ba6b
Merge #1710
1710: Check render bundle encoding for RODS r=cwfitzgerald a=kvark

**Connections**
Matches https://github.com/gpuweb/gpuweb/pull/1979

**Description**
Allows render bundles to be encoded for RODS.
In addition, validates that bundle RODS matches the pass RODS when executing. This part of the spec isn't written yet, and it's safer to be on the strict side.

**Testing**
Untested


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 15:36:32 +00:00
Dzmitry Malyshau
52734bf87a Fix tracing feature for RODS 2021-07-23 11:33:22 -04:00
Dzmitry Malyshau
34b68121c6 Check bundle RODS against pass RODS 2021-07-23 11:24:05 -04:00
Dzmitry Malyshau
bb218c1580 Check render bundle encoding for RODS 2021-07-23 11:24:05 -04:00
bors[bot]
35896df3b7
Merge #1716
1716: Update winit to 0.25 r=kvark a=Gordon-F

**Connections**


**Description**
Update winit to 0.25

**Testing**
Examples


Co-authored-by: Gordon-F <ishaposhnik@icloud.com>
2021-07-23 15:05:45 +00:00
bors[bot]
29f9e2a58e
Merge #1718
1718: Update naga to bbfa9a0, tweak DX12 debug output r=kvark a=kvark

**Connections**
Picks up #1132

**Description**
Also reduces the spam output of DX12 backend

**Testing**
Got skybox and water examples running!


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 14:51:08 +00:00
Dzmitry Malyshau
8dc4942431 Update naga to bbfa9a0, tweak DX12 debug output 2021-07-23 10:48:32 -04:00
Gordon-F
f0b1d5a673 Update winit to 0.25 2021-07-23 14:30:38 +03:00
bors[bot]
a0bcd86207
Merge #1714
1714: Update Naga to cc91c77 r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/naga/pull/1128 and other HLSL fixes.
Complements #1713

**Description**
Just an update

**Testing**
Ran examples locally 


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 06:20:11 +00:00
Dzmitry Malyshau
2c45796d9c Update Naga to cc91c77 2021-07-23 02:19:42 -04:00
bors[bot]
1f7d60d065
Merge #1713
1713: hal/dx12: rewrite view creation, use arrays more aggressively r=kvark a=kvark

**Connections**

**Description**
D3D12 has this thing where you can't create a 2D view with non-zero base array index.
So we have special logic now to fall back to 2D array views in these cases.

**Testing**
Tested on the Shadow example.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 06:07:18 +00:00
bors[bot]
5ef620ace8
Merge #1704
1704: Fix buffer memory initialization to use the tracker consistently r=kvark a=kvark

**Connections**
Depends on https://github.com/gfx-rs/naga/pull/1125

**Description**
Contains a number of dx12 fixes in addition to the buffer initialization fix.
The problem there was - we used the "pending writes" command buffer to initialize buffers, but also used the device's resource tracker and its state to figure out the transitions *after* a command buffer is merged its states.

**Testing**
Ran the examples on Vulkan.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-23 04:48:42 +00:00
Dzmitry Malyshau
726cf4f614 hal/dx12: rewrite view creation, use arrays more aggressively 2021-07-23 00:07:23 -04:00
bors[bot]
a32310096e
Merge #1705
1705: Fix failure mode of adapter_request_device (direct backend) r=kvark a=dhardy

This function has a method for reporting errors, so it shouldn't panic IMO.

Possibly though we should adapt the `RequestDeviceError` type to have a `cause: Box<dyn Error>` payload? The `log::error` line is just because we have no other way of reporting this value.

I tried to test this, but...

- on v0.9 I couldn't make the request fail, even with requesting absurd limits like 1e9 something
- on master the adapter request succeeds, then the shader creation fails with `UnsupportedCapability(Float64)` (even though the request contains `wgpu::Features::SHADER_FLOAT64` and does not fail)

So the `direct` or Vulkan backend does not check features properly?

Co-authored-by: Diggory Hardy <git@dhardy.name>
2021-07-22 19:14:03 +00:00
bors[bot]
10638f830f
Merge #1707
1707: Update naga revision r=kvark a=munrocket

**Connections**
https://github.com/gfx-rs/naga/pull/1096

**Description**
Updating `naga` with new WGSL operator `select(f, t, cons)`.

**Testing**
`cargo test` passed


Co-authored-by: munrocket <munrocket@pm.me>
2021-07-22 16:53:54 +00:00
munrocket
f909a8e631 update naga revision 2021-07-22 20:52:26 +04:00
bors[bot]
753cc25e13
Merge #1703
1703: Add Rgb9e5Ufloat Format r=kvark a=cwfitzgerald

**Connections**

Addresses part of #967, a wgpu-hal followup to #955.

**Description**

This adds only `Rgb9e5Ufloat`. I removed the explicit numbering from the texture format so we don't have to constantly re-number things. The default numbering is identical to what we were doing.

**Testing**

All backends unconditionally support it, so little testing is needed.


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-07-22 05:22:48 +00:00
Dzmitry Malyshau
09c9ab5e75 Fix buffer memory initialization to use the tracker consistently 2021-07-22 01:19:53 -04:00
Connor Fitzgerald
683d03a8e4 Add Rgb9e5Ufloat 2021-07-21 23:54:46 -04:00