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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
1702: Rename InputStepMode to VertexStepMode r=kvark a=kvark
**Connections**
https://github.com/gpuweb/gpuweb/pull/1927
**Description**
Just a rename
**Testing**
No need
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1701: hal/vk: use actual view usage for imageless framebuffers r=kvark a=kvark
**Connections**
Fixes#1700
**Description**
Vulkan spec is confusing. See [attachment info](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkFramebufferAttachmentImageInfo.html):
> usage is a bitmask of VkImageUsageFlagBits, matching the value of VkImageCreateInfo::usage used to create an image used with this framebuffer.
It doesn't talk about interaction with `ImageViewUsageCreateInfo`, which allows you to constrain the usage on a view.
**Testing**
Unable to test right now. `@initial-algebra` could you give it a spin?
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1694: hal/dx12: fix the binding model r=kvark a=kvark
**Connections**
Depends on https://github.com/gfx-rs/naga/pull/1114
Makes the halmark + bunnymark run on DX12
**Description**
There was a mess-up in trying to use top-down layout...
Also fixes double-free on the queue in DX12.
**Testing**
Examples
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1692: Avoid dev-dep on image r=cwfitzgerald a=Craig-Macomber
**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_
#1610
**Description**
_Describe what problem this is solving, and how it's solved._
This removes image from the dev-deps, reducing build time/size.
Looks like noise was pulling in image with all formats enabled:
├── noise v0.7.0
│ ├── image v0.23.14
This was fixed in 1af9e15222 (diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542) which has not been released yet.
For now, we can workaround this with:
noise = { version = "0.7", default-features = false }
**Testing**
_Explain how this change is tested._
Ran `cargo build` as well as `cargo run --example water`
Co-authored-by: Craig <CraigM@CraigM.info>
1691: Fix a couple of spelling errors in comments r=cwfitzgerald a=Craig-Macomber
**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_
None.
**Description**
_Describe what problem this is solving, and how it's solved._
Fixes a couple spelling errors my spell checker highlighted when reading the source.
**Testing**
_Explain how this change is tested._
Spell checker stopped highlighting the words.
Co-authored-by: Craig <CraigM@CraigM.info>
1687: Update naga, use binding map in DX12 r=kvark a=kvark
**Connections**
Updates naga with https://github.com/gfx-rs/naga/pull/1105
**Description**
Establishes a binding map contract between dx12 backend and naga.
**Testing**
Gets the cube running, but there is something strange there.
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1676: Add `Feature::SHADER_PRIMITIVE_INDEX` to support `builtin(primitive_index)` in fragment shaders r=kvark a=initial-algebra
**Connections**
https://github.com/gfx-rs/wgpu/issues/1669https://github.com/gfx-rs/naga/pull/1097
**Description**
Allows fragment shaders to access the index of the current primitive via a new builtin variable.
**Testing**
Works on my machine.
- passes the capability to my fork of `naga` for basic validation and translation
- enables the `geometryShader` feature for Vulkan
- is refused by DX12
Needs to be implemented and tested for OpenGL, DirectX and Metal.
Co-authored-by: initial-algebra <67286231+initial-algebra@users.noreply.github.com>
1618: webgpu: pass wgsl directly r=kvark a=grovesNL
**Connections**
Matrix conversation about passing WGSL to Gecko
**Description**
Gecko accepts WGSL now, so we can pass it directly instead of going through naga.
We could also consider converting SPIR-V to WGSL soon, assuming nobody is relying on the SPIR-V path with older versions of Gecko. We could do that in a separate PR though.
**Testing**
Tried hello-compute locally, using the examples HTML file and creating wasm with something like
```
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build --release --example hello-compute --target wasm32-unknown-unknown
wasm-bindgen target/wasm32-unknown-unknown/release/examples/hello-compute.wasm --out-dir target/generated --web
```
Co-authored-by: Joshua Groves <josh@joshgroves.com>