@@ -95,7 +95,7 @@ impl Context {
95
95
hal_device : hal:: OpenDevice < A > ,
96
96
desc : & crate :: DeviceDescriptor ,
97
97
trace_dir : Option < & std:: path:: Path > ,
98
- ) -> Result < ( Device , wgc :: id :: QueueId ) , crate :: RequestDeviceError > {
98
+ ) -> Result < ( Device , Queue ) , crate :: RequestDeviceError > {
99
99
let global = & self . 0 ;
100
100
let ( device_id, error) = global. create_device_from_hal (
101
101
* adapter,
@@ -107,12 +107,17 @@ impl Context {
107
107
if let Some ( err) = error {
108
108
self . handle_error_fatal ( err, "Adapter::create_device_from_hal" ) ;
109
109
}
110
+ let error_sink = Arc :: new ( Mutex :: new ( ErrorSinkRaw :: new ( ) ) ) ;
110
111
let device = Device {
111
112
id : device_id,
112
- error_sink : Arc :: new ( Mutex :: new ( ErrorSinkRaw :: new ( ) ) ) ,
113
+ error_sink : error_sink . clone ( ) ,
113
114
features : desc. features ,
114
115
} ;
115
- Ok ( ( device, device_id) )
116
+ let queue = Queue {
117
+ id : device_id,
118
+ error_sink,
119
+ } ;
120
+ Ok ( ( device, queue) )
116
121
}
117
122
118
123
#[ cfg( any( not( target_arch = "wasm32" ) , feature = "emscripten" ) ) ]
@@ -808,6 +813,18 @@ pub struct Texture {
808
813
error_sink : ErrorSink ,
809
814
}
810
815
816
+ #[ derive( Debug ) ]
817
+ pub struct Queue {
818
+ id : wgc:: id:: QueueId ,
819
+ error_sink : ErrorSink ,
820
+ }
821
+
822
+ impl Queue {
823
+ pub ( crate ) fn backend ( & self ) -> wgt:: Backend {
824
+ self . id . backend ( )
825
+ }
826
+ }
827
+
811
828
#[ derive( Debug ) ]
812
829
pub ( crate ) struct CommandEncoder {
813
830
id : wgc:: id:: CommandEncoderId ,
@@ -858,10 +875,17 @@ impl crate::GlobalId for CommandEncoder {
858
875
}
859
876
}
860
877
878
+ impl crate :: GlobalId for Queue {
879
+ fn global_id ( & self ) -> Id {
880
+ use wgc:: id:: TypedId ;
881
+ self . id . unzip ( )
882
+ }
883
+ }
884
+
861
885
impl crate :: Context for Context {
862
886
type AdapterId = wgc:: id:: AdapterId ;
863
887
type DeviceId = Device ;
864
- type QueueId = wgc :: id :: QueueId ;
888
+ type QueueId = Queue ;
865
889
type ShaderModuleId = wgc:: id:: ShaderModuleId ;
866
890
type BindGroupLayoutId = wgc:: id:: BindGroupLayoutId ;
867
891
type BindGroupId = wgc:: id:: BindGroupId ;
@@ -951,12 +975,17 @@ impl crate::Context for Context {
951
975
log:: error!( "Error in Adapter::request_device: {}" , err) ;
952
976
return ready ( Err ( crate :: RequestDeviceError ) ) ;
953
977
}
978
+ let error_sink = Arc :: new ( Mutex :: new ( ErrorSinkRaw :: new ( ) ) ) ;
954
979
let device = Device {
955
980
id : device_id,
956
- error_sink : Arc :: new ( Mutex :: new ( ErrorSinkRaw :: new ( ) ) ) ,
981
+ error_sink : error_sink . clone ( ) ,
957
982
features : desc. features ,
958
983
} ;
959
- ready ( Ok ( ( device, device_id) ) )
984
+ let queue = Queue {
985
+ id : device_id,
986
+ error_sink,
987
+ } ;
988
+ ready ( Ok ( ( device, queue) ) )
960
989
}
961
990
962
991
fn adapter_is_surface_supported (
@@ -2270,7 +2299,7 @@ impl crate::Context for Context {
2270
2299
) {
2271
2300
let global = & self . 0 ;
2272
2301
match wgc:: gfx_select!(
2273
- * queue => global. queue_write_buffer( * queue, buffer. id, offset, data)
2302
+ * queue => global. queue_write_buffer( queue. id , buffer. id, offset, data)
2274
2303
) {
2275
2304
Ok ( ( ) ) => ( ) ,
2276
2305
Err ( err) => self . handle_error_fatal ( err, "Queue::write_buffer" ) ,
@@ -2286,7 +2315,7 @@ impl crate::Context for Context {
2286
2315
) {
2287
2316
let global = & self . 0 ;
2288
2317
match wgc:: gfx_select!(
2289
- * queue => global. queue_validate_write_buffer( * queue, buffer. id, offset, size. get( ) )
2318
+ * queue => global. queue_validate_write_buffer( queue. id , buffer. id, offset, size. get( ) )
2290
2319
) {
2291
2320
Ok ( ( ) ) => ( ) ,
2292
2321
Err ( err) => self . handle_error_fatal ( err, "Queue::write_buffer_with" ) ,
@@ -2300,7 +2329,7 @@ impl crate::Context for Context {
2300
2329
) -> QueueWriteBuffer {
2301
2330
let global = & self . 0 ;
2302
2331
match wgc:: gfx_select!(
2303
- * queue => global. queue_create_staging_buffer( * queue, size, ( ) )
2332
+ * queue => global. queue_create_staging_buffer( queue. id , size, ( ) )
2304
2333
) {
2305
2334
Ok ( ( buffer_id, ptr) ) => QueueWriteBuffer {
2306
2335
buffer_id,
@@ -2322,10 +2351,12 @@ impl crate::Context for Context {
2322
2351
) {
2323
2352
let global = & self . 0 ;
2324
2353
match wgc:: gfx_select!(
2325
- * queue => global. queue_write_staging_buffer( * queue, buffer. id, offset, staging_buffer. buffer_id)
2354
+ * queue => global. queue_write_staging_buffer( queue. id , buffer. id, offset, staging_buffer. buffer_id)
2326
2355
) {
2327
2356
Ok ( ( ) ) => ( ) ,
2328
- Err ( err) => self . handle_error_fatal ( err, "Queue::write_buffer_with" ) ,
2357
+ Err ( err) => {
2358
+ self . handle_error_nolabel ( & queue. error_sink , err, "Queue::write_buffer_with" ) ;
2359
+ }
2329
2360
}
2330
2361
}
2331
2362
@@ -2339,14 +2370,14 @@ impl crate::Context for Context {
2339
2370
) {
2340
2371
let global = & self . 0 ;
2341
2372
match wgc:: gfx_select!( * queue => global. queue_write_texture(
2342
- * queue,
2373
+ queue. id ,
2343
2374
& map_texture_copy_view( texture) ,
2344
2375
data,
2345
2376
& data_layout,
2346
2377
& size
2347
2378
) ) {
2348
2379
Ok ( ( ) ) => ( ) ,
2349
- Err ( err) => self . handle_error_fatal ( err, "Queue::write_texture" ) ,
2380
+ Err ( err) => self . handle_error_nolabel ( & queue . error_sink , err, "Queue::write_texture" ) ,
2350
2381
}
2351
2382
}
2352
2383
@@ -2358,7 +2389,7 @@ impl crate::Context for Context {
2358
2389
let temp_command_buffers = command_buffers. collect :: < SmallVec < [ _ ; 4 ] > > ( ) ;
2359
2390
2360
2391
let global = & self . 0 ;
2361
- match wgc:: gfx_select!( * queue => global. queue_submit( * queue, & temp_command_buffers) ) {
2392
+ match wgc:: gfx_select!( * queue => global. queue_submit( queue. id , & temp_command_buffers) ) {
2362
2393
Ok ( index) => index,
2363
2394
Err ( err) => self . handle_error_fatal ( err, "Queue::submit" ) ,
2364
2395
}
@@ -2367,7 +2398,7 @@ impl crate::Context for Context {
2367
2398
fn queue_get_timestamp_period ( & self , queue : & Self :: QueueId ) -> f32 {
2368
2399
let global = & self . 0 ;
2369
2400
let res = wgc:: gfx_select!( queue => global. queue_get_timestamp_period(
2370
- * queue
2401
+ queue. id
2371
2402
) ) ;
2372
2403
match res {
2373
2404
Ok ( v) => v,
@@ -2385,7 +2416,7 @@ impl crate::Context for Context {
2385
2416
let closure = wgc:: device:: queue:: SubmittedWorkDoneClosure :: from_rust ( callback) ;
2386
2417
2387
2418
let global = & self . 0 ;
2388
- let res = wgc:: gfx_select!( queue => global. queue_on_submitted_work_done( * queue, closure) ) ;
2419
+ let res = wgc:: gfx_select!( queue => global. queue_on_submitted_work_done( queue. id , closure) ) ;
2389
2420
if let Err ( cause) = res {
2390
2421
self . handle_error_fatal ( cause, "Queue::on_submitted_work_done" ) ;
2391
2422
}
0 commit comments