Skip to content

Commit 8e4b0d8

Browse files
committed
comment fixes
1 parent 549cbd3 commit 8e4b0d8

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

crates/re_renderer/src/view_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl ViewBuilder {
554554
// Renderers can't be added anyways at this point (RendererData add their Renderer on creation),
555555
// so no point in taking the lock repeatedly.
556556
//
557-
// Note that this is a limitation that will be lifted in future versions of wgpu.
557+
// TODO(gfx-rs/wgpu#1453): Note that this is a limitation that will be lifted in future versions of wgpu.
558558
// However, having our locking concentrated for the duration of a view draw
559559
// is also beneficial since it enforces the model of prepare->draw which avoids a lot of repeated
560560
// locking and unlocking.

crates/re_renderer/src/wgpu_resources/static_resource_pool.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,24 @@ where
4949
Desc: std::fmt::Debug + Clone + Eq + Hash,
5050
{
5151
pub fn get_or_create<F: FnOnce(&Desc) -> Res>(&self, desc: &Desc, creation_func: F) -> Handle {
52-
{
53-
// Ensure the lock isn't held in the creation case.
54-
if let Some(handle) = self.lookup.read().get(desc) {
55-
return *handle;
56-
}
52+
// Ensure the lock isn't held in the creation case.
53+
if let Some(handle) = self.lookup.read().get(desc) {
54+
return *handle;
5755
}
58-
{
59-
re_tracing::profile_scope!(
60-
"Creating new static resource",
61-
std::any::type_name::<Res>()
62-
);
6356

64-
let resource = creation_func(desc);
65-
let handle = self.resources.write().insert(StoredResource {
66-
resource,
67-
statistics: ResourceStatistics {
68-
frame_created: self.current_frame_index,
69-
last_frame_used: self.current_frame_index.into(),
70-
},
71-
});
72-
self.lookup.write().insert(desc.clone(), handle);
57+
re_tracing::profile_scope!("Creating new static resource", std::any::type_name::<Res>());
7358

74-
handle
75-
}
59+
let resource = creation_func(desc);
60+
let handle = self.resources.write().insert(StoredResource {
61+
resource,
62+
statistics: ResourceStatistics {
63+
frame_created: self.current_frame_index,
64+
last_frame_used: self.current_frame_index.into(),
65+
},
66+
});
67+
self.lookup.write().insert(desc.clone(), handle);
68+
69+
handle
7670
}
7771

7872
pub fn recreate_resources<F: FnMut(&Desc) -> Option<Res>>(&mut self, mut recreation_func: F) {
@@ -137,6 +131,7 @@ fn to_pool_error<T>(get_result: Option<T>, handle: impl Key) -> Result<T, PoolEr
137131
})
138132
}
139133

134+
/// Accessor to the resource pool, either by taking a read lock or by moving out the resources.
140135
pub trait StaticResourcePoolAccessor<Handle: Key, Res> {
141136
fn get(&self, handle: Handle) -> Result<&Res, PoolError>;
142137
}

crates/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
7171
return Vec::new();
7272
};
7373

74-
let command_buffer = match view_builder.draw(ctx, self.clear_color) {
74+
match view_builder.draw(ctx, self.clear_color) {
7575
Ok(command_buffer) => {
7676
// If drawing worked, put the view_builder back in so we can use it during paint.
7777
ctx.active_frame
@@ -90,9 +90,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
9090
// TODO(andreas): It would be nice to paint an error message instead.
9191
Vec::new()
9292
}
93-
};
94-
95-
command_buffer
93+
}
9694
}
9795

9896
fn finish_prepare(
@@ -114,7 +112,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
114112
// are longer lived than the pass itself.
115113
// This is a bit of a conundrum since we can't store a lock guard in the callback resources.
116114
// So instead, we work around this by moving the render pipelines out of their lock!
117-
// Future wgpu versions will lift this restriction and will allow us to remove this workaround.
115+
// TODO(gfx-rs/wgpu#1453): Future wgpu versions will lift this restriction and will allow us to remove this workaround.
118116
if ctx.active_frame.pinned_render_pipelines.is_none() {
119117
let render_pipelines = ctx.gpu_resources.render_pipelines.take_resources();
120118
ctx.active_frame.pinned_render_pipelines = Some(render_pipelines);
@@ -130,12 +128,14 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
130128
paint_callback_resources: &'a egui_wgpu::CallbackResources,
131129
) {
132130
let Some(ctx) = paint_callback_resources.get::<re_renderer::RenderContext>() else {
131+
// TODO(#4433): Shouldn't show up like this.
133132
re_log::error_once!(
134133
"Failed to execute egui draw callback. No render context available."
135134
);
136135
return;
137136
};
138137
let Some(render_pipelines) = ctx.active_frame.pinned_render_pipelines.as_ref() else {
138+
// TODO(#4433): Shouldn't show up like this.
139139
re_log::error_once!(
140140
"Failed to execute egui draw callback. Render pipelines weren't transferred out of the pool first."
141141
);
@@ -148,6 +148,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
148148
.get::<ViewBuilderMap>()
149149
.and_then(|view_builder_map| view_builder_map.get(self.view_builder))
150150
else {
151+
// TODO(#4433): Shouldn't show up like this.
151152
re_log::error_once!(
152153
"Failed to execute egui draw callback. View builder with handle {:?} not found.",
153154
self.view_builder

0 commit comments

Comments
 (0)