~~Currently blocked on an upstream bug that causes crashes when
minimizing/resizing on dx12 https://github.com/gfx-rs/wgpu/issues/3967~~
wgpu 0.17.1 is out which fixes it

# Objective

Keep wgpu up to date.

## Solution

Update wgpu and naga_oil.

Currently this depends on an unreleased (and unmerged) branch of
naga_oil, and hasn't been properly tested yet.

The wgpu side of this seems to have been an extremely trivial upgrade
(all the upgrade work seems to be in naga_oil). This also lets us remove
the workarounds for pack/unpack4x8unorm in the SSAO shaders.

Lets us close the dx12 part of
https://github.com/bevyengine/bevy/issues/8888

related: https://github.com/bevyengine/bevy/issues/9304

---

## Changelog

Update to wgpu 0.17 and naga_oil 0.9
This commit is contained in:
Elabajaba 2023-10-09 16:15:24 -04:00 committed by GitHub
parent 12a2f83edd
commit 665dbcbb21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 33 deletions

View file

@ -1,3 +0,0 @@
(
exit_after: Some(90)
)

View file

@ -1,4 +0,0 @@
(
// Ensures that the full cycle will run
exit_after: Some(410)
)

View file

@ -30,7 +30,7 @@ bitflags = "2.3"
fixedbitset = "0.4"
# direct dependency required for derive macro
bytemuck = { version = "1", features = ["derive"] }
naga_oil = "0.8"
radsort = "0.1"
naga_oil = "0.9"
smallvec = "1.6"
thread_local = "1.0"

View file

@ -53,20 +53,12 @@ fn calculate_neighboring_depth_differences(pixel_coordinates: vec2<i32>) -> f32
edge_info = saturate((1.0 + bias) - edge_info / scale); // Apply the bias and scale, and invert edge_info so that small values become large, and vice versa
// Pack the edge info into the texture
let edge_info_packed = vec4<u32>(mypack4x8unorm(edge_info), 0u, 0u, 0u);
let edge_info_packed = vec4<u32>(pack4x8unorm(edge_info), 0u, 0u, 0u);
textureStore(depth_differences, pixel_coordinates, edge_info_packed);
return depth_center;
}
// TODO: Remove this once https://github.com/gfx-rs/naga/pull/2353 lands
fn mypack4x8unorm(e: vec4<f32>) -> u32 {
return u32(clamp(e.x, 0.0, 1.0) * 255.0 + 0.5) |
u32(clamp(e.y, 0.0, 1.0) * 255.0 + 0.5) << 8u |
u32(clamp(e.z, 0.0, 1.0) * 255.0 + 0.5) << 16u |
u32(clamp(e.w, 0.0, 1.0) * 255.0 + 0.5) << 24u;
}
fn load_normal_view_space(uv: vec2<f32>) -> vec3<f32> {
var world_normal = textureSampleLevel(normals, point_clamp_sampler, uv, 0.0).xyz;
world_normal = (world_normal * 2.0) - 1.0;

View file

@ -31,11 +31,11 @@ fn spatial_denoise(@builtin(global_invocation_id) global_id: vec3<u32>) {
let visibility2 = textureGather(0, ambient_occlusion_noisy, point_clamp_sampler, uv, vec2<i32>(0i, 2i));
let visibility3 = textureGather(0, ambient_occlusion_noisy, point_clamp_sampler, uv, vec2<i32>(2i, 2i));
let left_edges = myunpack4x8unorm(edges0.x);
let right_edges = myunpack4x8unorm(edges1.x);
let top_edges = myunpack4x8unorm(edges0.z);
let bottom_edges = myunpack4x8unorm(edges2.w);
var center_edges = myunpack4x8unorm(edges0.y);
let left_edges = unpack4x8unorm(edges0.x);
let right_edges = unpack4x8unorm(edges1.x);
let top_edges = unpack4x8unorm(edges0.z);
let bottom_edges = unpack4x8unorm(edges2.w);
var center_edges = unpack4x8unorm(edges0.y);
center_edges *= vec4<f32>(left_edges.y, right_edges.x, top_edges.w, bottom_edges.z);
let center_weight = 1.2;
@ -82,11 +82,3 @@ fn spatial_denoise(@builtin(global_invocation_id) global_id: vec3<u32>) {
textureStore(ambient_occlusion, pixel_coordinates, vec4<f32>(denoised_visibility, 0.0, 0.0, 0.0));
}
// TODO: Remove this once https://github.com/gfx-rs/naga/pull/2353 lands in Bevy
fn myunpack4x8unorm(e: u32) -> vec4<f32> {
return vec4<f32>(clamp(f32(e & 0xFFu) / 255.0, 0.0, 1.0),
clamp(f32((e >> 8u) & 0xFFu) / 255.0, 0.0, 1.0),
clamp(f32((e >> 16u) & 0xFFu) / 255.0, 0.0, 1.0),
clamp(f32((e >> 24u) & 0xFFu) / 255.0, 0.0, 1.0));
}

View file

@ -57,9 +57,12 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.12.0-dev" }
image = { version = "0.24", default-features = false }
# misc
wgpu = { version = "0.16.0", features=["naga"] }
codespan-reporting = "0.11.0"
naga = { version = "0.12.0", features = ["wgsl-in"] }
# `fragile-send-sync-non-atomic-wasm` feature means we can't use WASM threads for rendering
# It is enabled for now to avoid having to do a significant overhaul of the renderer just for wasm
wgpu = { version = "0.17.1", features = ["naga", "fragile-send-sync-non-atomic-wasm"] }
naga = { version = "0.13.0", features = ["wgsl-in"] }
naga_oil = "0.9"
serde = { version = "1", features = ["derive"] }
bitflags = "2.3"
bytemuck = { version = "1.5", features = ["derive"] }
@ -71,7 +74,6 @@ futures-lite = "1.4.0"
hexasphere = "9.0"
ddsfile = { version = "0.5.0", optional = true }
ktx2 = { version = "0.3.0", optional = true }
naga_oil = "0.8"
# For ktx2 supercompression
flate2 = { version = "1.0.22", optional = true }
ruzstd = { version = "0.4.0", optional = true }