mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
zest prefers this over await
This commit is contained in:
parent
32e58c4b17
commit
889a8d11f5
@ -232,7 +232,7 @@ fn main() {
|
||||
|
||||
// Create window
|
||||
use veloren_voxygen::{error::Error, render::RenderError};
|
||||
let (mut window, event_loop) = match tokio_runtime.block_on(Window::new(&settings)) {
|
||||
let (mut window, event_loop) = match Window::new(&settings, &tokio_runtime) {
|
||||
Ok(ok) => ok,
|
||||
// Custom panic message when a graphics backend could not be found
|
||||
Err(Error::RenderError(RenderError::CouldNotFindAdapter)) => {
|
||||
|
@ -183,9 +183,10 @@ pub struct Renderer {
|
||||
impl Renderer {
|
||||
/// Create a new `Renderer` from a variety of backend-specific components
|
||||
/// and the window targets.
|
||||
pub async fn new(
|
||||
pub fn new(
|
||||
window: &winit::window::Window,
|
||||
mode: RenderMode,
|
||||
runtime: &tokio::runtime::Runtime,
|
||||
) -> Result<Self, RenderError> {
|
||||
let (pipeline_modes, mut other_modes) = mode.split();
|
||||
// Enable seamless cubemaps globally, where available--they are essentially a
|
||||
@ -223,12 +224,11 @@ impl Renderer {
|
||||
#[allow(unsafe_code)]
|
||||
let surface = unsafe { instance.create_surface(window) };
|
||||
|
||||
let adapter = instance
|
||||
.request_adapter(&wgpu::RequestAdapterOptionsBase {
|
||||
let adapter = runtime
|
||||
.block_on(instance.request_adapter(&wgpu::RequestAdapterOptionsBase {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: Some(&surface),
|
||||
})
|
||||
.await
|
||||
}))
|
||||
.ok_or(RenderError::CouldNotFindAdapter)?;
|
||||
|
||||
let info = adapter.get_info();
|
||||
@ -271,20 +271,18 @@ impl Renderer {
|
||||
|
||||
path
|
||||
});
|
||||
let (device, queue) = adapter
|
||||
.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
// TODO
|
||||
label: None,
|
||||
features: wgpu::Features::DEPTH_CLAMPING
|
||||
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
|
||||
| wgpu::Features::PUSH_CONSTANTS
|
||||
| (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES),
|
||||
limits,
|
||||
},
|
||||
trace_path.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
let (device, queue) = runtime.block_on(adapter.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
// TODO
|
||||
label: None,
|
||||
features: wgpu::Features::DEPTH_CLAMPING
|
||||
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
|
||||
| wgpu::Features::PUSH_CONSTANTS
|
||||
| (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES),
|
||||
limits,
|
||||
},
|
||||
trace_path.as_deref(),
|
||||
))?;
|
||||
|
||||
// Set error handler for wgpu errors
|
||||
// This is better for use than their default because it includes the error in
|
||||
|
@ -398,7 +398,10 @@ pub struct Window {
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub async fn new(settings: &Settings) -> Result<(Window, EventLoop), Error> {
|
||||
pub fn new(
|
||||
settings: &Settings,
|
||||
runtime: &tokio::runtime::Runtime,
|
||||
) -> Result<(Window, EventLoop), Error> {
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
let size = settings.graphics.window_size;
|
||||
@ -418,7 +421,7 @@ impl Window {
|
||||
|
||||
let window = win_builder.build(&event_loop).unwrap();
|
||||
|
||||
let renderer = Renderer::new(&window, settings.graphics.render_mode.clone()).await?;
|
||||
let renderer = Renderer::new(&window, settings.graphics.render_mode.clone(), runtime)?;
|
||||
|
||||
let keypress_map = HashMap::new();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user