|
|
@@ -53,8 +53,9 @@ impl Renderer {
|
|
|
pub async fn new(window: &Window, path: &str) -> Self {
|
|
|
let size = window.inner_size();
|
|
|
|
|
|
- let instance = Instance::new(Backends::all());
|
|
|
- let surface = unsafe { instance.create_surface(window) };
|
|
|
+ let instance = Instance::new(InstanceDescriptor::default());
|
|
|
+ let surface = unsafe { instance.create_surface(window) }
|
|
|
+ .expect("Failed to create surface");
|
|
|
let adapter = instance.request_adapter(
|
|
|
// want to find the fastest gpu first, must support rendering to our surface
|
|
|
&RequestAdapterOptions {
|
|
|
@@ -75,16 +76,19 @@ impl Renderer {
|
|
|
None // Trace path
|
|
|
).await.expect("Failed to find a suitable physical device");
|
|
|
|
|
|
+ let caps = surface.get_capabilities(&adapter);
|
|
|
+ let format = *caps.formats
|
|
|
+ .first()
|
|
|
+ .expect("Surface has no preferred format");
|
|
|
let config = SurfaceConfiguration {
|
|
|
// using the surface to write to the window
|
|
|
usage: TextureUsages::RENDER_ATTACHMENT,
|
|
|
- format: *surface.get_supported_formats(&adapter)
|
|
|
- .first()
|
|
|
- .expect("Surface has no preferred format"),
|
|
|
+ format,
|
|
|
width: size.width,
|
|
|
height: size.height,
|
|
|
present_mode: PresentMode::AutoVsync,
|
|
|
- alpha_mode: CompositeAlphaMode::Auto
|
|
|
+ alpha_mode: CompositeAlphaMode::Auto,
|
|
|
+ view_formats: vec![format]
|
|
|
};
|
|
|
surface.configure(&device, &config);
|
|
|
|
|
|
@@ -229,18 +233,20 @@ impl Renderer {
|
|
|
a: 1.0
|
|
|
}),
|
|
|
// keep what is rendered
|
|
|
- store: true
|
|
|
+ store: StoreOp::Store
|
|
|
}
|
|
|
})],
|
|
|
// boy thats a mouthful
|
|
|
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
|
|
|
view: &self.depth.view,
|
|
|
depth_ops: Some(Operations {
|
|
|
- load: wgpu::LoadOp::Clear(1.0),
|
|
|
- store: true
|
|
|
+ load: LoadOp::Clear(1.0),
|
|
|
+ store: StoreOp::Store
|
|
|
}),
|
|
|
stencil_ops: None
|
|
|
- })
|
|
|
+ }),
|
|
|
+ timestamp_writes: None,
|
|
|
+ occlusion_query_set: None
|
|
|
});
|
|
|
|
|
|
pass.set_pipeline(&self.mesh_pipeline);
|