@@ -446,7 +446,7 @@ pub struct ComputePipelineDescriptor<'a> {
446
446
}
447
447
448
448
pub type RenderPassColorAttachmentDescriptor < ' a > =
449
- wgt:: RenderPassColorAttachmentDescriptorBase < & ' a TextureView , Option < & ' a TextureView > > ;
449
+ wgt:: RenderPassColorAttachmentDescriptorBase < & ' a TextureView > ;
450
450
pub type RenderPassDepthStencilAttachmentDescriptor < ' a > =
451
451
wgt:: RenderPassDepthStencilAttachmentDescriptorBase < & ' a TextureView > ;
452
452
@@ -623,26 +623,26 @@ impl Adapter {
623
623
/// If no adapters are found that suffice all the "hard" options, `None` is returned.
624
624
pub async fn request ( options : & RequestAdapterOptions < ' _ > , backends : BackendBit ) -> Option < Self > {
625
625
unsafe extern "C" fn adapter_callback (
626
- id : wgc:: id:: AdapterId ,
626
+ id : Option < wgc:: id:: AdapterId > ,
627
627
user_data : * mut std:: ffi:: c_void ,
628
628
) {
629
- * ( user_data as * mut wgc:: id:: AdapterId ) = id;
629
+ * ( user_data as * mut Option < wgc:: id:: AdapterId > ) = id;
630
630
}
631
631
632
- let mut id = wgc :: id :: AdapterId :: ERROR ;
632
+ let mut id_maybe = None ;
633
633
unsafe {
634
634
wgn:: wgpu_request_adapter_async (
635
635
Some ( & wgc:: instance:: RequestAdapterOptions {
636
636
power_preference : options. power_preference ,
637
637
compatible_surface : options. compatible_surface
638
- . map_or ( wgc :: id :: SurfaceId :: ERROR , |surface| surface. id ) ,
638
+ . map ( |surface| surface. id ) ,
639
639
} ) ,
640
640
backends,
641
641
adapter_callback,
642
- & mut id as * mut _ as * mut std:: ffi:: c_void ,
642
+ & mut id_maybe as * mut _ as * mut std:: ffi:: c_void ,
643
643
)
644
644
} ;
645
- Some ( Adapter { id } )
645
+ id_maybe . map ( |id| Adapter { id } )
646
646
}
647
647
648
648
/// Requests a connection to a physical device, creating a logical device.
@@ -1228,7 +1228,7 @@ impl CommandEncoder {
1228
1228
. iter ( )
1229
1229
. map ( |ca| wgc:: command:: RenderPassColorAttachmentDescriptor {
1230
1230
attachment : ca. attachment . id ,
1231
- resolve_target : ca. resolve_target . map ( |rt| & rt. id ) ,
1231
+ resolve_target : ca. resolve_target . map ( |rt| rt. id ) ,
1232
1232
load_op : ca. load_op ,
1233
1233
store_op : ca. store_op ,
1234
1234
clear_color : ca. clear_color ,
@@ -1633,26 +1633,24 @@ impl Drop for SwapChainOutput {
1633
1633
}
1634
1634
}
1635
1635
1636
+ /// The GPU timed out when attempting to acquire the next texture or if a
1637
+ /// previous output is still alive.
1638
+ #[ derive( Clone , Debug ) ]
1639
+ pub struct TimeOut ;
1640
+
1636
1641
impl SwapChain {
1637
1642
/// Returns the next texture to be presented by the swapchain for drawing.
1638
1643
///
1639
1644
/// When the [`SwapChainOutput`] returned by this method is dropped, the swapchain will present
1640
1645
/// the texture to the associated [`Surface`].
1641
- ///
1642
- /// Returns an `Err` if the GPU timed out when attempting to acquire the next texture or if a
1643
- /// previous output is still alive.
1644
- pub fn get_next_texture ( & mut self ) -> Result < SwapChainOutput , ( ) > {
1646
+ pub fn get_next_texture ( & mut self ) -> Result < SwapChainOutput , TimeOut > {
1645
1647
let output = wgn:: wgpu_swap_chain_get_next_texture ( self . id ) ;
1646
- if output. view_id == wgc:: id:: Id :: ERROR {
1647
- Err ( ( ) )
1648
- } else {
1649
- Ok ( SwapChainOutput {
1650
- view : TextureView {
1651
- id : output. view_id ,
1652
- owned : false ,
1653
- } ,
1648
+ match output. view_id {
1649
+ Some ( id) => Ok ( SwapChainOutput {
1650
+ view : TextureView { id, owned : false } ,
1654
1651
swap_chain_id : self . id ,
1655
- } )
1652
+ } ) ,
1653
+ None => Err ( TimeOut ) ,
1656
1654
}
1657
1655
}
1658
1656
}
0 commit comments