-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34fe670
commit 2eb9c73
Showing
7 changed files
with
68 additions
and
5 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
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,56 @@ | ||
use crate::{Adapter, DeviceError, SurfaceCapabilities, TextureFormatCapabilities}; | ||
|
||
use super::{DynDevice, DynQueue, DynResource, DynResourceExt, DynSurface}; | ||
|
||
pub struct DynOpenDevice { | ||
pub device: Box<dyn DynDevice>, | ||
pub queue: Box<dyn DynQueue>, | ||
} | ||
|
||
pub trait DynAdapter: DynResource { | ||
unsafe fn open( | ||
&self, | ||
features: wgt::Features, | ||
limits: &wgt::Limits, | ||
memory_hints: &wgt::MemoryHints, | ||
) -> Result<DynOpenDevice, DeviceError>; | ||
|
||
unsafe fn texture_format_capabilities( | ||
&self, | ||
format: wgt::TextureFormat, | ||
) -> TextureFormatCapabilities; | ||
|
||
unsafe fn surface_capabilities(&self, surface: &dyn DynSurface) -> Option<SurfaceCapabilities>; | ||
|
||
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp; | ||
} | ||
|
||
impl<A: Adapter + DynResource> DynAdapter for A { | ||
unsafe fn open( | ||
&self, | ||
features: wgt::Features, | ||
limits: &wgt::Limits, | ||
memory_hints: &wgt::MemoryHints, | ||
) -> Result<DynOpenDevice, DeviceError> { | ||
unsafe { A::open(self, features, limits, memory_hints) }.map(|open_device| DynOpenDevice { | ||
device: Box::new(open_device.device), | ||
queue: Box::new(open_device.queue), | ||
}) | ||
} | ||
|
||
unsafe fn texture_format_capabilities( | ||
&self, | ||
format: wgt::TextureFormat, | ||
) -> TextureFormatCapabilities { | ||
unsafe { A::texture_format_capabilities(self, format) } | ||
} | ||
|
||
unsafe fn surface_capabilities(&self, surface: &dyn DynSurface) -> Option<SurfaceCapabilities> { | ||
let surface = surface.expect_downcast_ref(); | ||
unsafe { A::surface_capabilities(self, surface) } | ||
} | ||
|
||
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp { | ||
unsafe { A::get_presentation_timestamp(self) } | ||
} | ||
} |
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
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
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
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
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