-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2035 from hannobraun/render
Add debug logging, improve error messages, shuffle some render stuff around
- Loading branch information
Showing
3 changed files
with
119 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#[derive(Debug)] | ||
pub struct Device { | ||
pub device: wgpu::Device, | ||
pub queue: wgpu::Queue, | ||
} | ||
|
||
impl Device { | ||
pub async fn new( | ||
adapter: &wgpu::Adapter, | ||
) -> Result<(Self, wgpu::Features), wgpu::RequestDeviceError> { | ||
let features = { | ||
let desired_features = wgpu::Features::POLYGON_MODE_LINE; | ||
let available_features = adapter.features(); | ||
|
||
// By requesting the intersection of desired and available features, | ||
// we prevent two things: | ||
// | ||
// 1. That requesting the device panics, which would happen if we | ||
// requested unavailable features. | ||
// 2. That a developer ends up accidentally using features that | ||
// happen to be available on their machine, but that aren't | ||
// necessarily available for all the users. | ||
desired_features.intersection(available_features) | ||
}; | ||
|
||
let limits = { | ||
// This is the lowest of the available defaults. It should guarantee | ||
// that we can run pretty much everywhere. | ||
let lowest_limits = wgpu::Limits::downlevel_webgl2_defaults(); | ||
|
||
// However, these lowest limits aren't necessarily capable of | ||
// supporting the screen resolution of our current platform, so | ||
// let's amend them. | ||
let supported_limits = adapter.limits(); | ||
lowest_limits.using_resolution(supported_limits) | ||
}; | ||
|
||
let (device, queue) = adapter | ||
.request_device( | ||
&wgpu::DeviceDescriptor { | ||
label: None, | ||
features, | ||
limits, | ||
}, | ||
None, | ||
) | ||
.await?; | ||
|
||
Ok((Device { device, queue }, features)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
//! Rendering primitives, routines, and structures. | ||
mod device; | ||
mod draw_config; | ||
mod drawables; | ||
mod geometries; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters