Skip to content

Adopt new SIMDn<T> names in overlays #25382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/public/Darwin/GameplayKit/GameplayKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import simd
@available(tvOS, introduced: 9.0)
extension GKPath {
/// Creates a path from an array of points
/// - Parameter points: an array of simd.float2 points to make a path from
/// - Parameter points: an array of SIMD2<Float> points to make a path from
/// - Parameter radius: radius of the path to create
/// - Parameter cyclical: if the path is of a cycle that loops back on itself
public convenience init(points: [simd.float2], radius: Float, cyclical: Bool) {
public convenience init(points: [SIMD2<Float>], radius: Float, cyclical: Bool) {
var variablePoints = points
self.init(__points: &variablePoints, count: points.count, radius: radius, cyclical: cyclical)
}
Expand All @@ -35,10 +35,10 @@ extension GKPath {
@available(tvOS, introduced: 10.0)
extension GKPath {
/// Creates a path from an array of points
/// - Parameter points: an array of simd.float3 points to make a path from
/// - Parameter points: an array of SIMD3<Float> points to make a path from
/// - Parameter radius: the radius of the path to create
/// - Parameter cyclical: if the path is of a cycle that loops back on itself
public convenience init(points: [simd.float3], radius: Float, cyclical: Bool) {
public convenience init(points: [SIMD3<Float>], radius: Float, cyclical: Bool) {
var variablePoints = points
self.init(__float3Points: &variablePoints, count: points.count, radius: radius, cyclical: cyclical)
}
Expand All @@ -50,7 +50,7 @@ extension GKPath {
extension GKPolygonObstacle {
/// Creates a polygon obstacle with an array of points.
/// - Parameter points: array of points in counter-clockwise order that are the vertices of a convex polygon
public convenience init(points: [simd.float2]) {
public convenience init(points: [SIMD2<Float>]) {
var variablePoints = points
self.init(__points: &variablePoints, count: points.count)
}
Expand Down
60 changes: 30 additions & 30 deletions stdlib/public/Darwin/ModelIO/ModelIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,47 +112,47 @@ extension MDLAnimatedScalarArray {
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector3Array {
@nonobjc public func set(float3Array array:[float3], atTime time: TimeInterval){
@nonobjc public func set(float3Array array:[SIMD3<Float>], atTime time: TimeInterval){
__setFloat3(array, count: array.count, atTime: time)
}

@nonobjc public func set(double3Array array:[double3], atTime time: TimeInterval){
@nonobjc public func set(double3Array array:[SIMD3<Double>], atTime time: TimeInterval){
__setDouble3(array, count: array.count, atTime: time)
}

@nonobjc public func float3Array(atTime time: TimeInterval) -> [float3] {
var values = [float3](repeating: float3(), count: Int(elementCount))
@nonobjc public func float3Array(atTime time: TimeInterval) -> [SIMD3<Float>] {
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(elementCount))
__getFloat3Array(&values[0], maxCount: elementCount, atTime: time)
return values
}

@nonobjc public func double3Array(atTime time: TimeInterval) -> [double3] {
var values = [double3](repeating: double3(), count: Int(elementCount))
@nonobjc public func double3Array(atTime time: TimeInterval) -> [SIMD3<Double>] {
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(elementCount))
__getDouble3Array(&values[0], maxCount: elementCount, atTime: time)
return values
}

@nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
@nonobjc public func reset(float3Array array:[SIMD3<Float>], atTimes times: [TimeInterval]){
__reset(withFloat3Array: array, count: array.count, atTimes: times, count: times.count)
}

@nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
@nonobjc public func reset(double3Array array:[SIMD3<Double>], atTimes times: [TimeInterval]){
__reset(withDouble3Array: array, count: array.count, atTimes: times, count: times.count)
}

@nonobjc public var float3Array: [float3] {
@nonobjc public var float3Array: [SIMD3<Float>] {
get {
let count = elementCount * timeSampleCount
var values = [float3](repeating: float3(), count: Int(count))
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(count))
__getFloat3Array(&values[0], maxCount: count)
return values
}
}

@nonobjc public var double3Array: [double3] {
@nonobjc public var double3Array: [SIMD3<Double>] {
get {
let count = elementCount * timeSampleCount
var values = [double3](repeating: double3(), count: Int(count))
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(count))
__getDouble3Array(&values[0], maxCount: count)
return values
}
Expand Down Expand Up @@ -243,25 +243,25 @@ extension MDLAnimatedScalar {
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector2 {
@nonobjc public func reset(float2Array array:[float2], atTimes times: [TimeInterval]){
@nonobjc public func reset(float2Array array:[SIMD2<Float>], atTimes times: [TimeInterval]){
__reset(withFloat2Array: array, atTimes: times, count: times.count)
}

@nonobjc public func reset(double2Array array:[double2], atTimes times: [TimeInterval]){
@nonobjc public func reset(double2Array array:[SIMD2<Double>], atTimes times: [TimeInterval]){
__reset(withDouble2Array: array, atTimes: times, count: times.count)
}

@nonobjc public var float2Array: [float2] {
@nonobjc public var float2Array: [SIMD2<Float>] {
get {
var values = [float2](repeating: float2(), count: Int(timeSampleCount))
var values = [SIMD2<Float>](repeating: SIMD2<Float>(), count: Int(timeSampleCount))
__getFloat2Array(&values[0], maxCount: timeSampleCount)
return values
}
}

@nonobjc public var double2Array: [double2] {
@nonobjc public var double2Array: [SIMD2<Double>] {
get {
var values = [double2](repeating: double2(), count: Int(timeSampleCount))
var values = [SIMD2<Double>](repeating: SIMD2<Double>(), count: Int(timeSampleCount))
__getDouble2Array(&values[0], maxCount: timeSampleCount)
return values
}
Expand All @@ -272,25 +272,25 @@ extension MDLAnimatedVector2 {
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector3 {
@nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
@nonobjc public func reset(float3Array array:[SIMD3<Float>], atTimes times: [TimeInterval]){
__reset(withFloat3Array: array, atTimes: times, count: times.count)
}

@nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
@nonobjc public func reset(double3Array array:[SIMD3<Double>], atTimes times: [TimeInterval]){
__reset(withDouble3Array: array, atTimes: times, count: times.count)
}

@nonobjc public var float3Array: [float3] {
@nonobjc public var float3Array: [SIMD3<Float>] {
get {
var values = [float3](repeating: float3(), count: Int(timeSampleCount))
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(timeSampleCount))
__getFloat3Array(&values[0], maxCount: timeSampleCount)
return values
}
}

@nonobjc public var double3Array: [double3] {
@nonobjc public var double3Array: [SIMD3<Double>] {
get {
var values = [double3](repeating: double3(), count: Int(timeSampleCount))
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(timeSampleCount))
__getDouble3Array(&values[0], maxCount: timeSampleCount)
return values
}
Expand All @@ -301,25 +301,25 @@ extension MDLAnimatedVector3 {
@available(iOS, introduced: 11.0)
@available(tvOS, introduced: 11.0)
extension MDLAnimatedVector4 {
@nonobjc public func reset(float4Array array:[float4], atTimes times: [TimeInterval]){
@nonobjc public func reset(float4Array array:[SIMD4<Float>], atTimes times: [TimeInterval]){
__reset(withFloat4Array: array, atTimes: times, count: times.count)
}

@nonobjc public func reset(double4Array array:[double4], atTimes times: [TimeInterval]){
@nonobjc public func reset(double4Array array:[SIMD4<Double>], atTimes times: [TimeInterval]){
__reset(withDouble4Array: array, atTimes: times, count: times.count)
}

@nonobjc public var float4Array: [float4] {
@nonobjc public var float4Array: [SIMD4<Float>] {
get {
var values = [float4](repeating: float4(), count: Int(timeSampleCount))
var values = [SIMD4<Float>](repeating: SIMD4<Float>(), count: Int(timeSampleCount))
__getFloat4Array(&values[0], maxCount: timeSampleCount)
return values
}
}

@nonobjc public var double4Array: [double4] {
@nonobjc public var double4Array: [SIMD4<Double>] {
get {
var values = [double4](repeating: double4(), count: Int(timeSampleCount))
var values = [SIMD4<Double>](repeating: SIMD4<Double>(), count: Int(timeSampleCount))
__getDouble4Array(&values[0], maxCount: timeSampleCount)
return values
}
Expand Down
24 changes: 12 additions & 12 deletions stdlib/public/Darwin/SceneKit/SceneKit.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ extension SCNVector3 {
public init(_ x: Int, _ y: Int, _ z: Int) {
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z))
}
public init(_ v: float3) {
public init(_ v: SIMD3<Float>) {
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z))
}
public init(_ v: double3) {
public init(_ v: SIMD3<Double>) {
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z))
}
}
Expand Down Expand Up @@ -78,10 +78,10 @@ extension SCNVector4 {
public init(_ x: Int, _ y: Int, _ z: Int, _ w: Int) {
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z), SCNFloat(w))
}
public init(_ v: float4) {
public init(_ v: SIMD4<Float>) {
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z), SCNFloat(v.w))
}
public init(_ v: double4) {
public init(_ v: SIMD4<Double>) {
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z), SCNFloat(v.w))
}
}
Expand Down Expand Up @@ -120,21 +120,21 @@ extension SCNMatrix4 {
extension float4x4 {
public init(_ m: SCNMatrix4) {
self.init([
float4(Float(m.m11), Float(m.m12), Float(m.m13), Float(m.m14)),
float4(Float(m.m21), Float(m.m22), Float(m.m23), Float(m.m24)),
float4(Float(m.m31), Float(m.m32), Float(m.m33), Float(m.m34)),
float4(Float(m.m41), Float(m.m42), Float(m.m43), Float(m.m44))
SIMD4<Float>(Float(m.m11), Float(m.m12), Float(m.m13), Float(m.m14)),
SIMD4<Float>(Float(m.m21), Float(m.m22), Float(m.m23), Float(m.m24)),
SIMD4<Float>(Float(m.m31), Float(m.m32), Float(m.m33), Float(m.m34)),
SIMD4<Float>(Float(m.m41), Float(m.m42), Float(m.m43), Float(m.m44))
])
}
}

extension double4x4 {
public init(_ m: SCNMatrix4) {
self.init([
double4(Double(m.m11), Double(m.m12), Double(m.m13), Double(m.m14)),
double4(Double(m.m21), Double(m.m22), Double(m.m23), Double(m.m24)),
double4(Double(m.m31), Double(m.m32), Double(m.m33), Double(m.m34)),
double4(Double(m.m41), Double(m.m42), Double(m.m43), Double(m.m44))
SIMD4<Double>(Double(m.m11), Double(m.m12), Double(m.m13), Double(m.m14)),
SIMD4<Double>(Double(m.m21), Double(m.m22), Double(m.m23), Double(m.m24)),
SIMD4<Double>(Double(m.m31), Double(m.m32), Double(m.m33), Double(m.m34)),
SIMD4<Double>(Double(m.m41), Double(m.m42), Double(m.m43), Double(m.m44))
])
}
}
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/Darwin/SpriteKit/SpriteKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension SKWarpGeometryGrid {
/// - Parameter rows: the number of rows to initialize the SKWarpGeometryGrid with
/// - Parameter sourcePositions: the source positions for the SKWarpGeometryGrid to warp from
/// - Parameter destinationPositions: the destination positions for SKWarpGeometryGrid to warp to
public convenience init(columns: Int, rows: Int, sourcePositions: [simd.float2] = [float2](), destinationPositions: [simd.float2] = [float2]()) {
public convenience init(columns: Int, rows: Int, sourcePositions: [SIMD2<Float>] = [SIMD2<Float>](), destinationPositions: [SIMD2<Float>] = [SIMD2<Float>]()) {
let requiredElementsCount = (columns + 1) * (rows + 1)
switch (destinationPositions.count, sourcePositions.count) {
case (0, 0):
Expand All @@ -79,11 +79,11 @@ extension SKWarpGeometryGrid {
}
}

public func replacingBySourcePositions(positions source: [simd.float2]) -> SKWarpGeometryGrid {
public func replacingBySourcePositions(positions source: [SIMD2<Float>]) -> SKWarpGeometryGrid {
return self.__replacingSourcePositions(source)
}

public func replacingByDestinationPositions(positions destination: [simd.float2]) -> SKWarpGeometryGrid {
public func replacingByDestinationPositions(positions destination: [SIMD2<Float>]) -> SKWarpGeometryGrid {
return self.__replacingDestPositions(destination)
}
}
22 changes: 10 additions & 12 deletions stdlib/public/Darwin/simd/Quaternion.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import Darwin

%for scalar in ['Float','Double']:
% quat = 'simd_quat' + ('f' if scalar == 'Float' else 'd')
% vec3 = str.lower(scalar) + '3'
% vec4 = str.lower(scalar) + '4'
% mat3 = 'simd_' + str.lower(scalar) + '3x3'
% mat4 = 'simd_' + str.lower(scalar) + '4x4'

Expand All @@ -34,13 +32,13 @@ extension ${quat} {
/// - r: The real (scalar) part.
@_transparent
public init(ix: ${scalar}, iy: ${scalar}, iz: ${scalar}, r: ${scalar}) {
self.init(vector: ${vec4}(ix, iy, iz, r))
self.init(vector: SIMD4<${scalar}>(ix, iy, iz, r))
}

/// Construct a quaternion from real and imaginary parts.
@_transparent
public init(real: ${scalar}, imag: ${vec3}) {
self.init(vector: simd_make_${vec4}(imag, real))
public init(real: ${scalar}, imag: SIMD3<${scalar}>) {
self.init(vector: simd_make_${str.lower(scalar)}4(imag, real))
}

/// A quaternion whose action is a rotation by `angle` radians about `axis`.
Expand All @@ -49,13 +47,13 @@ extension ${quat} {
/// - angle: The angle to rotate by measured in radians.
/// - axis: The axis to rotate around.
@_transparent
public init(angle: ${scalar}, axis: ${vec3}) {
public init(angle: ${scalar}, axis: SIMD3<${scalar}>) {
self = simd_quaternion(angle, axis)
}

/// A quaternion whose action rotates the vector `from` onto the vector `to`.
@_transparent
public init(from: ${vec3}, to: ${vec3}) {
public init(from: SIMD3<${scalar}>, to: SIMD3<${scalar}>) {
self = simd_quaternion(from, to)
}

Expand All @@ -80,11 +78,11 @@ extension ${quat} {
}

/// The imaginary (vector) part of `self`.
public var imag: ${vec3} {
public var imag: SIMD3<${scalar}> {
@_transparent
get { return simd_make_${vec3}(vector) }
get { return simd_make_${str.lower(scalar)}3(vector) }
@_transparent
set { vector = simd_make_${vec4}(newValue, vector.w) }
set { vector = simd_make_${str.lower(scalar)}4(newValue, vector.w) }
}

/// The angle (in radians) by which `self`'s action rotates.
Expand All @@ -95,7 +93,7 @@ extension ${quat} {

/// The normalized axis about which `self`'s action rotates.
@_transparent
public var axis: ${vec3} {
public var axis: SIMD3<${scalar}> {
return simd_axis(self)
}

Expand Down Expand Up @@ -126,7 +124,7 @@ extension ${quat} {
/// Applies the rotation represented by a unit quaternion to the vector and
/// returns the result.
@_transparent
public func act(_ vector: ${vec3}) -> ${vec3} {
public func act(_ vector: SIMD3<${scalar}>) -> SIMD3<${scalar}> {
return simd_act(self, vector)
}
}
Expand Down
16 changes: 7 additions & 9 deletions stdlib/public/Darwin/simd/simd.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ floating_types = ['Float','Double']

%for scalar in scalar_types:
% for count in [2, 3, 4]:
% vectype = ctype[scalar] + str(count)
% vectype = "SIMD" + str(count) + "<" + scalar + ">"
% vecsize = (8 if scalar == 'Double' else 4) * (4 if count == 3 else count)
% vecalign = (16 if vecsize > 16 else vecsize)
% is_floating = scalar in floating_types
% is_signed = scalar[0] != 'U'
% wrap = "" if is_floating else "&"

@available(swift, deprecated: 5.1, message: "Use SIMD${count}<${scalar}>")
public typealias ${vectype} = SIMD${count}<${scalar}>
public typealias ${ctype[scalar]}${count} = ${vectype}

% if is_signed:
/// Elementwise absolute value of a vector. The result is a vector of the same
Expand Down Expand Up @@ -337,17 +337,15 @@ public func step(_ x: ${scalar}, edge: ${scalar}) -> ${scalar} {
/// Interprets two two-dimensional vectors as three-dimensional vectors in the
/// xy-plane and computes their cross product, which lies along the z-axis.
@_transparent
public func cross(_ x: ${ctype[scalar]}2, _ y: ${ctype[scalar]}2)
-> ${ctype[scalar]}3 {
public func cross(_ x: SIMD2<${scalar}>, _ y: SIMD2<${scalar}>) -> SIMD3<${scalar}> {
return simd_cross(x,y)
}

/// Cross-product of two three-dimensional vectors. The resulting vector is
/// perpendicular to the plane determined by `x` and `y`, with length equal to
/// the oriented area of the parallelogram they determine.
@_transparent
public func cross(_ x: ${ctype[scalar]}3, _ y: ${ctype[scalar]}3)
-> ${ctype[scalar]}3 {
public func cross(_ x: SIMD3<${scalar}>, _ y: SIMD3<${scalar}>) -> SIMD3<${scalar}> {
return simd_cross(x,y)
}

Expand All @@ -359,9 +357,9 @@ public func cross(_ x: ${ctype[scalar]}3, _ y: ${ctype[scalar]}3)
% for cols in [2,3,4]:
% mattype = 'simd_' + ctype[type] + str(cols) + 'x' + str(rows)
% diagsize = rows if rows < cols else cols
% coltype = ctype[type] + str(rows)
% rowtype = ctype[type] + str(cols)
% diagtype = ctype[type] + str(diagsize)
% coltype = "SIMD" + str(rows) + "<" + type + ">"
% rowtype = "SIMD" + str(cols) + "<" + type + ">"
% diagtype = "SIMD" + str(diagsize) + "<" + type + ">"
% transtype = ctype[type] + str(rows) + 'x' + str(cols)

public typealias ${ctype[type]}${cols}x${rows} = ${mattype}
Expand Down