Skip to content

Commit 39fc24b

Browse files
committed
Default to capturing with MTLCaptureScope
1 parent 2a7c978 commit 39fc24b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/mtl/capture.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ Use [`beginScope()`](@ref) and [`endScope()`](@ref) to set the boundaries for a
1212
"""
1313
MTLCaptureScope
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()
5968
end
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()
@@ -110,7 +119,7 @@ end
110119
111120
Start 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

src/utilities.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ function captured(f; dest=MTL.MTLCaptureDestinationGPUTraceDocument,
137137
end
138138

139139
folder = capture_dir()
140-
startCapture(object, dest; folder)
140+
scope = MTLCaptureScope(object)
141+
startCapture(scope, dest; folder)
141142
try
142-
f()
143-
synchronize()
143+
beginScope(scope)
144+
f()
145+
endScope(scope)
146+
synchronize()
144147
finally
145148
@info "GPU frame capture saved to $folder; open the resulting trace in Xcode"
146149
stopCapture()

0 commit comments

Comments
 (0)