Skip to content

Commit

Permalink
add version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tgymnich committed Feb 5, 2025
1 parent 01c3ca8 commit 6052888
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
32 changes: 18 additions & 14 deletions lib/mtl/command_queue.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
export MTLCommandQueueDescriptor

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

function MTLCommandQueueDescriptor()
handle = @objc [MTLCommandQueueDescriptor alloc]::id{MTLCommandQueueDescriptor}
obj = MTLCommandQueueDescriptor(handle)
finalizer(release, obj)
@objc [obj::id{MTLCommandQueueDescriptor} init]::id{MTLCommandQueueDescriptor}
return obj
# @objcwrapper immutable=false MTLCommandQueueDescriptor <: NSObject

function MTLCommandQueueDescriptor()
handle = @objc [MTLCommandQueueDescriptor alloc]::id{MTLCommandQueueDescriptor}
obj = MTLCommandQueueDescriptor(handle)
finalizer(release, obj)
@objc [obj::id{MTLCommandQueueDescriptor} init]::id{MTLCommandQueueDescriptor}
return obj
end

function MTLCommandQueue(dev::MTLDevice, descriptor::MTLCommandQueueDescriptor)
handle = @objc [dev::id{MTLDevice} newCommandQueueWithDescriptor:descriptor::id{MTLCommandQueueDescriptor}]::id{MTLCommandQueue}
obj = MTLCommandQueue(handle)
finalizer(release, obj)
return obj
end
end


Expand All @@ -22,9 +32,3 @@ function MTLCommandQueue(dev::MTLDevice)
return obj
end

function MTLCommandQueue(dev::MTLDevice, descriptor::MTLCommandQueueDescriptor)
handle = @objc [dev::id{MTLDevice} newCommandQueueWithDescriptor:descriptor::id{MTLCommandQueueDescriptor}]::id{MTLCommandQueue}
obj = MTLCommandQueue(handle)
finalizer(release, obj)
return obj
end
36 changes: 19 additions & 17 deletions lib/mtl/log_state.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
export MTLLogLevel
@static if Metal.is_macos(v"15.0.0")
export MTLLogLevel

export MTLLogStateDescriptor
export MTLLogStateDescriptor

# @objcwrapper immutable = true MTLLogStateDescriptor <: NSObject
# @objcwrapper immutable = true MTLLogStateDescriptor <: NSObject

function MTLLogStateDescriptor()
handle = @objc [MTLLogStateDescriptor alloc]::id{MTLLogStateDescriptor}
obj = MTLLogStateDescriptor(handle)
@objc [obj::id{MTLLogStateDescriptor} init]::id{MTLLogStateDescriptor}
return obj
end
function MTLLogStateDescriptor()
handle = @objc [MTLLogStateDescriptor alloc]::id{MTLLogStateDescriptor}
obj = MTLLogStateDescriptor(handle)
@objc [obj::id{MTLLogStateDescriptor} init]::id{MTLLogStateDescriptor}
return obj
end


export MTLLogState
export MTLLogState

# @objcwrapper immutable = true MTLLogState <: NSObject
# @objcwrapper immutable = true MTLLogState <: NSObject

function MTLLogState(dev::MTLDevice, descriptor::MTLLogStateDescriptor)
err = Ref{id{NSError}}(nil)
handle = @objc [dev::id{MTLDevice} newLogStateWithDescriptor:descriptor::id{MTLLogStateDescriptor}
error:err::Ptr{id{NSError}}]::id{MTLLogState}
err[] == nil || throw(NSError(err[]))
MTLLogState(handle)
function MTLLogState(dev::MTLDevice, descriptor::MTLLogStateDescriptor)
err = Ref{id{NSError}}(nil)
handle = @objc [dev::id{MTLDevice} newLogStateWithDescriptor:descriptor::id{MTLLogStateDescriptor}
error:err::Ptr{id{NSError}}]::id{MTLLogState}
err[] == nil || throw(NSError(err[]))
MTLLogState(handle)
end
end
2 changes: 1 addition & 1 deletion src/compiler/execution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ end

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

Expand Down

0 comments on commit 6052888

Please sign in to comment.