create surface on same thread?
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
/target
|
||||
flamegraph.svg
|
||||
perf.data*
|
||||
|
||||
491
flamegraph.svg
491
flamegraph.svg
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 201 KiB |
BIN
perf.data.old
BIN
perf.data.old
Binary file not shown.
@@ -13,10 +13,7 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use voxel::VoxelPipeline;
|
||||
use winit::{
|
||||
dpi::PhysicalSize,
|
||||
window::{Fullscreen, Window},
|
||||
};
|
||||
use winit::dpi::PhysicalSize;
|
||||
|
||||
pub struct Renderer<'a> {
|
||||
size: Vector2<u32>,
|
||||
@@ -34,23 +31,11 @@ pub struct Renderer<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Renderer<'a> {
|
||||
pub fn new(window: Arc<Window>) -> Self {
|
||||
let fullscreen = false;
|
||||
if fullscreen {
|
||||
window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
||||
}
|
||||
|
||||
let size = window.inner_size();
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::PRIMARY,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let surface = instance
|
||||
.create_surface(window)
|
||||
.expect("Could not create window surface!");
|
||||
|
||||
pub fn new(
|
||||
instance: wgpu::Instance,
|
||||
surface: wgpu::Surface<'a>,
|
||||
size: PhysicalSize<u32>,
|
||||
) -> Self {
|
||||
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
|
||||
power_preference: wgpu::PowerPreference::default(),
|
||||
compatible_surface: Some(&surface),
|
||||
|
||||
@@ -34,10 +34,21 @@ pub struct CreateVoxelGrid {
|
||||
impl Renderer<'_> {
|
||||
pub fn spawn(window: Arc<Window>) -> (RendererChannel, JoinHandle<()>) {
|
||||
let (s, mut r) = channel();
|
||||
|
||||
let size = window.inner_size();
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::PRIMARY,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let surface = instance
|
||||
.create_surface(window)
|
||||
.expect("Could not create window surface!");
|
||||
(
|
||||
s,
|
||||
std::thread::spawn(move || {
|
||||
Self::new(window.clone()).start(&mut r);
|
||||
Self::new(instance, surface, size).start(&mut r);
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user