@@ -171,10 +171,23 @@ impl Drop for WGPUComputePipelineImpl {
171171 }
172172}
173173
174+ struct QueueId {
175+ context : Arc < Context > ,
176+ id : id:: QueueId ,
177+ }
178+ impl Drop for QueueId {
179+ fn drop ( & mut self ) {
180+ if !thread:: panicking ( ) {
181+ let context = & self . context ;
182+ gfx_select ! ( self . id => context. queue_drop( self . id) ) ;
183+ }
184+ }
185+ }
186+
174187pub struct WGPUDeviceImpl {
175188 context : Arc < Context > ,
176189 id : id:: DeviceId ,
177- queue_id : id :: QueueId ,
190+ queue : Arc < QueueId > ,
178191 error_sink : ErrorSink ,
179192}
180193impl Drop for WGPUDeviceImpl {
@@ -228,18 +241,9 @@ impl Drop for WGPUQuerySetImpl {
228241}
229242
230243pub struct WGPUQueueImpl {
231- context : Arc < Context > ,
232- id : id:: QueueId ,
244+ queue : Arc < QueueId > ,
233245 error_sink : ErrorSink ,
234246}
235- impl Drop for WGPUQueueImpl {
236- fn drop ( & mut self ) {
237- if !thread:: panicking ( ) {
238- let context = & self . context ;
239- gfx_select ! ( self . id => context. queue_drop( self . id) ) ;
240- }
241- }
242- }
243247
244248pub struct WGPURenderBundleImpl {
245249 context : Arc < Context > ,
@@ -834,7 +838,10 @@ pub unsafe extern "C" fn wgpuAdapterRequestDevice(
834838 Arc :: into_raw ( Arc :: new ( WGPUDeviceImpl {
835839 context : context. clone ( ) ,
836840 id : device_id,
837- queue_id,
841+ queue : Arc :: new ( QueueId {
842+ context : context. clone ( ) ,
843+ id : queue_id,
844+ } ) ,
838845 error_sink : Arc :: new ( Mutex :: new ( ErrorSinkRaw :: new ( device_lost_handler) ) ) ,
839846 } ) ) ,
840847 message. as_ptr ( ) ,
@@ -2529,14 +2536,13 @@ pub unsafe extern "C" fn wgpuDeviceGetLimits(
25292536
25302537#[ no_mangle]
25312538pub unsafe extern "C" fn wgpuDeviceGetQueue ( device : native:: WGPUDevice ) -> native:: WGPUQueue {
2532- let ( queue_id , context , error_sink) = {
2539+ let ( queue , error_sink) = {
25332540 let device = device. as_ref ( ) . expect ( "invalid device" ) ;
2534- ( device . queue_id , & device. context , & device. error_sink )
2541+ ( & device. queue , & device. error_sink )
25352542 } ;
25362543
25372544 Arc :: into_raw ( Arc :: new ( WGPUQueueImpl {
2538- context : context. clone ( ) ,
2539- id : queue_id,
2545+ queue : queue. clone ( ) ,
25402546 error_sink : error_sink. clone ( ) ,
25412547 } ) )
25422548}
@@ -2867,7 +2873,7 @@ pub unsafe extern "C" fn wgpuQueueOnSubmittedWorkDone(
28672873) {
28682874 let ( queue_id, context) = {
28692875 let queue = queue. as_ref ( ) . expect ( "invalid queue" ) ;
2870- ( queue. id , & queue. context )
2876+ ( queue. queue . id , & queue . queue . context )
28712877 } ;
28722878 let callback = callback. expect ( "invalid callback" ) ;
28732879 let userdata = utils:: Userdata :: new ( userdata) ;
@@ -2891,7 +2897,7 @@ pub unsafe extern "C" fn wgpuQueueSubmit(
28912897) {
28922898 let ( queue_id, context) = {
28932899 let queue = queue. as_ref ( ) . expect ( "invalid queue" ) ;
2894- ( queue. id , & queue. context )
2900+ ( queue. queue . id , & queue . queue . context )
28952901 } ;
28962902
28972903 let command_buffers = make_slice ( commands, command_count)
@@ -2918,7 +2924,7 @@ pub unsafe extern "C" fn wgpuQueueWriteBuffer(
29182924) {
29192925 let ( queue_id, context, error_sink) = {
29202926 let queue = queue. as_ref ( ) . expect ( "invalid queue" ) ;
2921- ( queue. id , & queue. context , & queue. error_sink )
2927+ ( queue. queue . id , & queue . queue . context , & queue. error_sink )
29222928 } ;
29232929 let buffer_id = buffer. as_ref ( ) . expect ( "invalid buffer" ) . id ;
29242930
@@ -2943,7 +2949,7 @@ pub unsafe extern "C" fn wgpuQueueWriteTexture(
29432949) {
29442950 let ( queue_id, context, error_sink) = {
29452951 let queue = queue. as_ref ( ) . expect ( "invalid queue" ) ;
2946- ( queue. id , & queue. context , & queue. error_sink )
2952+ ( queue. queue . id , & queue . queue . context , & queue. error_sink )
29472953 } ;
29482954
29492955 if let Err ( cause) = gfx_select ! ( queue_id => context. queue_write_texture(
@@ -4095,7 +4101,7 @@ pub unsafe extern "C" fn wgpuQueueSubmitForIndex(
40954101) -> native:: WGPUSubmissionIndex {
40964102 let ( queue_id, context) = {
40974103 let queue = queue. as_ref ( ) . expect ( "invalid queue" ) ;
4098- ( queue. id , & queue. context )
4104+ ( queue. queue . id , & queue . queue . context )
40994105 } ;
41004106
41014107 let command_buffers = make_slice ( commands, command_count)
@@ -4132,6 +4138,7 @@ pub unsafe extern "C" fn wgpuDevicePoll(
41324138 . queue
41334139 . as_ref ( )
41344140 . expect ( "invalid queue for wrapped submission index" )
4141+ . queue
41354142 . id ,
41364143 index : index. submissionIndex ,
41374144 } )
0 commit comments