Skip to content

Commit 244a272

Browse files
Lance Parkerairspeedswift
authored andcommitted
Make Metal(Kit) overlays build in Swift 4 mode (#13223)
1 parent d2842b1 commit 244a272

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

stdlib/public/SDK/Metal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")
44
add_swift_library(swiftMetal ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
55
Metal.swift
66

7-
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" "-swift-version" "3"
7+
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
88
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
99
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
1010
SWIFT_MODULE_DEPENDS_OSX Darwin CoreFoundation CoreGraphics Dispatch Foundation IOKit ObjectiveC XPC # auto-updated

stdlib/public/SDK/Metal/Metal.swift

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extension MTLBlitCommandEncoder {
1818

1919
public func fill(buffer: MTLBuffer, range: Range<Int>, value: UInt8) {
20-
fill(buffer: buffer, range: NSMakeRange(range.lowerBound, range.count), value: value)
20+
__fill(buffer, range: NSMakeRange(range.lowerBound, range.count), value: value)
2121
}
2222
}
2323

@@ -28,13 +28,13 @@ extension MTLBuffer {
2828
#if os(OSX)
2929
@available(macOS, introduced: 10.11)
3030
public func didModifyRange(_ range: Range<Int>) {
31-
didModifyRange(NSMakeRange(range.lowerBound, range.count))
31+
__didModifyRange(NSMakeRange(range.lowerBound, range.count))
3232
}
3333
#endif
3434

3535
@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)
3636
public func addDebugMarker(_ marker: String, range: Range<Int>) {
37-
addDebugMarker(marker, range: NSMakeRange(range.lowerBound, range.count))
37+
__addDebugMarker(marker, range: NSMakeRange(range.lowerBound, range.count))
3838
}
3939
}
4040

@@ -44,28 +44,28 @@ extension MTLComputeCommandEncoder {
4444

4545
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
4646
public func useResources(_ resources: [MTLResource], usage: MTLResourceUsage) {
47-
useResources(resources, count: resources.count, usage: usage)
47+
__use(resources, count: resources.count, usage: usage)
4848
}
4949

5050
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
5151
public func useHeaps(_ heaps: [MTLHeap]) {
52-
useHeaps(heaps, count: heaps.count)
52+
__use(heaps, count: heaps.count)
5353
}
5454

5555
public func setBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
56-
setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
56+
__setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
5757
}
5858

5959
public func setTextures(_ textures: [MTLTexture?], range: Range<Int>) {
60-
setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
60+
__setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
6161
}
6262

6363
public func setSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
64-
setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
64+
__setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
6565
}
6666

6767
public func setSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
68-
setSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
68+
__setSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
6969
}
7070
}
7171

