Skip to content

Commit eef4758

Browse files
authored
Update egui to latest and wgpu to 0.16 (#1958)
* update to wgpu 0.16 and egui using this version * shader fixup for type aliases and rectangle shader * shader signed/unsigned shenanigans * more signed/unsigned issues * fix texture component count * fix picking layer depth readback crash on web * patch wgpu * better texture size estimate * fix patches
1 parent f0fdcf3 commit eef4758

File tree

29 files changed

+524
-369
lines changed

29 files changed

+524
-369
lines changed

Cargo.lock

Lines changed: 93 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ comfy-table = { version = "6.1", default-features = false }
5959
ctrlc = { version = "3.0", features = ["termination"] }
6060
ecolor = "0.21.0"
6161
eframe = { version = "0.21.3", default-features = false }
62-
egui = { version = "0.21.0", features = ["extra_debug_asserts", "tracing"] }
62+
egui = { version = "0.21.0", features = ["extra_debug_asserts", "log"] }
6363
egui-wgpu = "0.21.0"
6464
egui_dock = "0.4"
65-
egui_extras = { version = "0.21.0", features = ["tracing"] }
65+
egui_extras = { version = "0.21.0", features = ["log"] }
6666
emath = "0.21.0"
6767
enumset = "1.0.12"
6868
epaint = "0.21.0"
@@ -85,9 +85,8 @@ thiserror = "1.0"
8585
time = { version = "0.3", features = ["wasm-bindgen"] }
8686
tinyvec = { version = "1.6", features = ["alloc", "rustc_1_55"] }
8787
tokio = "1.24"
88-
wgpu = { version = "0.15.1", default-features = false }
89-
wgpu-core = { version = "0.15.1", default-features = false }
90-
wgpu-hal = { version = "0.15.4", default-features = false }
88+
wgpu = { version = "0.16", default-features = false }
89+
wgpu-core = { version = "0.16", default-features = false }
9190

9291

9392
[profile.dev]
@@ -113,9 +112,16 @@ debug = true
113112
# As a last resport, patch with a commit to our own repository.
114113
# ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk.
115114

116-
# ecolor = { path = "../../egui/crates/ecolor" }
117-
# eframe = { path = "../../egui/crates/eframe" }
118-
# egui = { path = "../../egui/crates/egui" }
119-
# egui-wgpu = { path = "../../egui/crates/egui-wgpu" }
120-
# egui_extras = { path = "../../egui/crates/egui_extras" }
121-
# emath = { path = "../../egui/crates/emath" }
115+
# TODO(andreas/emilk): Update to a stable egui version
116+
# wgpu 0.16 support.
117+
ecolor = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
118+
eframe = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
119+
egui = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
120+
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
121+
egui_extras = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
122+
emath = { git = "https://github.com/emilk/egui", rev = "0e6d69d" }
123+
124+
# TODO(andreas): Either work around this issue in wgpu-egui (never discard command buffers) or wait for wgpu patch release.
125+
# Fix for command buffer dropping crash https://github.com/gfx-rs/wgpu/pull/3726
126+
wgpu = { git = "https://github.com/rerun-io/wgpu", rev = "de497aeda152a3515bac5eb4bf1b17f1757b9dac" }
127+
wgpu-core = { git = "https://github.com/rerun-io/wgpu", rev = "de497aeda152a3515bac5eb4bf1b17f1757b9dac" }

crates/re_renderer/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ notify = "5.0"
7777
puffin.workspace = true
7878
wgpu = { workspace = true, default-features = false, features = ["wgsl"] }
7979
wgpu-core.workspace = true
80-
wgpu-hal.workspace = true
8180

8281
# wasm
8382
[target.'cfg(target_arch = "wasm32")'.dependencies]

crates/re_renderer/shader/depth_cloud.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ struct PointData {
8282
}
8383

8484
// Backprojects the depth texture using the intrinsics passed in the uniform buffer.
85-
fn compute_point_data(quad_idx: i32) -> PointData {
85+
fn compute_point_data(quad_idx: u32) -> PointData {
8686
let wh = textureDimensions(depth_texture);
87-
let texcoords = IVec2(quad_idx % wh.x, quad_idx / wh.x);
87+
let texcoords = UVec2(quad_idx % wh.x, quad_idx / wh.x);
8888

8989
// TODO(cmc): expose knobs to linearize/normalize/flip/cam-to-plane depth.
9090
let world_space_depth = depth_cloud_info.world_depth_from_texture_value * textureLoad(depth_texture, texcoords, 0).x;

crates/re_renderer/shader/lines.wgsl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ struct BatchUniformBuffer {
3232
@group(2) @binding(0)
3333
var<uniform> batch: BatchUniformBuffer;
3434

35-
36-
// textureLoad needs i32 right now, so we use that with all sizes & indices to avoid casts
37-
// https://github.com/gfx-rs/naga/issues/1997
38-
const POSITION_TEXTURE_SIZE: i32 = 512;
39-
const LINE_STRIP_TEXTURE_SIZE: i32 = 256;
35+
const POSITION_TEXTURE_SIZE: u32 = 512u;
36+
const LINE_STRIP_TEXTURE_SIZE: u32 = 256u;
4037

4138
// Flags
4239
// See lines.rs#LineStripFlags
@@ -87,9 +84,7 @@ struct LineStripData {
8784

8885
// Read and unpack line strip data at a given location
8986
fn read_strip_data(idx: u32) -> LineStripData {
90-
// can be u32 once https://github.com/gfx-rs/naga/issues/1997 is solved
91-
let idx = i32(idx);
92-
let coord = IVec2(idx % LINE_STRIP_TEXTURE_SIZE, idx / LINE_STRIP_TEXTURE_SIZE);
87+
let coord = UVec2(idx % LINE_STRIP_TEXTURE_SIZE, idx / LINE_STRIP_TEXTURE_SIZE);
9388
var raw_data = textureLoad(position_data_texture, coord, 0).xy;
9489

9590
var data: LineStripData;
@@ -110,9 +105,7 @@ struct PositionData {
110105

111106
// Read and unpack position data at a given location
112107
fn read_position_data(idx: u32) -> PositionData {
113-
// can be u32 once https://github.com/gfx-rs/naga/issues/1997 is solved
114-
let idx = i32(idx);
115-
var raw_data = textureLoad(line_strip_texture, IVec2(idx % POSITION_TEXTURE_SIZE, idx / POSITION_TEXTURE_SIZE), 0);
108+
var raw_data = textureLoad(line_strip_texture, UVec2(idx % POSITION_TEXTURE_SIZE, idx / POSITION_TEXTURE_SIZE), 0);
116109

117110
var data: PositionData;
118111
let pos_4d = batch.world_from_obj * Vec4(raw_data.xyz, 1.0);

crates/re_renderer/shader/point_cloud.wgsl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ var<uniform> batch: BatchUniformBuffer;
3636
// Flags
3737
// See point_cloud.rs#PointCloudBatchFlags
3838
const ENABLE_SHADING: u32 = 1u;
39-
40-
// textureLoad needs i32 right now, so we use that with all sizes & indices to avoid casts
41-
// https://github.com/gfx-rs/naga/issues/1997
42-
var<private> TEXTURE_SIZE: i32 = 2048;
39+
const TEXTURE_SIZE: u32 = 2048u;
4340

4441
struct VertexOut {
4542
@builtin(position)
@@ -75,8 +72,8 @@ struct PointData {
7572
}
7673

7774
// Read and unpack data at a given location
78-
fn read_data(idx: i32) -> PointData {
79-
let coord = IVec2(i32(idx % TEXTURE_SIZE), idx / TEXTURE_SIZE);
75+
fn read_data(idx: u32) -> PointData {
76+
let coord = UVec2(idx % TEXTURE_SIZE, idx / TEXTURE_SIZE);
8077
let position_data = textureLoad(position_data_texture, coord, 0);
8178
let color = textureLoad(color_texture, coord, 0);
8279

crates/re_renderer/shader/rectangle_fs.wgsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ fn fs_main(in: VertexOut) -> @location(0) Vec4 {
8686
let colormap_size = textureDimensions(colormap_texture).xy;
8787
let color_index = normalized_value.r * f32(colormap_size.x * colormap_size.y);
8888
// TODO(emilk): interpolate between neighboring colors for non-integral color indices
89-
let color_index_i32 = i32(color_index);
90-
let x = color_index_i32 % colormap_size.x;
91-
let y = color_index_i32 / colormap_size.x;
92-
texture_color = textureLoad(colormap_texture, IVec2(x, y), 0);
89+
let color_index_u32 = u32(color_index);
90+
let x = color_index_u32 % colormap_size.x;
91+
let y = color_index_u32 / colormap_size.x;
92+
texture_color = textureLoad(colormap_texture, UVec2(x, y), 0);
9393
} else {
9494
return ERROR_RGBA; // unknown color mapper
9595
}

crates/re_renderer/shader/types.wgsl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Names chosen to match [`glam`](https://docs.rs/glam/latest/glam/)
2-
type Vec2 = vec2<f32>;
3-
type Vec3 = vec3<f32>;
4-
type Vec4 = vec4<f32>;
5-
type UVec2 = vec2<u32>;
6-
type UVec3 = vec3<u32>;
7-
type UVec4 = vec4<u32>;
8-
type IVec2 = vec2<i32>;
9-
type IVec3 = vec3<i32>;
10-
type IVec4 = vec4<i32>;
11-
type Mat3 = mat3x3<f32>;
12-
type Mat4x3 = mat4x3<f32>;
13-
type Mat4 = mat4x4<f32>;
2+
alias Vec2 = vec2<f32>;
3+
alias Vec3 = vec3<f32>;
4+
alias Vec4 = vec4<f32>;
5+
alias UVec2 = vec2<u32>;
6+
alias UVec3 = vec3<u32>;
7+
alias UVec4 = vec4<u32>;
8+
alias IVec2 = vec2<i32>;
9+
alias IVec3 = vec3<i32>;
10+
alias IVec4 = vec4<i32>;
11+
alias Mat3 = mat3x3<f32>;
12+
alias Mat4x3 = mat4x3<f32>;
13+
alias Mat4 = mat4x4<f32>;
1414

1515
// Extreme values as documented by the spec:
1616
// https://www.w3.org/TR/WGSL/#floating-point-types

crates/re_renderer/shader/utils/sphere_quad.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ fn sphere_quad_span_orthographic(point_pos: Vec3, point_radius: f32, top_bottom:
5656
}
5757

5858
/// Returns the index of the current quad.
59-
fn sphere_quad_index(vertex_idx: u32) -> i32 {
60-
return i32(vertex_idx) / 6;
59+
fn sphere_quad_index(vertex_idx: u32) -> u32 {
60+
return vertex_idx / 6u;
6161
}
6262

6363
struct SphereQuadData {

crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
use std::{num::NonZeroU32, sync::mpsc};
1+
use std::sync::mpsc;
22

3-
use crate::wgpu_resources::{BufferDesc, GpuBuffer, GpuBufferPool, Texture2DBufferInfo};
3+
use crate::{
4+
texture_info::Texture2DBufferInfo,
5+
wgpu_resources::{BufferDesc, GpuBuffer, GpuBufferPool},
6+
};
47

58
/// A sub-allocated staging buffer that can be written to.
69
///
@@ -119,7 +122,7 @@ where
119122
buffer: &self.chunk_buffer,
120123
layout: wgpu::ImageDataLayout {
121124
offset: self.byte_offset_in_chunk_buffer,
122-
bytes_per_row: NonZeroU32::new(buffer_info.bytes_per_row_padded),
125+
bytes_per_row: Some(buffer_info.bytes_per_row_padded),
123126
rows_per_image: None,
124127
},
125128
},
@@ -290,7 +293,7 @@ impl CpuWriteGpuReadBelt {
290293
);
291294
// Largest uncompressed texture format (btw. many compressed texture format have the same block size!)
292295
debug_assert!(
293-
wgpu::TextureFormat::Rgba32Uint.describe().block_size as u64
296+
wgpu::TextureFormat::Rgba32Uint.block_size(None).unwrap() as u64
294297
<= CpuWriteGpuReadBelt::MIN_OFFSET_ALIGNMENT
295298
);
296299

0 commit comments

Comments
 (0)