Skip to content

Commit 28d9601

Browse files
authored
Update wgpu dependency to 0.19.0. (#567)
1 parent a68c76a commit 28d9601

File tree

22 files changed

+59
-111
lines changed

22 files changed

+59
-111
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Per Keep a Changelog there are 6 main categories of changes:
4545
- rend3: Added basic (no shadow maps, no clustering) point light support to the renderer API. @marceline-cramer
4646

4747
### Changes
48-
- rend3: Update to wgpu 0.13, naga 0.9 @garyttierney
48+
- rend3: Update to wgpu 0.19, naga 0.14 @garyttierney @kpreid
4949
- rend3: Convert all shaders to WGSL using a custom preprocessing solution @cwfitzgerald
5050
- rend3: Update to winit 0.29.4 @pillowtrucker
5151
- rend3-framework: Consolidate many arguments into single `SetupContext`, `EventContext`, and `RedrawContext` structs. @cwfitzgerald

examples/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ web-time = "0.2"
6666
# windowing
6767
winit = "0.29.4"
6868
# Integration with wgpu
69-
wgpu = "0.18"
69+
wgpu = "0.19.0"
7070
# Profiling with wgpu
71-
wgpu-profiler = "0.15"
71+
wgpu-profiler = "0.16.0"
7272

7373
[target.'cfg(target_arch = "wasm32")'.dependencies]
7474
console_log = "1"
7575
console_error_panic_hook = "0.1"
7676
js-sys = "0.3"
77-
web-sys = "0.3"
77+
web-sys = "0.3.67"
7878
wasm-bindgen = "0.2.83"
7979
wasm-bindgen-futures = "0.4"
8080

examples/src/cube_no_framework/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ winit = "0.29.4"
3131
console_log = "1"
3232
console_error_panic_hook = "0.1"
3333
js-sys = "0.3"
34-
web-sys = "0.3"
34+
web-sys = "0.3.67"
3535
wasm-bindgen = "0.2.83"
3636
wasm-bindgen-futures = "0.4"

examples/src/cube_no_framework/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn main() {
7979
// SAFETY: this surface _must_ not be used after the `window` dies. Both the
8080
// event loop and the renderer are owned by the `run` closure passed to winit,
8181
// so rendering work will stop after the window dies.
82-
let surface = Arc::new(unsafe { iad.instance.create_surface(&window) }.unwrap());
82+
let surface = Arc::new(iad.instance.create_surface(&window).unwrap());
8383
// Get the preferred format for the surface.
8484
let caps = surface.get_capabilities(&iad.adapter);
8585
let preferred_format = caps.formats[0];

examples/src/scene_viewer/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ use rend3::{
1010
Backend, Camera, CameraProjection, DirectionalLight, DirectionalLightHandle, SampleCount, Texture,
1111
TextureFormat,
1212
},
13-
util::typedefs::FastHashMap,
13+
util::typedefs::{FastHashMap, RendererStatistics},
1414
Renderer, RendererProfile,
1515
};
1616
use rend3_framework::{lock, AssetPath, Mutex};
1717
use rend3_gltf::{GltfLoadSettings, GltfSceneInstance, LoadedGltfScene};
1818
use rend3_routine::{pbr::NormalTextureYDirection, skybox::SkyboxRoutine};
1919
use web_time::Instant;
20-
use wgpu_profiler::GpuTimerScopeResult;
2120
use winit::{
2221
event::{DeviceEvent, ElementState, Event, KeyEvent, MouseButton, WindowEvent},
2322
keyboard::{KeyCode, PhysicalKey},
@@ -135,7 +134,6 @@ fn extract_backend(value: &str) -> Result<Backend, &'static str> {
135134
Ok(match value.to_lowercase().as_str() {
136135
"vulkan" | "vk" => Backend::Vulkan,
137136
"dx12" | "12" => Backend::Dx12,
138-
"dx11" | "11" => Backend::Dx11,
139137
"metal" | "mtl" => Backend::Metal,
140138
"opengl" | "gl" => Backend::Gl,
141139
_ => return Err("unknown backend"),
@@ -301,7 +299,7 @@ pub struct SceneViewer {
301299
camera_pitch: f32,
302300
camera_yaw: f32,
303301
camera_location: Vec3A,
304-
previous_profiling_stats: Option<Vec<GpuTimerScopeResult>>,
302+
previous_profiling_stats: Option<RendererStatistics>,
305303
last_mouse_delta: Option<DVec2>,
306304

307305
scene: Option<LoadedGltfScene>,

rend3-egui/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ egui = {git = "https://github.com/emilk/egui.git", branch="master"}
1616
egui-wgpu = {git = "https://github.com/emilk/egui.git", branch="master"}
1717
glam = "0.24"
1818
rend3 = { version = "^0.3.0", path = "../rend3" }
19-
wgpu = "0.18.0"
20-
wgpu-types = "0.18.0"
19+
wgpu = "0.19.0"
20+
wgpu-types = "0.19.0"

rend3-egui/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl EguiRenderRoutine {
137137
image_rgba,
138138
dimensions,
139139
format.block_dimensions(),
140-
format.block_size(None).unwrap(),
140+
format.block_copy_size(None).unwrap(),
141141
)
142142
}
143143

rend3-framework/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ rend3-routine = { version = "0.3.0", path = "../rend3-routine" }
2323
thiserror = { version = "1" }
2424
web-time = "0.2"
2525
winit = { version = "0.29.4", features = ["rwh_05"] }
26-
wgpu = "0.18.0"
26+
wgpu = "0.19.0"
2727

2828
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2929
# logging
@@ -38,7 +38,7 @@ reqwest = "0.11"
3838
once_cell = "1.8"
3939
wasm-bindgen = "0.2.87"
4040
wasm-bindgen-futures = "0.4"
41-
web-sys = "0.3"
41+
web-sys = "0.3.67"
4242

4343
[target.'cfg(target_os = "android")'.dependencies]
4444
ndk-glue = "0.7"

rend3-framework/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub async fn async_start<A: App<T> + 'static, T: 'static>(mut app: A, window_bui
166166

167167
// Create the window invisible until we are rendering
168168
let (event_loop, window) = app.create_window(window_builder.with_visible(false)).unwrap();
169+
let window = Arc::new(window);
169170
let window_size = window.inner_size();
170171

171172
let iad = app.create_iad().await.unwrap();
@@ -178,7 +179,7 @@ pub async fn async_start<A: App<T> + 'static, T: 'static>(mut app: A, window_bui
178179
let mut surface = if cfg!(target_os = "android") {
179180
None
180181
} else {
181-
Some(Arc::new(unsafe { iad.instance.create_surface(&window) }.unwrap()))
182+
Some(Arc::new(iad.instance.create_surface(window.clone()).unwrap()))
182183
};
183184

184185
// Make us a renderer.
@@ -401,7 +402,7 @@ struct StoredSurfaceInfo {
401402
#[allow(clippy::too_many_arguments)]
402403
fn handle_surface<A: App<T>, T: 'static>(
403404
app: &A,
404-
window: &Window,
405+
window: &Arc<Window>,
405406
event: &Event<T>,
406407
instance: &Instance,
407408
surface: &mut Option<Arc<Surface>>,
@@ -411,7 +412,7 @@ fn handle_surface<A: App<T>, T: 'static>(
411412
match *event {
412413
Event::Resumed => {
413414
if surface.is_none() {
414-
*surface = Some(Arc::new(unsafe { instance.create_surface(window) }.unwrap()));
415+
*surface = Some(Arc::new(instance.create_surface(window.clone()).unwrap()));
415416
}
416417
Some(false)
417418
}

rend3-gltf/src/lib.rs

+1-58
Original file line numberDiff line numberDiff line change
@@ -1797,63 +1797,6 @@ pub mod util {
17971797
}
17981798

17991799
pub fn format_components(tex: types::TextureFormat) -> Option<u8> {
1800-
use types::TextureFormat as r3F;
1801-
1802-
match tex {
1803-
r3F::R8Unorm
1804-
| r3F::R8Snorm
1805-
| r3F::R8Uint
1806-
| r3F::R8Sint
1807-
| r3F::R16Uint
1808-
| r3F::R16Sint
1809-
| r3F::R16Unorm
1810-
| r3F::R16Snorm
1811-
| r3F::R16Float => Some(1),
1812-
r3F::Rg8Unorm | r3F::Rg8Snorm | r3F::Rg8Uint | r3F::Rg8Sint => Some(2),
1813-
r3F::R32Uint | r3F::R32Sint | r3F::R32Float => Some(1),
1814-
r3F::Rg16Uint | r3F::Rg16Sint | r3F::Rg16Unorm | r3F::Rg16Snorm | r3F::Rg16Float => Some(2),
1815-
r3F::Rgba8Unorm
1816-
| r3F::Rgba8UnormSrgb
1817-
| r3F::Rgba8Snorm
1818-
| r3F::Rgba8Uint
1819-
| r3F::Rgba8Sint
1820-
| r3F::Bgra8Unorm
1821-
| r3F::Bgra8UnormSrgb => Some(4),
1822-
r3F::Rgb9e5Ufloat => Some(4),
1823-
r3F::Rgb10a2Unorm | r3F::Rgb10a2Uint => Some(4),
1824-
r3F::Rg11b10Float => Some(3),
1825-
r3F::Rg32Uint | r3F::Rg32Sint | r3F::Rg32Float => Some(2),
1826-
r3F::Rgba16Uint
1827-
| r3F::Rgba16Sint
1828-
| r3F::Rgba16Unorm
1829-
| r3F::Rgba16Snorm
1830-
| r3F::Rgba16Float
1831-
| r3F::Rgba32Uint
1832-
| r3F::Rgba32Sint
1833-
| r3F::Rgba32Float => Some(4),
1834-
r3F::Stencil8 => Some(1),
1835-
r3F::Depth16Unorm => Some(1),
1836-
r3F::Depth24Plus => Some(1),
1837-
r3F::Depth24PlusStencil8 => Some(2),
1838-
r3F::Depth32Float => Some(1),
1839-
r3F::Depth32FloatStencil8 => Some(2),
1840-
r3F::Bc1RgbaUnorm => Some(4),
1841-
r3F::Bc1RgbaUnormSrgb => Some(4),
1842-
r3F::Bc2RgbaUnorm => Some(4),
1843-
r3F::Bc2RgbaUnormSrgb => Some(4),
1844-
r3F::Bc3RgbaUnorm => Some(4),
1845-
r3F::Bc3RgbaUnormSrgb => Some(4),
1846-
r3F::Bc4RUnorm | r3F::Bc4RSnorm => Some(1),
1847-
r3F::Bc5RgUnorm | r3F::Bc5RgSnorm => Some(2),
1848-
r3F::Bc6hRgbUfloat | r3F::Bc6hRgbFloat => Some(3),
1849-
r3F::Bc7RgbaUnorm | r3F::Bc7RgbaUnormSrgb => Some(4),
1850-
r3F::Etc2Rgb8Unorm | r3F::Etc2Rgb8UnormSrgb => Some(3),
1851-
r3F::Etc2Rgb8A1Unorm | r3F::Etc2Rgb8A1UnormSrgb | r3F::Etc2Rgba8Unorm | r3F::Etc2Rgba8UnormSrgb => Some(4),
1852-
r3F::EacR11Unorm => Some(1),
1853-
r3F::EacR11Snorm => Some(1),
1854-
r3F::EacRg11Unorm => Some(2),
1855-
r3F::EacRg11Snorm => Some(2),
1856-
r3F::Astc { block: _, channel: _ } => Some(4),
1857-
}
1800+
Some(tex.components())
18581801
}
18591802
}

rend3-routine/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ encase = { version = "0.6", features = ["glam"] }
2020
flume = "0.11"
2121
glam = { version = "0.24.0", features = ["bytemuck"] }
2222
log = "0.4"
23-
naga = { version = "0.14", features = ["wgsl-in"] }
23+
naga = { version = "0.19.0", features = ["wgsl-in"] }
2424
ordered-float = "4"
2525
parking_lot = "0.12"
2626
profiling = {version = "1", default-features = false }
2727
rend3 = { version = "^0.3.0", path = "../rend3" }
2828
rust-embed = { version = "8", features = ["interpolate-folder-path"] }
2929
serde = { version = "1", features = ["derive"] }
3030
serde_json = "1"
31-
wgpu = "0.18.0"
32-
wgpu-profiler = "0.15.0"
31+
wgpu = "0.19.0"
32+
wgpu-profiler = "0.16.0"

rend3-test/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ glam = "0.24"
2121
image = { version = "0.24", default-features = false, features = ["png"] }
2222
rend3 = { path = "../rend3" }
2323
rend3-routine = { path = "../rend3-routine" }
24-
wgpu = "0.18.0"
24+
wgpu = "0.19.0"
2525

2626
# These should be dev-deps but doing this allows us to have a single attribute on all tests
2727
# and not need to have conditional attributes on every single test.

rend3-types/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ glam = { version = "0.24", features = ["bytemuck"] }
2020
list-any = "0.2"
2121
once_cell = "1"
2222
thiserror = "1"
23-
wgt = { package = "wgpu-types", version = "0.18" }
23+
wgt = { package = "wgpu-types", version = "0.19" }

rend3/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ serde = { version = "1", features = ["derive"] }
5858
smallvec = "1"
5959
smartstring = "1.0"
6060
thiserror = "1"
61-
wgpu = "0.18.0"
62-
wgpu-profiler = "0.15.0"
61+
wgpu = "0.19.0"
62+
wgpu-profiler = "0.16.0"
6363

6464
[dev-dependencies]
6565
pollster = "0.3"

rend3/src/graph/graph.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ impl<'node> RenderGraph<'node> {
482482

483483
profiling::scope!(&format!("Node: {}", node.label));
484484

485-
data_core.profiler.try_lock().unwrap().begin_scope(
486-
&node.label,
485+
let profiler_query = data_core.profiler.try_lock().unwrap().begin_query(
486+
node.label,
487487
&mut encoder_or_rpass,
488488
&renderer.device,
489489
);
@@ -509,7 +509,11 @@ impl<'node> RenderGraph<'node> {
509509
None => RenderGraphEncoderOrPassInner::Encoder(unsafe { &mut *encoder_cell.get() }),
510510
};
511511

512-
let _ = data_core.profiler.try_lock().unwrap().end_scope(&mut encoder_or_rpass);
512+
data_core
513+
.profiler
514+
.try_lock()
515+
.unwrap()
516+
.end_query(&mut encoder_or_rpass, profiler_query);
513517
}
514518
}
515519

rend3/src/managers/texture.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use thiserror::Error;
55
use wgpu::{
66
util::DeviceExt, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor,
77
BindGroupLayoutEntry, BindingResource, BindingType, CommandBuffer, CommandEncoder, CommandEncoderDescriptor,
8-
Device, Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, ShaderStages, Texture, TextureAspect,
8+
Device, Extent3d, Features, ImageCopyTexture, ImageDataLayout, Origin3d, ShaderStages, Texture, TextureAspect,
99
TextureDescriptor, TextureDimension, TextureSampleType, TextureView, TextureViewDescriptor, TextureViewDimension,
1010
};
1111

@@ -108,7 +108,7 @@ impl<T: 'static> TextureManager<T> {
108108
texture: crate::types::Texture,
109109
cube: bool,
110110
) -> Result<(Option<CommandBuffer>, InternalTexture), TextureCreationError> {
111-
validate_texture_format(texture.format)?;
111+
validate_texture_format(texture.format, renderer.device.features())?;
112112

113113
let (block_x, block_y) = texture.format.block_dimensions();
114114
let size = Extent3d {
@@ -142,9 +142,12 @@ impl<T: 'static> TextureManager<T> {
142142
let (buffer, tex) = match texture.mip_source {
143143
MipmapSource::Uploaded => {
144144
let scope = AllocationErrorScope::new(&renderer.device);
145-
let texture = renderer
146-
.device
147-
.create_texture_with_data(&renderer.queue, &desc, &texture.data);
145+
let texture = renderer.device.create_texture_with_data(
146+
&renderer.queue,
147+
&desc,
148+
wgpu::util::TextureDataOrder::LayerMajor,
149+
&texture.data,
150+
);
148151
scope.end().map_err(TextureCreationError::TextureAllocationFailed)?;
149152
(None, texture)
150153
}
@@ -160,7 +163,7 @@ impl<T: 'static> TextureManager<T> {
160163
scope.end().map_err(TextureCreationError::TextureAllocationFailed)?;
161164

162165
let (block_width, _) = texture.format.block_dimensions();
163-
let block_size = texture.format.block_size(None).unwrap();
166+
let block_size = texture.format.block_copy_size(None).unwrap();
164167

165168
let scope = AllocationErrorScope::new(&renderer.device);
166169
// write first level
@@ -415,8 +418,8 @@ fn create_null_tex_view(device: &Device, dimension: TextureViewDimension) -> Tex
415418
})
416419
}
417420

418-
fn validate_texture_format(format: TextureFormat) -> Result<(), TextureCreationError> {
419-
let sample_type = format.sample_type(None);
421+
fn validate_texture_format(format: TextureFormat, features: Features) -> Result<(), TextureCreationError> {
422+
let sample_type = format.sample_type(None, Some(features));
420423
match sample_type {
421424
Some(TextureSampleType::Float { filterable: true }) => Ok(()),
422425
Some(TextureSampleType::Float { filterable: false }) => Err(TextureCreationError::TextureFormatNotFilterable {

rend3/src/renderer/eval.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ pub fn evaluate_instructions(renderer: &Renderer) -> InstructionEvaluationOutput
2929
match kind {
3030
InstructionKind::AddSkeleton { handle, skeleton } => {
3131
profiling::scope!("Add Skeleton");
32+
let profiler_query = data_core.profiler.try_lock().unwrap().begin_query(
33+
"Add Skeleton",
34+
&mut encoder,
35+
&renderer.device,
36+
);
37+
data_core.skeleton_manager.add(handle, *skeleton);
3238
data_core
3339
.profiler
3440
.try_lock()
3541
.unwrap()
36-
.begin_scope("Add Skeleton", &mut encoder, &renderer.device);
37-
data_core.skeleton_manager.add(handle, *skeleton);
38-
let _ = data_core.profiler.try_lock().unwrap().end_scope(&mut encoder);
42+
.end_query(&mut encoder, profiler_query);
3943
}
4044
InstructionKind::AddTexture2D {
4145
handle,

rend3/src/renderer/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn create_renderer(
6363

6464
let profiler = Mutex::new(
6565
wgpu_profiler::GpuProfiler::new(GpuProfilerSettings {
66-
enable_timer_scopes: true,
66+
enable_timer_queries: true,
6767
enable_debug_groups: true,
6868
max_num_pending_frames: 4,
6969
})

0 commit comments

Comments
 (0)