@@ -76,7 +76,7 @@ extension MTLDevice {
7676
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
7777
public func getDefaultSamplePositions(sampleCount: Int) -> [MTLSamplePosition] {
7878
var positions = [MTLSamplePosition](repeating: MTLSamplePosition(x: 0,y: 0), count: sampleCount)
79-
getDefaultSamplePositions(&positions, count: sampleCount)
79+
__getDefaultSamplePositions(&positions, count: sampleCount)
8080
return positions
8181
}
8282
}
@@ -87,7 +87,7 @@ extension MTLDevice {
8787
public func MTLCopyAllDevicesWithObserver(handler: @escaping MTLDeviceNotificationHandler) -> (devices:[MTLDevice], observer:NSObject) {
8888
var resultTuple: (devices:[MTLDevice], observer:NSObject)
8989
resultTuple.observer = NSObject()
90-
resultTuple.devices = MTLCopyAllDevicesWithObserver(AutoreleasingUnsafeMutablePointer<NSObjectProtocol?>(&resultTuple.observer), handler)
90+
resultTuple.devices = __MTLCopyAllDevicesWithObserver(AutoreleasingUnsafeMutablePointer<NSObjectProtocol?>(&resultTuple.observer), handler)
9191
return resultTuple
9292
}
9393
#endif
@@ -97,7 +97,7 @@ public func MTLCopyAllDevicesWithObserver(handler: @escaping MTLDeviceNotificati
9797
extension MTLFunctionConstantValues {
9898

9999
public func setConstantValues(_ values: UnsafeRawPointer, type: MTLDataType, range: Range<Int>) {
100-
setConstantValues(values, type: type, with: NSMakeRange(range.lowerBound, range.count))
100+
__setConstantValues(values, type: type, with: NSMakeRange(range.lowerBound, range.count))
101101
}
102102

103103
}
@@ -107,15 +107,15 @@ extension MTLFunctionConstantValues {
107107
extension MTLArgumentEncoder {
108108

109109
public func setBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
110-
setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
110+
__setBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
111111
}
112112

113113
public func setTextures(_ textures: [MTLTexture?], range: Range<Int>) {
114-
setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
114+
__setTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
115115
}
116116

117117
public func setSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
118-
setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
118+
__setSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
119119
}
120120
}
121121

@@ -125,56 +125,56 @@ extension MTLRenderCommandEncoder {
125125

126126
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
127127
public func useResources(_ resources: [MTLResource], usage: MTLResourceUsage) {
128-
useResources(resources, count: resources.count, usage: usage)
128+
__use(resources, count: resources.count, usage: usage)
129129
}
130130

131131
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
132132
public func useHeaps(_ heaps: [MTLHeap]) {
133-
useHeaps(heaps, count: heaps.count)
133+
__use(heaps, count: heaps.count)
134134
}
135135

136136
#if os(OSX)
137137
@available(macOS 10.13, *)
138138
public func setViewports(_ viewports: [MTLViewport]) {
139-
setViewports(viewports, count: viewports.count)
139+
__setViewports(viewports, count: viewports.count)
140140
}
141141

142142
@available(macOS 10.13, *)
143143
public func setScissorRects(_ scissorRects: [MTLScissorRect]) {
144-
setScissorRects(scissorRects, count: scissorRects.count)
144+
__setScissorRects(scissorRects, count: scissorRects.count)
145145
}
146146
#endif
147147

148148
public func setVertexBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
149-
setVertexBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
149+
__setVertexBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
150150
}
151151

152152
public func setVertexTextures(_ textures: [MTLTexture?], range: Range<Int>) {
153-
setVertexTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
153+
__setVertexTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
154154
}
155155

156156
public func setVertexSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
157-
setVertexSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
157+
__setVertexSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
158158
}
159159

160160
public func setVertexSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
161-
setVertexSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
161+
__setVertexSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
162162
}
163163

164164
public func setFragmentBuffers(_ buffers: [MTLBuffer?], offsets: [Int], range: Range<Int>) {
165-
setFragmentBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
165+
__setFragmentBuffers(buffers, offsets: offsets, with: NSMakeRange(range.lowerBound, range.count))
166166
}
167167

168168
public func setFragmentTextures(_ textures: [MTLTexture?], range: Range<Int>) {
169-
setFragmentTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
169+
__setFragmentTextures(textures, with: NSMakeRange(range.lowerBound, range.count))
170170
}
171171

172172
public func setFragmentSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
173-
setFragmentSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
173+
__setFragmentSamplerStates(samplers, with: NSMakeRange(range.lowerBound, range.count))
174174
}
175175

