Skip to content

Commit 02cd8d3

Browse files
tgymnichchristiangnrd
authored andcommitted
add version checks
1 parent 2e752d8 commit 02cd8d3

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

lib/mtl/command_queue.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
export MTLCommandQueueDescriptor
21

3-
# @objcwrapper immutable=false MTLCommandQueueDescriptor <: NSObject
2+
@static if Metal.is_macos(v"15.0.0")
3+
export MTLCommandQueueDescriptor
44

5-
function MTLCommandQueueDescriptor()
6-
handle = @objc [MTLCommandQueueDescriptor alloc]::id{MTLCommandQueueDescriptor}
7-
obj = MTLCommandQueueDescriptor(handle)
8-
finalizer(release, obj)
9-
@objc [obj::id{MTLCommandQueueDescriptor} init]::id{MTLCommandQueueDescriptor}
10-
return obj
5+
# @objcwrapper immutable=false MTLCommandQueueDescriptor <: NSObject
6+
7+
function MTLCommandQueueDescriptor()
8+
handle = @objc [MTLCommandQueueDescriptor alloc]::id{MTLCommandQueueDescriptor}
9+
obj = MTLCommandQueueDescriptor(handle)
10+
finalizer(release, obj)
11+
@objc [obj::id{MTLCommandQueueDescriptor} init]::id{MTLCommandQueueDescriptor}
12+
return obj
13+
end
14+
15+
function MTLCommandQueue(dev::MTLDevice, descriptor::MTLCommandQueueDescriptor)
16+
handle = @objc [dev::id{MTLDevice} newCommandQueueWithDescriptor:descriptor::id{MTLCommandQueueDescriptor}]::id{MTLCommandQueue}
17+
obj = MTLCommandQueue(handle)
18+
finalizer(release, obj)
19+
return obj
20+
end
1121
end
1222

1323

@@ -22,9 +32,3 @@ function MTLCommandQueue(dev::MTLDevice)
2232
return obj
2333
end
2434

25-
function MTLCommandQueue(dev::MTLDevice, descriptor::MTLCommandQueueDescriptor)
26-
handle = @objc [dev::id{MTLDevice} newCommandQueueWithDescriptor:descriptor::id{MTLCommandQueueDescriptor}]::id{MTLCommandQueue}
27-
obj = MTLCommandQueue(handle)
28-
finalizer(release, obj)
29-
return obj
30-
end

lib/mtl/log_state.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
export MTLLogLevel
1+
@static if Metal.is_macos(v"15.0.0")
2+
export MTLLogLevel
23

3-
export MTLLogStateDescriptor
4+
export MTLLogStateDescriptor
45

5-
# @objcwrapper immutable = true MTLLogStateDescriptor <: NSObject
6+
# @objcwrapper immutable = true MTLLogStateDescriptor <: NSObject
67

7-
function MTLLogStateDescriptor()
8-
handle = @objc [MTLLogStateDescriptor alloc]::id{MTLLogStateDescriptor}
9-
obj = MTLLogStateDescriptor(handle)
10-
@objc [obj::id{MTLLogStateDescriptor} init]::id{MTLLogStateDescriptor}
11-
return obj
12-
end
8+
function MTLLogStateDescriptor()
9+
handle = @objc [MTLLogStateDescriptor alloc]::id{MTLLogStateDescriptor}
10+
obj = MTLLogStateDescriptor(handle)
11+
@objc [obj::id{MTLLogStateDescriptor} init]::id{MTLLogStateDescriptor}
12+
return obj
13+
end
1314

1415

15-
export MTLLogState
16+
export MTLLogState
1617

17-
# @objcwrapper immutable = true MTLLogState <: NSObject
18+
# @objcwrapper immutable = true MTLLogState <: NSObject
1819

19-
function MTLLogState(dev::MTLDevice, descriptor::MTLLogStateDescriptor)
20-
err = Ref{id{NSError}}(nil)
21-
handle = @objc [dev::id{MTLDevice} newLogStateWithDescriptor:descriptor::id{MTLLogStateDescriptor}
22-
error:err::Ptr{id{NSError}}]::id{MTLLogState}
23-
err[] == nil || throw(NSError(err[]))
24-
MTLLogState(handle)
20+
function MTLLogState(dev::MTLDevice, descriptor::MTLLogStateDescriptor)
21+
err = Ref{id{NSError}}(nil)
22+
handle = @objc [dev::id{MTLDevice} newLogStateWithDescriptor:descriptor::id{MTLLogStateDescriptor}
23+
error:err::Ptr{id{NSError}}]::id{MTLLogState}
24+
err[] == nil || throw(NSError(err[]))
25+
MTLLogState(handle)
26+
end
2527
end

src/compiler/execution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ end
278278

279279
cmdbuf = if kernel.loggingEnabled
280280
# TODO: make this a dynamic error, i.e., from the kernel (JuliaGPU/Metal.jl#433)
281-
@static if macos_version() < v"15"
281+
@static if !is_macos(v"15.0.0")
282282
error("Logging is only supported on macOS 15 or higher")
283283
end
284284

0 commit comments

Comments
 (0)