1
1
use std:: { future:: Future , sync:: Arc , thread} ;
2
2
3
- use crate :: context:: { DeviceRequest , DynContext , ObjectId } ;
3
+ use crate :: context:: { DeviceRequest , DynContext } ;
4
4
use crate :: * ;
5
5
6
6
/// Handle to a physical graphics and/or compute device.
@@ -14,7 +14,6 @@ use crate::*;
14
14
#[ derive( Debug ) ]
15
15
pub struct Adapter {
16
16
pub ( crate ) context : Arc < C > ,
17
- pub ( crate ) id : ObjectId ,
18
17
pub ( crate ) data : Box < Data > ,
19
18
}
20
19
#[ cfg( send_sync) ]
@@ -23,7 +22,7 @@ static_assertions::assert_impl_all!(Adapter: Send, Sync);
23
22
impl Drop for Adapter {
24
23
fn drop ( & mut self ) {
25
24
if !thread:: panicking ( ) {
26
- self . context . adapter_drop ( & self . id , self . data . as_ref ( ) )
25
+ self . context . adapter_drop ( self . data . as_ref ( ) )
27
26
}
28
27
}
29
28
}
@@ -40,14 +39,6 @@ pub type RequestAdapterOptions<'a, 'b> = RequestAdapterOptionsBase<&'a Surface<'
40
39
static_assertions:: assert_impl_all!( RequestAdapterOptions <' _, ' _>: Send , Sync ) ;
41
40
42
41
impl 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
-
51
42
/// Requests a connection to a physical device, creating a logical device.
52
43
///
53
44
/// Returns the [`Device`] together with a [`Queue`] that executes command buffers.
@@ -80,28 +71,23 @@ impl Adapter {
80
71
let context = Arc :: clone ( & self . context ) ;
81
72
let device = DynContext :: adapter_request_device (
82
73
& * self . context ,
83
- & self . id ,
84
74
self . data . as_ref ( ) ,
85
75
desc,
86
76
trace_path,
87
77
) ;
88
78
async move {
89
79
device. await . map (
90
80
|DeviceRequest {
91
- device_id,
92
81
device_data,
93
- queue_id,
94
82
queue_data,
95
83
} | {
96
84
(
97
85
Device {
98
86
context : Arc :: clone ( & context) ,
99
- id : device_id,
100
87
data : device_data,
101
88
} ,
102
89
Queue {
103
90
context,
104
- id : queue_id,
105
91
data : queue_data,
106
92
} ,
107
93
)
@@ -131,18 +117,21 @@ impl Adapter {
131
117
// Part of the safety requirements is that the device was generated from the same adapter.
132
118
// Therefore, unwrap is fine here since only WgpuCoreContext based adapters have the ability to create hal devices.
133
119
. 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
+ )
135
126
}
136
127
. map ( |( device, queue) | {
137
128
(
138
129
Device {
139
130
context : Arc :: clone ( & context) ,
140
- id : device. id ( ) . into ( ) ,
141
131
data : Box :: new ( device) ,
142
132
} ,
143
133
Queue {
144
134
context,
145
- id : queue. id ( ) . into ( ) ,
146
135
data : Box :: new ( queue) ,
147
136
} ,
148
137
)
@@ -178,7 +167,12 @@ impl Adapter {
178
167
. as_any ( )
179
168
. downcast_ref :: < crate :: backend:: ContextWgpuCore > ( )
180
169
{
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
+ }
182
176
} else {
183
177
hal_adapter_callback ( None )
184
178
}
@@ -188,44 +182,37 @@ impl Adapter {
188
182
pub fn is_surface_supported ( & self , surface : & Surface < ' _ > ) -> bool {
189
183
DynContext :: adapter_is_surface_supported (
190
184
& * self . context ,
191
- & self . id ,
192
185
self . data . as_ref ( ) ,
193
- & surface. id ,
194
186
surface. surface_data . as_ref ( ) ,
195
187
)
196
188
}
197
189
198
190
/// The features which can be used to create devices on this adapter.
199
191
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 ( ) )
201
193
}
202
194
203
195
/// The best limits which can be used to create devices on this adapter.
204
196
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 ( ) )
206
198
}
207
199
208
200
/// Get info about the adapter itself.
209
201
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 ( ) )
211
203
}
212
204
213
205
/// Get info about the adapter itself.
214
206
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 ( ) )
216
208
}
217
209
218
210
/// Returns the features supported for a given texture format by this adapter.
219
211
///
220
212
/// Note that the WebGPU spec further restricts the available usages/features.
221
213
/// To disable these restrictions on a device, request the [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] feature.
222
214
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)
229
216
}
230
217
231
218
/// Generates a timestamp using the clock used by the presentation engine.
@@ -250,6 +237,6 @@ impl Adapter {
250
237
//
251
238
/// [Instant]: std::time::Instant
252
239
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 ( ) )
254
241
}
255
242
}
0 commit comments