[−][src]Struct truck_platform::DeviceHandler
Chain that holds Device, Queue and SwapChainDescriptor.
This struct is used for creating Scene.
Device and Queue must be wrapped Arc,
and SwapChainDescriptor Arc<Mutex>.
Examples
use std::sync::{Arc, Mutex}; use truck_platform::*; use wgpu::*; let instance = Instance::new(BackendBit::PRIMARY); let (device, queue) = futures::executor::block_on(async { let adapter = instance .request_adapter(&RequestAdapterOptions { power_preference: PowerPreference::Default, compatible_surface: None, }) .await .unwrap(); adapter .request_device( &DeviceDescriptor { features: Default::default(), limits: Limits::default(), shader_validation: true, }, None, ) .await .unwrap() }); let sc_desc = SwapChainDescriptor { usage: TextureUsage::OUTPUT_ATTACHMENT, format: TextureFormat::Bgra8UnormSrgb, width: 512, height: 512, present_mode: PresentMode::Mailbox, }; // creates SwapChain or Texture to draw by Scene. let device_handler = DeviceHandler::new( Arc::new(device), Arc::new(queue), Arc::new(Mutex::new(sc_desc)), );
Implementations
impl DeviceHandler[src]
pub fn new(
device: Arc<Device>,
queue: Arc<Queue>,
sc_desc: Arc<Mutex<SwapChainDescriptor>>
) -> DeviceHandler[src]
device: Arc<Device>,
queue: Arc<Queue>,
sc_desc: Arc<Mutex<SwapChainDescriptor>>
) -> DeviceHandler
constructor
pub fn device(&self) -> &Arc<Device>[src]
Returns the reference of the device.
pub fn queue(&self) -> &Arc<Queue>[src]
Returns the reference of the queue.
pub fn sc_desc(&self) -> SwapChainDescriptor[src]
Returns the copy of swap chain descriptor.
pub fn lock_sc_desc(&self) -> LockResult<MutexGuard<'_, SwapChainDescriptor>>[src]
Locks the swap chain descriptor.
Trait Implementations
impl Clone for DeviceHandler[src]
pub fn clone(&self) -> DeviceHandler[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for DeviceHandler[src]
Auto Trait Implementations
impl !RefUnwindSafe for DeviceHandler[src]
impl Send for DeviceHandler[src]
impl Sync for DeviceHandler[src]
impl Unpin for DeviceHandler[src]
impl !UnwindSafe for DeviceHandler[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,