176176
public func setFragmentSamplerStates(_ samplers: [MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>) {
177-
setFragmentSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
177+
__setFragmentSamplerStates(samplers, lodMinClamps: lodMinClamps, lodMaxClamps: lodMaxClamps, with: NSMakeRange(range.lowerBound, range.count))
178178
}
179179

180180
#if os(iOS)
@@ -207,14 +207,14 @@ extension MTLRenderPassDescriptor {
207207

208208
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
209209
public func setSamplePositions(_ positions: [MTLSamplePosition]) {
210-
setSamplePositions(positions, count: positions.count)
210+
__setSamplePositions(positions, count: positions.count)
211211
}
212212

213213
@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)
214214
public func getSamplePositions() -> [MTLSamplePosition] {
215-
let numPositions = getSamplePositions(nil, count: 0)
215+
let numPositions = __getSamplePositions(nil, count: 0)
216216
var positions = [MTLSamplePosition](repeating: MTLSamplePosition(x: 0,y: 0), count: numPositions)
217-
getSamplePositions(&positions, count: numPositions)
217+
__getSamplePositions(&positions, count: numPositions)
218218
return positions
219219
}
220220

@@ -226,6 +226,6 @@ extension MTLTexture {
226226

227227
@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)
228228
public func makeTextureView(pixelFormat: MTLPixelFormat, textureType: MTLTextureType, levels levelRange: Range<Int>, slices sliceRange: Range<Int>) -> MTLTexture? {
229-
return makeTextureView(pixelFormat: pixelFormat, textureType: textureType, levels: NSMakeRange(levelRange.lowerBound, levelRange.count), slices: NSMakeRange(sliceRange.lowerBound, sliceRange.count))
229+
return __newTextureView(with: pixelFormat, textureType: textureType, levels: NSMakeRange(levelRange.lowerBound, levelRange.count), slices: NSMakeRange(sliceRange.lowerBound, sliceRange.count))
230230
}
231231
}

stdlib/public/SDK/MetalKit/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include("../../../../cmake/modules/StandaloneOverlay.cmake")
44
add_swift_library(swiftMetalKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
55
MetalKit.swift
66

7-
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}" "-swift-version" "3"
7+
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
88
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
99
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
1010
SWIFT_MODULE_DEPENDS_OSX Darwin AppKit CoreData CoreFoundation CoreGraphics CoreImage Dispatch Foundation IOKit Metal ModelIO ObjectiveC QuartzCore simd XPC # auto-updated

stdlib/public/SDK/MetalKit/MetalKit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extension MTKMesh {
1818
public class func newMeshes(asset: MDLAsset, device: MTLDevice) throws -> (modelIOMeshes: [MDLMesh], metalKitMeshes: [MTKMesh]) {
1919
var modelIOMeshes: NSArray?
20-
var metalKitMeshes = try MTKMesh.newMeshes(from: asset, device: device, sourceMeshes: &modelIOMeshes)
20+
let metalKitMeshes = try MTKMesh.__newMeshes(from: asset, device: device, sourceMeshes: &modelIOMeshes)
2121
return (modelIOMeshes: modelIOMeshes as! [MDLMesh], metalKitMeshes: metalKitMeshes)
2222
}
2323
}
@@ -26,7 +26,7 @@ extension MTKMesh {
2626
@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)
2727
public func MTKModelIOVertexDescriptorFromMetalWithError(_ metalDescriptor: MTLVertexDescriptor) throws -> MDLVertexDescriptor {
2828
var error: NSError? = nil
29-
let result = MTKModelIOVertexDescriptorFromMetalWithError(metalDescriptor, &error)
29+
let result = __MTKModelIOVertexDescriptorFromMetalWithError(metalDescriptor, &error)
3030
if let error = error {
3131
throw error
3232
}
@@ -37,7 +37,7 @@ public func MTKModelIOVertexDescriptorFromMetalWithError(_ metalDescriptor: MTLV
3737
@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)
3838
public func MTKMetalVertexDescriptorFromModelIOWithError(_ modelIODescriptor: MDLVertexDescriptor) throws -> MTLVertexDescriptor? {
3939
var error: NSError? = nil
40-
let result = MTKMetalVertexDescriptorFromModelIOWithError(modelIODescriptor, &error)
40+
let result = __MTKMetalVertexDescriptorFromModelIOWithError(modelIODescriptor, &error)
4141
if let error = error {
4242
throw error
4343
}

0 commit comments

Comments
 (0)