Skip to content

Commit

Permalink
GpuRenderPipelinePoolMemMoveAccessor -> GpuRenderPipelinePoolMoveAcce…
Browse files Browse the repository at this point in the history
…ssor, moved_render_pipelines -> pinned_render_pipelines
  • Loading branch information
Wumpf committed Dec 4, 2023
1 parent 30fdbf8 commit 41c718e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions crates/re_renderer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
global_bindings::GlobalBindings,
renderer::Renderer,
resource_managers::{MeshManager, TextureManager2D},
wgpu_resources::{GpuRenderPipelinePoolMemMoveAccessor, WgpuResourcePools},
wgpu_resources::{GpuRenderPipelinePoolMoveAccessor, WgpuResourcePools},
FileResolver, FileServer, FileSystem, RecommendedFileResolver,
};

Expand Down Expand Up @@ -185,7 +185,7 @@ impl RenderContext {
let active_frame = ActiveFrameContext {
before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&device)),
per_frame_data_helper: TypeMap::new(),
moved_render_pipelines: None,
pinned_render_pipelines: None,
frame_index: 0,
};

Expand Down Expand Up @@ -299,7 +299,7 @@ impl RenderContext {
self.gpu_readback_belt.get_mut().after_queue_submit();

// Give back moved render pipelines to the pool if any were moved out.
if let Some(moved_render_pipelines) = self.active_frame.moved_render_pipelines.take() {
if let Some(moved_render_pipelines) = self.active_frame.pinned_render_pipelines.take() {
self.gpu_resources
.render_pipelines
.return_resources(moved_render_pipelines);
Expand All @@ -309,7 +309,7 @@ impl RenderContext {
self.active_frame = ActiveFrameContext {
before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&self.device)),
frame_index: self.active_frame.frame_index + 1,
moved_render_pipelines: None,
pinned_render_pipelines: None,
per_frame_data_helper: TypeMap::new(),
};
let frame_index = self.active_frame.frame_index;
Expand Down Expand Up @@ -444,7 +444,7 @@ pub struct ActiveFrameContext {
/// Will be moved back to the resource pool at the start of the frame.
/// This is needed for accessing the render pipelines without keeping a reference
/// to the resource pool lock during the lifetime of a render pass.
pub moved_render_pipelines: Option<GpuRenderPipelinePoolMemMoveAccessor>,
pub pinned_render_pipelines: Option<GpuRenderPipelinePoolMoveAccessor>,

/// Index of this frame. Is incremented for every render frame.
frame_index: u64,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_renderer/src/wgpu_resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use pipeline_layout_pool::{
mod render_pipeline_pool;
pub use render_pipeline_pool::{
GpuRenderPipelineHandle, GpuRenderPipelinePool, GpuRenderPipelinePoolAccessor,
GpuRenderPipelinePoolMemMoveAccessor, RenderPipelineDesc, VertexBufferLayout,
GpuRenderPipelinePoolMoveAccessor, RenderPipelineDesc, VertexBufferLayout,
};

mod sampler_pool;
Expand Down
6 changes: 3 additions & 3 deletions crates/re_renderer/src/wgpu_resources/render_pipeline_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl RenderPipelineDesc {
pub type GpuRenderPipelinePoolAccessor<'a> =
dyn StaticResourcePoolAccessor<GpuRenderPipelineHandle, wgpu::RenderPipeline> + 'a;

pub type GpuRenderPipelinePoolMemMoveAccessor =
pub type GpuRenderPipelinePoolMoveAccessor =
StaticResourcePoolMemMoveAccessor<GpuRenderPipelineHandle, wgpu::RenderPipeline>;

#[derive(Default)]
Expand Down Expand Up @@ -256,14 +256,14 @@ impl GpuRenderPipelinePool {
/// This is useful when the existing resources need to be accessed without
/// taking a lock on the pool.
/// Resource can be put with `return_resources`.
pub fn take_resources(&mut self) -> GpuRenderPipelinePoolMemMoveAccessor {
pub fn take_resources(&mut self) -> GpuRenderPipelinePoolMoveAccessor {
self.pool.take_resources()
}

/// Counterpart to `take_resources`.
///
/// Logs an error if resources were added to the pool since `take_resources` was called.
pub fn return_resources(&mut self, resources: GpuRenderPipelinePoolMemMoveAccessor) {
pub fn return_resources(&mut self, resources: GpuRenderPipelinePoolMoveAccessor) {
self.pool.return_resources(resources);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
// This is a bit of a conundrum since we can't store a lock guard in the callback resources.
// So instead, we work around this by moving the render pipelines out of their lock!
// Future wgpu versions will lift this restriction and will allow us to remove this workaround.
if ctx.active_frame.moved_render_pipelines.is_none() {
if ctx.active_frame.pinned_render_pipelines.is_none() {
let render_pipelines = ctx.gpu_resources.render_pipelines.take_resources();
ctx.active_frame.moved_render_pipelines = Some(render_pipelines);
ctx.active_frame.pinned_render_pipelines = Some(render_pipelines);
}

Vec::new()
Expand All @@ -135,7 +135,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
);
return;
};
let Some(render_pipelines) = ctx.active_frame.moved_render_pipelines.as_ref() else {
let Some(render_pipelines) = ctx.active_frame.pinned_render_pipelines.as_ref() else {
re_log::error_once!(
"Failed to execute egui draw callback. Render pipelines weren't transferred out of the pool first."
);
Expand Down

0 comments on commit 41c718e

Please sign in to comment.