4
4
5
5
#![ cfg_attr( docsrs, feature( doc_cfg) ) ] // Allow doc(cfg(feature = "")) for showing in docs that something is feature gated.
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;
@@ -1730,7 +1730,7 @@ impl Instance {
1730
1730
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "emscripten" ) ) ]
1731
1731
pub unsafe fn from_hal < A : wgc:: hub:: HalApi > ( hal_instance : A :: Instance ) -> Self {
1732
1732
Self {
1733
- context : Arc :: new ( C :: from_hal_instance :: < A > ( hal_instance) ) ,
1733
+ context : Arc :: new ( unsafe { C :: from_hal_instance :: < A > ( hal_instance) } ) ,
1734
1734
}
1735
1735
}
1736
1736
@@ -1746,7 +1746,7 @@ impl Instance {
1746
1746
/// [`Instance`]: hal::Api::Instance
1747
1747
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "webgl" ) ) ]
1748
1748
pub unsafe fn as_hal < A : wgc:: hub:: HalApi > ( & self ) -> Option < & A :: Instance > {
1749
- self . context . instance_as_hal :: < A > ( )
1749
+ unsafe { self . context . instance_as_hal :: < A > ( ) }
1750
1750
}
1751
1751
1752
1752
/// Create an new instance of wgpu from a wgpu-core instance.
@@ -1761,7 +1761,7 @@ impl Instance {
1761
1761
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "webgl" ) ) ]
1762
1762
pub unsafe fn from_core ( core_instance : wgc:: instance:: Instance ) -> Self {
1763
1763
Self {
1764
- context : Arc :: new ( C :: from_core_instance ( core_instance) ) ,
1764
+ context : Arc :: new ( unsafe { C :: from_core_instance ( core_instance) } ) ,
1765
1765
}
1766
1766
}
1767
1767
@@ -1807,7 +1807,7 @@ impl Instance {
1807
1807
hal_adapter : hal:: ExposedAdapter < A > ,
1808
1808
) -> Adapter {
1809
1809
let context = Arc :: clone ( & self . context ) ;
1810
- let id = context. create_adapter_from_hal ( hal_adapter) ;
1810
+ let id = unsafe { context. create_adapter_from_hal ( hal_adapter) } ;
1811
1811
Adapter { context, id }
1812
1812
}
1813
1813
@@ -1854,7 +1854,7 @@ impl Instance {
1854
1854
/// - visual must be a valid IDCompositionVisual to create a surface upon.
1855
1855
#[ cfg( target_os = "windows" ) ]
1856
1856
pub unsafe fn create_surface_from_visual ( & self , visual : * mut std:: ffi:: c_void ) -> Surface {
1857
- self . context . create_surface_from_visual ( visual)
1857
+ unsafe { self . context . create_surface_from_visual ( visual) }
1858
1858
}
1859
1859
1860
1860
/// Creates a surface from a `web_sys::HtmlCanvasElement`.
@@ -1967,20 +1967,22 @@ impl Adapter {
1967
1967
trace_path : Option < & std:: path:: Path > ,
1968
1968
) -> Result < ( Device , Queue ) , RequestDeviceError > {
1969
1969
let context = Arc :: clone ( & self . context ) ;
1970
- self . context
1971
- . create_device_from_hal ( & self . id , hal_device, desc, trace_path)
1972
- . map ( |( device_id, queue_id) | {
1973
- (
1974
- Device {
1975
- context : Arc :: clone ( & context) ,
1976
- id : device_id,
1977
- } ,
1978
- Queue {
1979
- context,
1980
- id : queue_id,
1981
- } ,
1982
- )
1983
- } )
1970
+ unsafe {
1971
+ self . context
1972
+ . create_device_from_hal ( & self . id , hal_device, desc, trace_path)
1973
+ }
1974
+ . map ( |( device_id, queue_id) | {
1975
+ (
1976
+ Device {
1977
+ context : Arc :: clone ( & context) ,
1978
+ id : device_id,
1979
+ } ,
1980
+ Queue {
1981
+ context,
1982
+ id : queue_id,
1983
+ } ,
1984
+ )
1985
+ } )
1984
1986
}
1985
1987
1986
1988
/// Apply a callback to this `Adapter`'s underlying backend adapter.
@@ -2007,8 +2009,10 @@ impl Adapter {
2007
2009
& self ,
2008
2010
hal_adapter_callback : F ,
2009
2011
) -> R {
2010
- self . context
2011
- . adapter_as_hal :: < A , F , R > ( self . id , hal_adapter_callback)
2012
+ unsafe {
2013
+ self . context
2014
+ . adapter_as_hal :: < A , F , R > ( self . id , hal_adapter_callback)
2015
+ }
2012
2016
}
2013
2017
2014
2018
/// Returns whether this adapter may present to the passed surface.
@@ -2108,12 +2112,14 @@ impl Device {
2108
2112
) -> ShaderModule {
2109
2113
ShaderModule {
2110
2114
context : Arc :: clone ( & self . context ) ,
2111
- id : Context :: device_create_shader_module (
2112
- & * self . context ,
2113
- & self . id ,
2114
- desc,
2115
- wgt:: ShaderBoundChecks :: unchecked ( ) ,
2116
- ) ,
2115
+ id : unsafe {
2116
+ Context :: device_create_shader_module (
2117
+ & * self . context ,
2118
+ & self . id ,
2119
+ desc,
2120
+ wgt:: ShaderBoundChecks :: unchecked ( ) ,
2121
+ )
2122
+ } ,
2117
2123
}
2118
2124
}
2119
2125
@@ -2131,7 +2137,9 @@ impl Device {
2131
2137
) -> ShaderModule {
2132
2138
ShaderModule {
2133
2139
context : Arc :: clone ( & self . context ) ,
2134
- id : Context :: device_create_shader_module_spirv ( & * self . context , & self . id , desc) ,
2140
+ id : unsafe {
2141
+ Context :: device_create_shader_module_spirv ( & * self . context , & self . id , desc)
2142
+ } ,
2135
2143
}
2136
2144
}
2137
2145
@@ -2241,9 +2249,10 @@ impl Device {
2241
2249
) -> Texture {
2242
2250
Texture {
2243
2251
context : Arc :: clone ( & self . context ) ,
2244
- id : self
2245
- . context
2246
- . create_texture_from_hal :: < A > ( hal_texture, & self . id , desc) ,
2252
+ id : unsafe {
2253
+ self . context
2254
+ . create_texture_from_hal :: < A > ( hal_texture, & self . id , desc)
2255
+ } ,
2247
2256
owned : true ,
2248
2257
}
2249
2258
}
@@ -2315,8 +2324,10 @@ impl Device {
2315
2324
& self ,
2316
2325
hal_device_callback : F ,
2317
2326
) -> R {
2318
- self . context
2319
- . device_as_hal :: < A , F , R > ( & self . id , hal_device_callback)
2327
+ unsafe {
2328
+ self . context
2329
+ . device_as_hal :: < A , F , R > ( & self . id , hal_device_callback)
2330
+ }
2320
2331
}
2321
2332
}
2322
2333
@@ -2626,8 +2637,10 @@ impl Texture {
2626
2637
& self ,
2627
2638
hal_texture_callback : F ,
2628
2639
) {
2629
- self . context
2630
- . texture_as_hal :: < A , F > ( & self . id , hal_texture_callback)
2640
+ unsafe {
2641
+ self . context
2642
+ . texture_as_hal :: < A , F > ( & self . id , hal_texture_callback)
2643
+ }
2631
2644
}
2632
2645
2633
2646
/// Creates a view of this texture.
0 commit comments