11use std:: { future:: Future , sync:: Arc , thread} ;
22
3- use crate :: context:: { DeviceRequest , DynContext , ObjectId } ;
3+ use crate :: context:: { DeviceRequest , DynContext } ;
44use crate :: * ;
55
66/// Handle to a physical graphics and/or compute device.
@@ -14,7 +14,6 @@ use crate::*;
1414#[ derive( Debug ) ]
1515pub struct Adapter {
1616 pub ( crate ) context : Arc < C > ,
17- pub ( crate ) id : ObjectId ,
1817 pub ( crate ) data : Box < Data > ,
1918}
2019#[ cfg( send_sync) ]
@@ -23,7 +22,7 @@ static_assertions::assert_impl_all!(Adapter: Send, Sync);
2322impl Drop for Adapter {
2423 fn drop ( & mut self ) {
2524 if !thread:: panicking ( ) {
26- self . context . adapter_drop ( & self . id , self . data . as_ref ( ) )
25+ self . context . adapter_drop ( self . data . as_ref ( ) )
2726 }
2827 }
2928}
@@ -40,14 +39,6 @@ pub type RequestAdapterOptions<'a, 'b> = RequestAdapterOptionsBase<&'a Surface<'
4039static_assertions:: assert_impl_all!( RequestAdapterOptions <' _, ' _>: Send , Sync ) ;
4140
4241impl Adapter {
43- /// Returns a globally-unique identifier for this `Adapter`.
44- ///
45- /// Calling this method multiple times on the same object will always return the same value.
46- /// The returned value is guaranteed to be different for all resources created from the same `Instance`.
47- pub fn global_id ( & self ) -> Id < Self > {
48- Id :: new ( self . id )
49- }
50-
5142 /// Requests a connection to a physical device, creating a logical device.
5243 ///
5344 /// Returns the [`Device`] together with a [`Queue`] that executes command buffers.
@@ -80,28 +71,23 @@ impl Adapter {
8071 let context = Arc :: clone ( & self . context ) ;
8172 let device = DynContext :: adapter_request_device (
8273 & * self . context ,
83- & self . id ,
8474 self . data . as_ref ( ) ,
8575 desc,
8676 trace_path,
8777 ) ;
8878 async move {
8979 device. await . map (
9080 |DeviceRequest {
91- device_id,
9281 device_data,
93- queue_id,
9482 queue_data,
9583 } | {
9684 (
9785 Device {
9886 context : Arc :: clone ( & context) ,
99- id : device_id,
10087 data : device_data,
10188 } ,
10289 Queue {
10390 context,
104- id : queue_id,
10591 data : queue_data,
10692 } ,
10793 )
@@ -131,18 +117,21 @@ impl Adapter {
131117 // Part of the safety requirements is that the device was generated from the same adapter.
132118 // Therefore, unwrap is fine here since only WgpuCoreContext based adapters have the ability to create hal devices.
133119 . unwrap ( )
134- . create_device_from_hal ( & self . id . into ( ) , hal_device, desc, trace_path)
120+ . create_device_from_hal (
121+ crate :: context:: downcast_ref ( & self . data ) ,
122+ hal_device,
123+ desc,
124+ trace_path,
125+ )
135126 }
136127 . map ( |( device, queue) | {
137128 (
138129 Device {
139130 context : Arc :: clone ( & context) ,
140- id : device. id ( ) . into ( ) ,
141131 data : Box :: new ( device) ,
142132 } ,
143133 Queue {
144134 context,
145- id : queue. id ( ) . into ( ) ,
146135 data : Box :: new ( queue) ,
147136 } ,
148137 )
@@ -178,7 +167,12 @@ impl Adapter {
178167 . as_any ( )
179168 . downcast_ref :: < crate :: backend:: ContextWgpuCore > ( )
180169 {
181- unsafe { ctx. adapter_as_hal :: < A , F , R > ( self . id . into ( ) , hal_adapter_callback) }
170+ unsafe {
171+ ctx. adapter_as_hal :: < A , F , R > (
172+ crate :: context:: downcast_ref ( & self . data ) ,
173+ hal_adapter_callback,
174+ )
175+ }
182176 } else {
183177 hal_adapter_callback ( None )
184178 }
@@ -188,44 +182,37 @@ impl Adapter {
188182 pub fn is_surface_supported ( & self , surface : & Surface < ' _ > ) -> bool {
189183 DynContext :: adapter_is_surface_supported (
190184 & * self . context ,
191- & self . id ,
192185 self . data . as_ref ( ) ,
193- & surface. id ,
194186 surface. surface_data . as_ref ( ) ,
195187 )
196188 }
197189
198190 /// The features which can be used to create devices on this adapter.
199191 pub fn features ( & self ) -> Features {
200- DynContext :: adapter_features ( & * self . context , & self . id , self . data . as_ref ( ) )
192+ DynContext :: adapter_features ( & * self . context , self . data . as_ref ( ) )
201193 }
202194
203195 /// The best limits which can be used to create devices on this adapter.
204196 pub fn limits ( & self ) -> Limits {
205- DynContext :: adapter_limits ( & * self . context , & self . id , self . data . as_ref ( ) )
197+ DynContext :: adapter_limits ( & * self . context , self . data . as_ref ( ) )
206198 }
207199
208200 /// Get info about the adapter itself.
209201 pub fn get_info ( & self ) -> AdapterInfo {
210- DynContext :: adapter_get_info ( & * self . context , & self . id , self . data . as_ref ( ) )
202+ DynContext :: adapter_get_info ( & * self . context , self . data . as_ref ( ) )
211203 }
212204
213205 /// Get info about the adapter itself.
214206 pub fn get_downlevel_capabilities ( & self ) -> DownlevelCapabilities {
215- DynContext :: adapter_downlevel_capabilities ( & * self . context , & self . id , self . data . as_ref ( ) )
207+ DynContext :: adapter_downlevel_capabilities ( & * self . context , self . data . as_ref ( ) )
216208 }
217209
218210 /// Returns the features supported for a given texture format by this adapter.
219211 ///
220212 /// Note that the WebGPU spec further restricts the available usages/features.
221213 /// To disable these restrictions on a device, request the [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] feature.
222214 pub fn get_texture_format_features ( & self , format : TextureFormat ) -> TextureFormatFeatures {
223- DynContext :: adapter_get_texture_format_features (
224- & * self . context ,
225- & self . id ,
226- self . data . as_ref ( ) ,
227- format,
228- )
215+ DynContext :: adapter_get_texture_format_features ( & * self . context , self . data . as_ref ( ) , format)
229216 }
230217
231218 /// Generates a timestamp using the clock used by the presentation engine.
@@ -250,6 +237,6 @@ impl Adapter {
250237 //
251238 /// [Instant]: std::time::Instant
252239 pub fn get_presentation_timestamp ( & self ) -> PresentationTimestamp {
253- DynContext :: adapter_get_presentation_timestamp ( & * self . context , & self . id , self . data . as_ref ( ) )
240+ DynContext :: adapter_get_presentation_timestamp ( & * self . context , self . data . as_ref ( ) )
254241 }
255242}
0 commit comments