Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderContext::new() needn't return Result. #547

Merged
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
3 changes: 1 addition & 2 deletions crates/tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ pub fn render_sync(scene: Scene, params: &TestParams) -> Result<Image> {
}

pub async fn render(scene: Scene, params: &TestParams) -> Result<Image> {
let mut context = RenderContext::new()
.or_else(|_| bail!("Got non-Send/Sync error from creating render context"))?;
let mut context = RenderContext::new();
let device_id = context
.device(None)
.await
Expand Down
3 changes: 1 addition & 2 deletions examples/headless/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ fn main() -> Result<()> {
}

async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
let mut context = RenderContext::new()
.or_else(|_| bail!("Got non-Send/Sync error from creating render context"))?;
let mut context = RenderContext::new();
let device_id = context
.device(None)
.await
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() -> Result<()> {
// Setup a bunch of state:

// The vello RenderContext which is a global context that lasts for the lifetime of the application
let mut render_cx = RenderContext::new().unwrap();
let mut render_cx = RenderContext::new();

// An array of renderers, one per wgpu device
let mut renderers: Vec<Option<Renderer>> = vec![];
Expand Down
4 changes: 2 additions & 2 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ pub fn main() -> anyhow::Result<()> {
if let Some(scenes) = scenes {
let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build()?;
#[allow(unused_mut)]
let mut render_cx = RenderContext::new().unwrap();
let mut render_cx = RenderContext::new();
#[cfg(not(target_arch = "wasm32"))]
{
let proxy = event_loop.create_proxy();
Expand Down Expand Up @@ -836,7 +836,7 @@ fn android_main(app: AndroidApp) {
.select_scene_set(|| Args::command())
.unwrap()
.unwrap();
let render_cx = RenderContext::new().unwrap();
let render_cx = RenderContext::new();

run(event_loop, args, scenes, render_cx);
}
7 changes: 4 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ pub struct DeviceHandle {
}

impl RenderContext {
pub fn new() -> Result<Self> {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
let instance = Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY),
dx12_shader_compiler: wgpu::Dx12Compiler::Fxc,
..Default::default()
});
Ok(Self {
Self {
instance,
devices: Vec::new(),
})
}
}

/// Creates a new surface for the specified window and dimensions.
Expand Down