@@ -12,6 +12,15 @@ Use [`beginScope()`](@ref) and [`endScope()`](@ref) to set the boundaries for a
1212""" 
1313MTLCaptureScope
1414
15+ function  MTLCaptureScope (queue:: MTLDevice , manager= MTLCaptureManager ())
16+     handle =  @objc  [manager:: id{MTLCaptureManager}  newCaptureScopeWithDevice: queue:: id{MTLDevice} ]:: id{MTLCaptureScope} 
17+     MTLCaptureScope (handle)
18+ end 
19+ function  MTLCaptureScope (queue:: MTLCommandQueue , manager= MTLCaptureManager ())
20+     handle =  @objc  [manager:: id{MTLCaptureManager}  newCaptureScopeWithCommandQueue: queue:: id{MTLCommandQueue} ]:: id{MTLCaptureScope} 
21+     MTLCaptureScope (handle)
22+ end 
23+ 
1524#  @objcwrapper MTLCaptureScope <: NSObject
1625
1726""" 
@@ -59,7 +68,7 @@ function MTLCaptureDescriptor()
5968end 
6069
6170#  TODO : Add capture state
62- function  MTLCaptureDescriptor (obj:: Union{MTLDevice,MTLCommandQueue, MTLCaptureScope} ,
71+ function  MTLCaptureDescriptor (obj:: Union{MTLDevice,  MTLCommandQueue, MTLCaptureScope} ,
6372                              destination:: MTLCaptureDestination ;
6473                              folder:: String = nothing )
6574    desc =  MTLCaptureDescriptor ()
110119
111120Start GPU frame capture using the default capture object and specifying capture descriptor parameters directly. 
112121""" 
113- function  startCapture (obj:: Union{MTLDevice,MTLCommandQueue, MTLCaptureScope} ,
122+ function  startCapture (obj:: Union{MTLDevice,  MTLCommandQueue, MTLCaptureScope} ,
114123                      destination:: MTLCaptureDestination = MTLCaptureDestinationGPUTraceDocument;
115124                      folder:: String = nothing )
116125    if  destination ==  MTLCaptureDestinationGPUTraceDocument &&  folder ===  nothing 
@@ -141,8 +150,17 @@ Stop GPU frame capture.
141150""" 
142151function  stopCapture (manager:: MTLCaptureManager = MTLCaptureManager ())
143152    @objc  [manager:: id{MTLCaptureManager}  stopCapture]:: Nothing 
153+     #  Spinlock until capture is fully complete. Otherwise, `stopCapture`
154+     #   sometimes returns while the capture manager is still capturing,
155+     #   causing test failures and potentially corrupted captures.
156+     while  manager. isCapturing
157+     end 
144158end 
145159
160+ """ 
161+     supports_destination(manager::MTLCaptureManager, destination::MTLCaptureDestination) 
162+ Checks if a given capture destination is supported. 
163+ """ 
146164function  supports_destination (manager:: MTLCaptureManager , destination:: MTLCaptureDestination )
147165    @objc  [manager:: id{MTLCaptureManager}  supportsDestination: destination:: MTLCaptureDestination ]:: Bool 
148166end 
0 commit comments