4
4
5
5
#![ cfg_attr( docsrs, feature( doc_cfg, doc_auto_cfg) ) ]
6
6
#![ doc( html_logo_url = "https://raw.githubusercontent.com/gfx-rs/wgpu/master/logo.png" ) ]
7
- #![ warn( missing_docs) ]
7
+ #![ warn( missing_docs, unsafe_op_in_unsafe_fn ) ]
8
8
9
9
mod backend;
10
10
pub mod util;
@@ -1738,7 +1738,7 @@ impl Instance {
1738
1738
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "emscripten" ) ) ]
1739
1739
pub unsafe fn from_hal < A : wgc:: hub:: HalApi > ( hal_instance : A :: Instance ) -> Self {
1740
1740
Self {
1741
- context : Arc :: new ( C :: from_hal_instance :: < A > ( hal_instance) ) ,
1741
+ context : Arc :: new ( unsafe { C :: from_hal_instance :: < A > ( hal_instance) } ) ,
1742
1742
}
1743
1743
}
1744
1744
@@ -1754,7 +1754,7 @@ impl Instance {
1754
1754
/// [`Instance`]: hal::Api::Instance
1755
1755
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "webgl" ) ) ]
1756
1756
pub unsafe fn as_hal < A : wgc:: hub:: HalApi > ( & self ) -> Option < & A :: Instance > {
1757
- self . context . instance_as_hal :: < A > ( )
1757
+ unsafe { self . context . instance_as_hal :: < A > ( ) }
1758
1758
}
1759
1759
1760
1760
/// Create an new instance of wgpu from a wgpu-core instance.
@@ -1769,7 +1769,7 @@ impl Instance {
1769
1769
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "webgl" ) ) ]
1770
1770
pub unsafe fn from_core ( core_instance : wgc:: instance:: Instance ) -> Self {
1771
1771
Self {
1772
- context : Arc :: new ( C :: from_core_instance ( core_instance) ) ,
1772
+ context : Arc :: new ( unsafe { C :: from_core_instance ( core_instance) } ) ,
1773
1773
}
1774
1774
}
1775
1775
@@ -1815,7 +1815,7 @@ impl Instance {
1815
1815
hal_adapter : hal:: ExposedAdapter < A > ,
1816
1816
) -> Adapter {
1817
1817
let context = Arc :: clone ( & self . context ) ;
1818
- let id = context. create_adapter_from_hal ( hal_adapter) ;
1818
+ let id = unsafe { context. create_adapter_from_hal ( hal_adapter) } ;
1819
1819
Adapter { context, id }
1820
1820
}
1821
1821
@@ -1855,7 +1855,7 @@ impl Instance {
1855
1855
& self ,
1856
1856
layer : * mut std:: ffi:: c_void ,
1857
1857
) -> Surface {
1858
- self . context . create_surface_from_core_animation_layer ( layer)
1858
+ unsafe { self . context . create_surface_from_core_animation_layer ( layer) }
1859
1859
}
1860
1860
1861
1861
/// Creates a surface from `IDCompositionVisual`.
@@ -1865,7 +1865,7 @@ impl Instance {
1865
1865
/// - visual must be a valid IDCompositionVisual to create a surface upon.
1866
1866
#[ cfg( target_os = "windows" ) ]
1867
1867
pub unsafe fn create_surface_from_visual ( & self , visual : * mut std:: ffi:: c_void ) -> Surface {
1868
- self . context . create_surface_from_visual ( visual)
1868
+ unsafe { self . context . create_surface_from_visual ( visual) }
1869
1869
}
1870
1870
1871
1871
/// Creates a surface from a `web_sys::HtmlCanvasElement`.
@@ -1978,20 +1978,22 @@ impl Adapter {
1978
1978
trace_path : Option < & std:: path:: Path > ,
1979
1979
) -> Result < ( Device , Queue ) , RequestDeviceError > {
1980
1980
let context = Arc :: clone ( & self . context ) ;
1981
- self . context
1982
- . create_device_from_hal ( & self . id , hal_device, desc, trace_path)
1983
- . map ( |( device_id, queue_id) | {
1984
- (
1985
- Device {
1986
- context : Arc :: clone ( & context) ,
1987
- id : device_id,
1988
- } ,
1989
- Queue {
1990
- context,
1991
- id : queue_id,
1992
- } ,
1993
- )
1994
- } )
1981
+ unsafe {
1982
+ self . context
1983
+ . create_device_from_hal ( & self . id , hal_device, desc, trace_path)
1984
+ }
1985
+ . map ( |( device_id, queue_id) | {
1986
+ (
1987
+ Device {
1988
+ context : Arc :: clone ( & context) ,
1989
+ id : device_id,
1990
+ } ,
1991
+ Queue {
1992
+ context,
1993
+ id : queue_id,
1994
+ } ,
1995
+ )
1996
+ } )
1995
1997
}
1996
1998
1997
1999
/// Apply a callback to this `Adapter`'s underlying backend adapter.
@@ -2018,8 +2020,10 @@ impl Adapter {
2018
2020
& self ,
2019
2021
hal_adapter_callback : F ,
2020
2022
) -> R {
2021
- self . context
2022
- . adapter_as_hal :: < A , F , R > ( self . id , hal_adapter_callback)
2023
+ unsafe {
2024
+ self . context
2025
+ . adapter_as_hal :: < A , F , R > ( self . id , hal_adapter_callback)
2026
+ }
2023
2027
}
2024
2028
2025
2029
/// Returns whether this adapter may present to the passed surface.
@@ -2119,12 +2123,14 @@ impl Device {
2119
2123
) -> ShaderModule {
2120
2124
ShaderModule {
2121
2125
context : Arc :: clone ( & self . context ) ,
2122
- id : Context :: device_create_shader_module (
2123
- & * self . context ,
2124
- & self . id ,
2125
- desc,
2126
- wgt:: ShaderBoundChecks :: unchecked ( ) ,
2127
- ) ,
2126
+ id : unsafe {
2127
+ Context :: device_create_shader_module (
2128
+ & * self . context ,
2129
+ & self . id ,
2130
+ desc,
2131
+ wgt:: ShaderBoundChecks :: unchecked ( ) ,
2132
+ )
2133
+ } ,
2128
2134
}
2129
2135
}
2130
2136
@@ -2142,7 +2148,9 @@ impl Device {
2142
2148
) -> ShaderModule {
2143
2149
ShaderModule {
2144
2150
context : Arc :: clone ( & self . context ) ,
2145
- id : Context :: device_create_shader_module_spirv ( & * self . context , & self . id , desc) ,
2151
+ id : unsafe {
2152
+ Context :: device_create_shader_module_spirv ( & * self . context , & self . id , desc)
2153
+ } ,
2146
2154
}
2147
2155
}
2148
2156
@@ -2252,9 +2260,10 @@ impl Device {
2252
2260
) -> Texture {
2253
2261
Texture {
2254
2262
context : Arc :: clone ( & self . context ) ,
2255
- id : self
2256
- . context
2257
- . create_texture_from_hal :: < A > ( hal_texture, & self . id , desc) ,
2263
+ id : unsafe {
2264
+ self . context
2265
+ . create_texture_from_hal :: < A > ( hal_texture, & self . id , desc)
2266
+ } ,
2258
2267
owned : true ,
2259
2268
}
2260
2269
}
@@ -2326,8 +2335,10 @@ impl Device {
2326
2335
& self ,
2327
2336
hal_device_callback : F ,
2328
2337
) -> R {
2329
- self . context
2330
- . device_as_hal :: < A , F , R > ( & self . id , hal_device_callback)
2338
+ unsafe {
2339
+ self . context
2340
+ . device_as_hal :: < A , F , R > ( & self . id , hal_device_callback)
2341
+ }
2331
2342
}
2332
2343
}
2333
2344
@@ -2637,8 +2648,10 @@ impl Texture {
2637
2648
& self ,
2638
2649
hal_texture_callback : F ,
2639
2650
) {
2640
- self . context
2641
- . texture_as_hal :: < A , F > ( & self . id , hal_texture_callback)
2651
+ unsafe {
2652
+ self . context
2653
+ . texture_as_hal :: < A , F > ( & self . id , hal_texture_callback)
2654
+ }
2642
2655
}
2643
2656
2644
2657
/// Creates a view of this texture.
@@ -3795,8 +3808,10 @@ impl Surface {
3795
3808
& mut self ,
3796
3809
hal_surface_callback : F ,
3797
3810
) -> R {
3798
- self . context
3799
- . surface_as_hal_mut :: < A , F , R > ( & self . id , hal_surface_callback)
3811
+ unsafe {
3812
+ self . context
3813
+ . surface_as_hal_mut :: < A , F , R > ( & self . id , hal_surface_callback)
3814
+ }
3800
3815
}
3801
3816
}
3802
3817
0 commit comments