Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions vello_gpu/src/render/wgpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl Renderer {
render_target_config,
layer_config,
resource_texture_dimension_2d,
settings.pipeline_cache.as_ref(),
),
gradient_cache,
encoded_paints: Vec::new(),
Expand Down Expand Up @@ -1105,6 +1106,7 @@ impl Programs {
render_target_config: &RenderTargetConfig,
layer_config: LayersConfig,
resource_texture_dimension_2d: u32,
pipeline_cache: Option<&wgpu::PipelineCache>,
) -> Self {
let strip_bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
Expand Down Expand Up @@ -1260,7 +1262,7 @@ impl Programs {
depth_stencil,
multisample: wgpu::MultisampleState::default(),
multiview_mask: None,
cache: None,
cache: pipeline_cache,
})
};

Expand Down Expand Up @@ -1337,7 +1339,7 @@ impl Programs {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview_mask: None,
cache: None,
cache: pipeline_cache,
})
};
let clear_pipeline =
Expand Down Expand Up @@ -1380,7 +1382,7 @@ impl Programs {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview_mask: None,
cache: None,
cache: pipeline_cache,
});

let filter_texture_entry = wgpu::BindGroupLayoutEntry {
Expand Down Expand Up @@ -1481,7 +1483,7 @@ impl Programs {
},
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
cache: None,
cache: pipeline_cache,
multiview_mask: None,
});

Expand Down Expand Up @@ -1610,7 +1612,7 @@ impl Programs {
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview_mask: None,
cache: None,
cache: pipeline_cache,
})
};
let blend_pipeline = create_texture_op_pipeline(
Expand Down
10 changes: 9 additions & 1 deletion vello_gpu/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ impl Drawable for RecordedDraw {
}

/// Settings to apply to the render context.
#[derive(Copy, Clone, Debug)]
#[derive(Clone, Debug)]
pub struct RenderSettings {
/// The SIMD level that should be used for rendering operations.
pub level: Level,
/// Configuration for GPU memory used while rendering.
pub memory_settings: MemorySettings,
/// Optional cache used when creating the wgpu render pipelines - can substantially
/// reduce startup times (especially on low tier devices).
///
/// Requires [`wgpu::Features::PIPELINE_CACHE`] on the device.
#[cfg(feature = "wgpu")]
pub pipeline_cache: Option<wgpu::PipelineCache>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having public struct fields gated behind features is usually a bad idea. If someone depends on Vello GPU to only use the WebGL backend, but then some other dependency in the tree activates the wgpu backend as well, their code will fail to compile. I think we should either make the fields in RenderSettings private and turn it into a builder pattern, or instead have new_with take the pipeline cache directly. The second is probably easier for now? Even if it requires updating more call sites.

}

/// Settings controlling usage of GPU memory.
Expand Down Expand Up @@ -197,6 +203,8 @@ impl Default for RenderSettings {
Self {
level: Level::try_detect().unwrap_or(Level::baseline()),
memory_settings: MemorySettings::default(),
#[cfg(feature = "wgpu")]
pipeline_cache: None,
}
}
}
Expand Down
Loading