@@ -90,9 +90,10 @@ extension MTLDevice {
90
90
91
91
@available ( macOS 10 . 13 , iOS 11 . 0 , tvOS 11 . 0 , * )
92
92
public func getDefaultSamplePositions( sampleCount: Int ) -> [ MTLSamplePosition ] {
93
- var positions = [ MTLSamplePosition] ( repeating: MTLSamplePosition ( x: 0 , y: 0 ) , count: sampleCount)
94
- __getDefaultSamplePositions ( & positions, count: sampleCount)
95
- return positions
93
+ return [ MTLSamplePosition] ( unsafeUninitializedCapacity: sampleCount) { buf, initializedCount in
94
+ __getDefaultSamplePositions ( buf. baseAddress!, count: sampleCount)
95
+ initializedCount = sampleCount
96
+ }
96
97
}
97
98
}
98
99
@@ -263,9 +264,10 @@ extension MTLRenderPassDescriptor {
263
264
@available ( macOS 10 . 13 , iOS 11 . 0 , tvOS 11 . 0 , * )
264
265
public func getSamplePositions( ) -> [ MTLSamplePosition ] {
265
266
let numPositions = __getSamplePositions ( nil , count: 0 )
266
- var positions = [ MTLSamplePosition] ( repeating: MTLSamplePosition ( x: 0 , y: 0 ) , count: numPositions)
267
- __getSamplePositions ( & positions, count: numPositions)
268
- return positions
267
+ return [ MTLSamplePosition] ( unsafeUninitializedCapacity: numPositions) { buf, initializedCount in
268
+ __getSamplePositions ( buf. baseAddress!, count: numPositions)
269
+ initializedCount = numPositions
270
+ }
269
271
}
270
272
271
273
}
0 commit comments