Skip to content

Commit 3c4e045

Browse files
Adapt to nightly ccall changes (#678)
* Adapt to nightly ccall changes * Don't use bridgesupport versions
1 parent b6062f3 commit 3c4e045

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

lib/mtl/libmtl.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using CEnum: CEnum, @cenum
55

6+
const libmtl = Symbol("/System/Library/Frameworks/Metal.framework/Metal")
7+
68
const _NSRange = NSRange
79

810

@@ -23,7 +25,7 @@ struct MTLTextureSwizzleChannels
2325
end
2426

2527
function MTLTextureSwizzleChannelsMake(r, g, b, a)
26-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLTextureSwizzleChannelsMake(r::MTLTextureSwizzle, g::MTLTextureSwizzle, b::MTLTextureSwizzle, a::MTLTextureSwizzle)::MTLTextureSwizzleChannels
28+
return @ccall libmtl.MTLTextureSwizzleChannelsMake(r::MTLTextureSwizzle, g::MTLTextureSwizzle, b::MTLTextureSwizzle, a::MTLTextureSwizzle)::MTLTextureSwizzleChannels
2729
end
2830

2931
struct MTLOrigin
@@ -33,7 +35,7 @@ struct MTLOrigin
3335
end
3436

3537
function MTLOriginMake(x, y, z)
36-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLOriginMake(x::NSUInteger, y::NSUInteger, z::NSUInteger)::MTLOrigin
38+
return @ccall libmtl.MTLOriginMake(x::NSUInteger, y::NSUInteger, z::NSUInteger)::MTLOrigin
3739
end
3840

3941
struct MTLSize
@@ -43,7 +45,7 @@ struct MTLSize
4345
end
4446

4547
function MTLSizeMake(width, height, depth)
46-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLSizeMake(width::NSUInteger, height::NSUInteger, depth::NSUInteger)::MTLSize
48+
return @ccall libmtl.MTLSizeMake(width::NSUInteger, height::NSUInteger, depth::NSUInteger)::MTLSize
4749
end
4850

4951
struct MTLRegion
@@ -52,15 +54,15 @@ struct MTLRegion
5254
end
5355

5456
function MTLRegionMake1D(x, width)
55-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLRegionMake1D(x::NSUInteger, width::NSUInteger)::MTLRegion
57+
return @ccall libmtl.MTLRegionMake1D(x::NSUInteger, width::NSUInteger)::MTLRegion
5658
end
5759

5860
function MTLRegionMake2D(x, y, width, height)
59-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLRegionMake2D(x::NSUInteger, y::NSUInteger, width::NSUInteger, height::NSUInteger)::MTLRegion
61+
return @ccall libmtl.MTLRegionMake2D(x::NSUInteger, y::NSUInteger, width::NSUInteger, height::NSUInteger)::MTLRegion
6062
end
6163

6264
function MTLRegionMake3D(x, y, z, width, height, depth)
63-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLRegionMake3D(x::NSUInteger, y::NSUInteger, z::NSUInteger, width::NSUInteger, height::NSUInteger, depth::NSUInteger)::MTLRegion
65+
return @ccall libmtl.MTLRegionMake3D(x::NSUInteger, y::NSUInteger, z::NSUInteger, width::NSUInteger, height::NSUInteger, depth::NSUInteger)::MTLRegion
6466
end
6567

6668
struct MTLSamplePosition
@@ -69,13 +71,13 @@ struct MTLSamplePosition
6971
end
7072

7173
function MTLSamplePositionMake(x, y)
72-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLSamplePositionMake(x::Cfloat, y::Cfloat)::MTLSamplePosition
74+
return @ccall libmtl.MTLSamplePositionMake(x::Cfloat, y::Cfloat)::MTLSamplePosition
7375
end
7476

7577
const MTLCoordinate2D = MTLSamplePosition
7678

7779
function MTLCoordinate2DMake(x, y)
78-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLCoordinate2DMake(x::Cfloat, y::Cfloat)::MTLCoordinate2D
80+
return @ccall libmtl.MTLCoordinate2DMake(x::Cfloat, y::Cfloat)::MTLCoordinate2D
7981
end
8082

8183
struct MTLResourceID
@@ -1346,7 +1348,7 @@ struct MTLClearColor
13461348
end
13471349

13481350
function MTLClearColorMake(red, green, blue, alpha)
1349-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLClearColorMake(red::Cdouble, green::Cdouble, blue::Cdouble, alpha::Cdouble)::MTLClearColor
1351+
return @ccall libmtl.MTLClearColorMake(red::Cdouble, green::Cdouble, blue::Cdouble, alpha::Cdouble)::MTLClearColor
13501352
end
13511353

13521354
@cenum MTLLoadAction::UInt64 begin
@@ -2373,7 +2375,7 @@ struct MTL4BufferRange
23732375
end
23742376

23752377
function MTL4BufferRangeMake(bufferAddress, length)
2376-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTL4BufferRangeMake(bufferAddress::MTLGPUAddress, length::UInt64)::MTL4BufferRange
2378+
return @ccall libmtl.MTL4BufferRangeMake(bufferAddress::MTLGPUAddress, length::UInt64)::MTL4BufferRange
23772379
end
23782380

23792381
struct _MTLPackedFloat3
@@ -2412,7 +2414,7 @@ end
24122414
const MTLPackedFloat3 = _MTLPackedFloat3
24132415

24142416
function MTLPackedFloat3Make(x, y, z)
2415-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLPackedFloat3Make(x::Cfloat, y::Cfloat, z::Cfloat)::MTLPackedFloat3
2417+
return @ccall libmtl.MTLPackedFloat3Make(x::Cfloat, y::Cfloat, z::Cfloat)::MTLPackedFloat3
24162418
end
24172419

24182420
struct MTLPackedFloatQuaternion
@@ -2423,7 +2425,7 @@ struct MTLPackedFloatQuaternion
24232425
end
24242426

24252427
function MTLPackedFloatQuaternionMake(x, y, z, w)
2426-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLPackedFloatQuaternionMake(x::Cfloat, y::Cfloat, z::Cfloat, w::Cfloat)::MTLPackedFloatQuaternion
2428+
return @ccall libmtl.MTLPackedFloatQuaternionMake(x::Cfloat, y::Cfloat, z::Cfloat, w::Cfloat)::MTLPackedFloatQuaternion
24272429
end
24282430

24292431
struct _MTLPackedFloat4x3
@@ -2991,7 +2993,7 @@ struct MTLIndirectCommandBufferExecutionRange
29912993
end
29922994

29932995
function MTLIndirectCommandBufferExecutionRangeMake(location, length)
2994-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLIndirectCommandBufferExecutionRangeMake(location::UInt32, length::UInt32)::MTLIndirectCommandBufferExecutionRange
2996+
return @ccall libmtl.MTLIndirectCommandBufferExecutionRangeMake(location::UInt32, length::UInt32)::MTLIndirectCommandBufferExecutionRange
29952997
end
29962998

29972999
@objcwrapper immutable = true MTLIndirectCommandBufferDescriptor <: NSObject
@@ -3269,19 +3271,19 @@ end
32693271
const MTLIOCompressionContext = Ptr{Cvoid}
32703272

32713273
function MTLIOCompressionContextDefaultChunkSize()
3272-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLIOCompressionContextDefaultChunkSize()::Csize_t
3274+
return @ccall libmtl.MTLIOCompressionContextDefaultChunkSize()::Csize_t
32733275
end
32743276

32753277
function MTLIOCreateCompressionContext(path, type, chunkSize)
3276-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLIOCreateCompressionContext(path::Cstring, type::MTLIOCompressionMethod, chunkSize::Csize_t)::MTLIOCompressionContext
3278+
return @ccall libmtl.MTLIOCreateCompressionContext(path::Cstring, type::MTLIOCompressionMethod, chunkSize::Csize_t)::MTLIOCompressionContext
32773279
end
32783280

32793281
function MTLIOCompressionContextAppendData(context, data, size)
3280-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLIOCompressionContextAppendData(context::MTLIOCompressionContext, data::Ptr{Cvoid}, size::Csize_t)::Cvoid
3282+
return @ccall libmtl.MTLIOCompressionContextAppendData(context::MTLIOCompressionContext, data::Ptr{Cvoid}, size::Csize_t)::Cvoid
32813283
end
32823284

32833285
function MTLIOFlushAndDestroyCompressionContext(context)
3284-
return @ccall (Symbol("/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib")).MTLIOFlushAndDestroyCompressionContext(context::MTLIOCompressionContext)::MTLIOCompressionStatus
3286+
return @ccall libmtl.MTLIOFlushAndDestroyCompressionContext(context::MTLIOCompressionContext)::MTLIOCompressionStatus
32853287
end
32863288

32873289
@objcwrapper immutable = true availability = macos(v"15.0.0") MTLResidencySetDescriptor <: NSObject

res/wrap/libmtl.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[general]
2-
library_name = "Symbol(\"/System/Library/Frameworks/Metal.framework/Resources/BridgeSupport/Metal.dylib\")"
2+
library_name = "libmtl"
33
output_file_path = "../../lib/mtl/libmtl.jl"
44
prologue_file_path = "libmtl_prologue.jl"
55

res/wrap/libmtl_prologue.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
const libmtl = Symbol("/System/Library/Frameworks/Metal.framework/Metal")
2+
13
const _NSRange = NSRange

src/utilities.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function versioninfo(io::IO=stdout)
6868
return
6969
end
7070

71-
const _iokitlib = Symbol("/System/Library/Frameworks/IOKit.framework/Resources/BridgeSupport/IOKit.dylib")
72-
const _cflib = Symbol("/System/Library/Frameworks/CoreFoundation.framework/Resources/BridgeSupport/CoreFoundation.dylib")
71+
const _iokitlib = Symbol("/System/Library/Frameworks/IOKit.framework/IOKit")
72+
const _cflib = Symbol("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")
7373

7474
@static if isdefined(Base, :OncePerProcess) # VERSION >= v"1.12.0-DEV.1421"
7575
const num_gpu_cores = OncePerProcess{Int64}() do

0 commit comments

Comments
 (0)