From a5c301e57048fff9c2127d31317f52a5516ec6b1 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 19 Feb 2026 09:34:04 +0000 Subject: [PATCH 1/2] [Generated] swift-format --- ios/graphics/Model/GraphicsFactory.swift | 8 +- ios/graphics/Model/Polygon/Polygon2d.swift | 2 +- .../Model/Polygon/Polygon2dTessellated.swift | 80 +++++++++---------- .../Model/Quad/Quad2dTessellated.swift | 77 +++++++++--------- ios/graphics/Model/Vertex3DTessellated.swift | 6 +- .../Model/Vertex3DTextureTessellated.swift | 4 +- ios/graphics/Pipelines/PipelineLibrary.swift | 24 +++--- ios/graphics/Shader/ShaderFactory.swift | 4 +- ios/helpers/Half.swift | 2 +- ios/maps/SwiftUI/MapView.swift | 2 +- 10 files changed, 104 insertions(+), 105 deletions(-) diff --git a/ios/graphics/Model/GraphicsFactory.swift b/ios/graphics/Model/GraphicsFactory.swift index 9897467f5..1a5e1145f 100644 --- a/ios/graphics/Model/GraphicsFactory.swift +++ b/ios/graphics/Model/GraphicsFactory.swift @@ -12,7 +12,7 @@ import Foundation import MapCoreSharedModule class GraphicsFactory: MCGraphicsObjectFactoryInterface { - + func createQuadMask(_ is3d: Bool) -> (any MCQuad2dInterface)? { let shader = ColorShader(shader: .colorShader) return Quad2d(shader: shader, metalContext: .current) @@ -22,7 +22,7 @@ class GraphicsFactory: MCGraphicsObjectFactoryInterface { let shader = MaskShader() return Polygon2d(shader: shader, metalContext: .current) } - + func createPolygonMaskTessellated(_ is3d: Bool) -> (any MCPolygon2dInterface)? { let shader = MaskShader(shader: .maskTessellatedShader) return Polygon2dTessellated(shader: shader, metalContext: .current) @@ -42,7 +42,7 @@ class GraphicsFactory: MCGraphicsObjectFactoryInterface { guard let shader else { fatalError("No Shader provided") } return Quad2d(shader: shader, metalContext: .current) } - + func createQuadTessellated(_ shader: MCShaderProgramInterface?) -> MCQuad2dInterface? { guard let shader else { fatalError("No Shader provided") } return Quad2dTessellated(shader: shader, metalContext: .current) @@ -67,7 +67,7 @@ class GraphicsFactory: MCGraphicsObjectFactoryInterface { guard let shader else { fatalError("No Shader provided") } return Polygon2d(shader: shader, metalContext: .current) } - + func createPolygonTessellated(_ shader: MCShaderProgramInterface?) -> MCPolygon2dInterface? { guard let shader else { fatalError("No Shader provided") } return Polygon2dTessellated(shader: shader, metalContext: .current) diff --git a/ios/graphics/Model/Polygon/Polygon2d.swift b/ios/graphics/Model/Polygon/Polygon2d.swift index bb084bfdc..7235eded4 100644 --- a/ios/graphics/Model/Polygon/Polygon2d.swift +++ b/ios/graphics/Model/Polygon/Polygon2d.swift @@ -215,7 +215,7 @@ extension Polygon2d: MCMaskingObjectInterface { extension Polygon2d: MCPolygon2dInterface { func setSubdivisionFactor(_ factor: Int32) {} - + func setVertices( _ vertices: MCSharedBytes, indices: MCSharedBytes, origin: MCVec3D, is3d: Bool ) { diff --git a/ios/graphics/Model/Polygon/Polygon2dTessellated.swift b/ios/graphics/Model/Polygon/Polygon2dTessellated.swift index d8c4875bc..54d811999 100644 --- a/ios/graphics/Model/Polygon/Polygon2dTessellated.swift +++ b/ios/graphics/Model/Polygon/Polygon2dTessellated.swift @@ -19,10 +19,10 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { private var verticesBuffer: MTLBuffer? private var indicesBuffer: MTLBuffer? private var indicesCount: Int = 0 - + private var tessellationFactorsBuffer: MTLBuffer? private var originBuffers: MultiBuffer - + private var is3d = false private var subdivisionFactor: Int32 = 0 @@ -38,14 +38,14 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { sampler: metalContext.samplerLibrary.value( Sampler.magLinear.rawValue)!, label: "Polygon2dTessellated") - + let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits - + var tessellationFactors = MTLTriangleTessellationFactorsHalf( edgeTessellationFactor: (factorH, factorH, factorH), insideTessellationFactor: factorH ) - + self.tessellationFactorsBuffer.copyOrCreate( bytes: &tessellationFactors, length: MemoryLayout.stride, @@ -95,7 +95,7 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { encoder.setDepthStencilState(renderPassStencilState) encoder.setStencilReferenceValue(0b0000_0000) } - + renderMain( encoder: encoder, context: context, @@ -104,7 +104,7 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { origin: origin, isScreenSpaceCoords: isScreenSpaceCoords) } - + private func renderMain( encoder: MTLRenderCommandEncoder, context: RenderingContext, @@ -117,7 +117,7 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { let indicesBuffer, let tessellationFactorsBuffer else { return } - + shader.setupProgram(context) shader.preRender(context, isScreenSpaceCoords: isScreenSpaceCoords) @@ -146,7 +146,7 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { bufferPointer.pointee.z = Float(originOffset.z - origin.z) } encoder.setVertexBuffer(originOffsetBuffer, offset: 0, index: 3) - + let originBuffer = originBuffers.getNextBuffer(context) if let bufferPointer = originBuffer?.contents() .assumingMemoryBound( @@ -159,35 +159,35 @@ final class Polygon2dTessellated: BaseGraphicsObject, @unchecked Sendable { fatalError() } encoder.setVertexBuffer(originBuffer, offset: 0, index: 4) - + encoder.setVertexBytes(&self.is3d, length: MemoryLayout.stride, index: 5) - + encoder.setTessellationFactorBuffer(tessellationFactorsBuffer, offset: 0, instanceStride: 0) - + #if HARDWARE_TESSELLATION_WIREFRAME_METAL - let wireframePipeline = MetalContext.current.pipelineLibrary.value( - Pipeline( - type: .polygonTessellatedWireframeShader, - blendMode: (shader as? BaseShader)?.blendMode ?? .NORMAL) - ) - if let wireframePipeline { - context.setRenderPipelineStateIfNeeded(wireframePipeline) - } - encoder.setTriangleFillMode(.lines) - encoder.drawIndexedPatches( - numberOfPatchControlPoints: 3, - patchStart: 0, - patchCount: indicesCount / 3, - patchIndexBuffer: nil, - patchIndexBufferOffset: 0, - controlPointIndexBuffer: indicesBuffer, - controlPointIndexBufferOffset: 0, - instanceCount: 1, - baseInstance: 0) - encoder.setTriangleFillMode(.fill) - shader.preRender(context, isScreenSpaceCoords: isScreenSpaceCoords) + let wireframePipeline = MetalContext.current.pipelineLibrary.value( + Pipeline( + type: .polygonTessellatedWireframeShader, + blendMode: (shader as? BaseShader)?.blendMode ?? .NORMAL) + ) + if let wireframePipeline { + context.setRenderPipelineStateIfNeeded(wireframePipeline) + } + encoder.setTriangleFillMode(.lines) + encoder.drawIndexedPatches( + numberOfPatchControlPoints: 3, + patchStart: 0, + patchCount: indicesCount / 3, + patchIndexBuffer: nil, + patchIndexBufferOffset: 0, + controlPointIndexBuffer: indicesBuffer, + controlPointIndexBufferOffset: 0, + instanceCount: 1, + baseInstance: 0) + encoder.setTriangleFillMode(.fill) + shader.preRender(context, isScreenSpaceCoords: isScreenSpaceCoords) #endif - + encoder.drawIndexedPatches( numberOfPatchControlPoints: 3, patchStart: 0, @@ -266,14 +266,14 @@ extension Polygon2dTessellated: MCPolygon2dInterface { lock.withCritical { if self.subdivisionFactor != factor { self.subdivisionFactor = factor - - let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits; - + + let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits + var tessellationFactors = MTLTriangleTessellationFactorsHalf( edgeTessellationFactor: (factorH, factorH, factorH), insideTessellationFactor: factorH - ); - + ) + self.tessellationFactorsBuffer.copyOrCreate( bytes: &tessellationFactors, length: MemoryLayout.stride, @@ -281,7 +281,7 @@ extension Polygon2dTessellated: MCPolygon2dInterface { } } } - + func setVertices( _ vertices: MCSharedBytes, indices: MCSharedBytes, origin: MCVec3D, is3d: Bool ) { diff --git a/ios/graphics/Model/Quad/Quad2dTessellated.swift b/ios/graphics/Model/Quad/Quad2dTessellated.swift index 9c1b206c5..b03dbcc01 100644 --- a/ios/graphics/Model/Quad/Quad2dTessellated.swift +++ b/ios/graphics/Model/Quad/Quad2dTessellated.swift @@ -16,10 +16,10 @@ import simd final class Quad2dTessellated: BaseGraphicsObject, @unchecked Sendable { private var verticesBuffer: MTLBuffer? - + private var tessellationFactorsBuffer: MTLBuffer? private var originBuffers: MultiBuffer - + private var is3d = false private var subdivisionFactor: Int32 = 0 @@ -53,15 +53,14 @@ final class Quad2dTessellated: BaseGraphicsObject, @unchecked Sendable { sampler: metalContext.samplerLibrary.value( Sampler.magLinear.rawValue)!, label: label) - - - let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits; - + + let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits + var tessellationFactors = MTLQuadTessellationFactorsHalf( edgeTessellationFactor: (factorH, factorH, factorH, factorH), insideTessellationFactor: (factorH, factorH) - ); - + ) + self.tessellationFactorsBuffer.copyOrCreate( bytes: &tessellationFactors, length: MemoryLayout.stride, @@ -187,7 +186,7 @@ final class Quad2dTessellated: BaseGraphicsObject, @unchecked Sendable { if let texture { encoder.setFragmentTexture(texture, index: 0) } - + let originBuffer = originBuffers.getNextBuffer(context) if let bufferPointer = originBuffer?.contents() .assumingMemoryBound( @@ -200,33 +199,33 @@ final class Quad2dTessellated: BaseGraphicsObject, @unchecked Sendable { fatalError() } encoder.setVertexBuffer(originBuffer, offset: 0, index: 4) - + encoder.setVertexBytes(&self.is3d, length: MemoryLayout.stride, index: 5) - + encoder.setTessellationFactorBuffer(tessellationFactorsBuffer, offset: 0, instanceStride: 0) - + #if HARDWARE_TESSELLATION_WIREFRAME_METAL - let wireframePipeline = MetalContext.current.pipelineLibrary.value( - Pipeline( - type: .quadTessellatedWireframeShader, - blendMode: (shader as? BaseShader)?.blendMode ?? .NORMAL) - ) - if let wireframePipeline { - context.setRenderPipelineStateIfNeeded(wireframePipeline) - } - encoder.setTriangleFillMode(.lines) - encoder.drawPatches( - numberOfPatchControlPoints: 4, - patchStart: 0, - patchCount: 1, - patchIndexBuffer: nil, - patchIndexBufferOffset: 0, - instanceCount: 1, - baseInstance: 0) - encoder.setTriangleFillMode(.fill) - shader.preRender(context, isScreenSpaceCoords: isScreenSpaceCoords) + let wireframePipeline = MetalContext.current.pipelineLibrary.value( + Pipeline( + type: .quadTessellatedWireframeShader, + blendMode: (shader as? BaseShader)?.blendMode ?? .NORMAL) + ) + if let wireframePipeline { + context.setRenderPipelineStateIfNeeded(wireframePipeline) + } + encoder.setTriangleFillMode(.lines) + encoder.drawPatches( + numberOfPatchControlPoints: 4, + patchStart: 0, + patchCount: 1, + patchIndexBuffer: nil, + patchIndexBufferOffset: 0, + instanceCount: 1, + baseInstance: 0) + encoder.setTriangleFillMode(.fill) + shader.preRender(context, isScreenSpaceCoords: isScreenSpaceCoords) #endif - + encoder.drawPatches( numberOfPatchControlPoints: 4, patchStart: 0, @@ -284,14 +283,14 @@ extension Quad2dTessellated: MCQuad2dInterface { lock.withCritical { if self.subdivisionFactor != factor { self.subdivisionFactor = factor - - let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits; - + + let factorH = Half(pow(2, Float(self.subdivisionFactor))).bits + var tessellationFactors = MTLQuadTessellationFactorsHalf( edgeTessellationFactor: (factorH, factorH, factorH, factorH), insideTessellationFactor: (factorH, factorH) - ); - + ) + self.tessellationFactorsBuffer.copyOrCreate( bytes: &tessellationFactors, length: MemoryLayout.stride, @@ -317,7 +316,7 @@ extension Quad2dTessellated: MCQuad2dInterface { return MCVec3D(x: x, y: y, z: 0) } } - + /* The quad is made out of 4 vertices as following B----C @@ -352,7 +351,7 @@ extension Quad2dTessellated: MCQuad2dInterface { textureU: textureCoordinates.xF + textureCoordinates.widthF, textureV: textureCoordinates.yF + textureCoordinates.heightF), // D ] - + lock.withCritical { self.is3d = is3d self.originOffset = origin diff --git a/ios/graphics/Model/Vertex3DTessellated.swift b/ios/graphics/Model/Vertex3DTessellated.swift index eea2ac177..a0d0049a1 100644 --- a/ios/graphics/Model/Vertex3DTessellated.swift +++ b/ios/graphics/Model/Vertex3DTessellated.swift @@ -16,19 +16,19 @@ struct Vertex3DTessellated: Equatable { let vertexDescriptor = MTLVertexDescriptor() let bufferIndex = 0 var offset = 0 - + // Position vertexDescriptor.attributes[0].bufferIndex = bufferIndex vertexDescriptor.attributes[0].format = .float4 vertexDescriptor.attributes[0].offset = offset offset += MemoryLayout>.stride - + // Frame Coord (2D coord used to transform onto unit sphere) vertexDescriptor.attributes[1].bufferIndex = bufferIndex vertexDescriptor.attributes[1].format = .float2 vertexDescriptor.attributes[1].offset = offset offset += MemoryLayout>.stride - + vertexDescriptor.layouts[0].stride = offset vertexDescriptor.layouts[0].stepRate = 1 vertexDescriptor.layouts[0].stepFunction = .perPatchControlPoint diff --git a/ios/graphics/Model/Vertex3DTextureTessellated.swift b/ios/graphics/Model/Vertex3DTextureTessellated.swift index efdeb51a1..93901d357 100644 --- a/ios/graphics/Model/Vertex3DTextureTessellated.swift +++ b/ios/graphics/Model/Vertex3DTextureTessellated.swift @@ -30,7 +30,7 @@ public struct Vertex3DTextureTessellated: Equatable { vertexDescriptor.attributes[0].format = .float3 vertexDescriptor.attributes[0].offset = offset offset += MemoryLayout>.stride - + // Frame Coord (2D coord to project onto unit sphere) vertexDescriptor.attributes[1].bufferIndex = bufferIndex vertexDescriptor.attributes[1].format = .float2 @@ -42,7 +42,7 @@ public struct Vertex3DTextureTessellated: Equatable { vertexDescriptor.attributes[2].format = .float2 vertexDescriptor.attributes[2].offset = offset offset += MemoryLayout>.stride - + vertexDescriptor.layouts[0].stride = MemoryLayout.stride vertexDescriptor.layouts[0].stepRate = 1 vertexDescriptor.layouts[0].stepFunction = .perPatchControlPoint diff --git a/ios/graphics/Pipelines/PipelineLibrary.swift b/ios/graphics/Pipelines/PipelineLibrary.swift index 2924702af..d38436ef0 100644 --- a/ios/graphics/Pipelines/PipelineLibrary.swift +++ b/ios/graphics/Pipelines/PipelineLibrary.swift @@ -8,9 +8,9 @@ * SPDX-License-Identifier: MPL-2.0 */ +import MapCoreSharedModule @preconcurrency import Metal import OSLog -import MapCoreSharedModule public enum PipelineDescriptorFactory { public static func pipelineDescriptor( @@ -76,7 +76,7 @@ public enum PipelineDescriptorFactory { pipelineDescriptor.vertexFunction = vertexFunction pipelineDescriptor.fragmentFunction = fragmentFunction } - + if tessellation != MCTessellationMode.NONE { pipelineDescriptor.maxTessellationFactor = 64 pipelineDescriptor.tessellationPartitionMode = .pow2 @@ -85,7 +85,7 @@ public enum PipelineDescriptorFactory { pipelineDescriptor.tessellationOutputWindingOrder = .clockwise pipelineDescriptor.tessellationControlPointIndexType = .none pipelineDescriptor.isTessellationFactorScaleEnabled = false - + if tessellation == MCTessellationMode.TRIANGLE { pipelineDescriptor.tessellationOutputWindingOrder = .counterClockwise pipelineDescriptor.tessellationControlPointIndexType = .uint16 @@ -135,13 +135,13 @@ public struct Pipeline: Codable, CaseIterable, Hashable, Sendable { Pipeline(type: type, blendMode: blendMode) } } - #if targetEnvironment(simulator) - return allPipelines.filter { - $0.type.tessellation == MCTessellationMode.NONE - } - #else - return allPipelines - #endif + #if targetEnvironment(simulator) + return allPipelines.filter { + $0.type.tessellation == MCTessellationMode.NONE + } + #else + return allPipelines + #endif } } @@ -337,7 +337,7 @@ public enum PipelineType: String, CaseIterable, Codable, Sendable { return Vertex.descriptor } } - + var tessellation: MCTessellationMode { switch self { case .quadTessellatedShader: @@ -345,7 +345,7 @@ public enum PipelineType: String, CaseIterable, Codable, Sendable { case .maskTessellatedShader, .polygonTessellatedShader, .polygonTessellatedWireframeShader: - return MCTessellationMode.TRIANGLE + return MCTessellationMode.TRIANGLE case .quadTessellatedWireframeShader: return MCTessellationMode.QUAD default: diff --git a/ios/graphics/Shader/ShaderFactory.swift b/ios/graphics/Shader/ShaderFactory.swift index 9a9c4a345..9b27fe223 100644 --- a/ios/graphics/Shader/ShaderFactory.swift +++ b/ios/graphics/Shader/ShaderFactory.swift @@ -23,7 +23,7 @@ class ShaderFactory: MCShaderFactoryInterface { func createUnitSphereRasterShader() -> MCRasterShaderInterface? { RasterShader() } - + func createQuadTessellatedShader() -> MCRasterShaderInterface? { RasterShader(shader: .quadTessellatedShader) } @@ -87,7 +87,7 @@ class ShaderFactory: MCShaderFactoryInterface { func createColorShader() -> MCColorShaderInterface? { ColorShader() } - + func createPolygonTessellatedShader(_ unitSphere: Bool) -> MCColorShaderInterface? { ColorShader(shader: .polygonTessellatedShader) } diff --git a/ios/helpers/Half.swift b/ios/helpers/Half.swift index 5139d4f21..4586d85c2 100644 --- a/ios/helpers/Half.swift +++ b/ios/helpers/Half.swift @@ -29,7 +29,7 @@ public struct Half: Equatable, Hashable, Sendable { private static func floatToHalfBits(_ value: Float) -> UInt16 { let f = value.bitPattern let sign = UInt16((f >> 31) & 0x1) - let exp = Int((f >> 23) & 0xFF) - 127 + 15 + let exp = Int((f >> 23) & 0xFF) - 127 + 15 var mant = UInt16((f >> 13) & 0x3FF) if exp <= 0 { diff --git a/ios/maps/SwiftUI/MapView.swift b/ios/maps/SwiftUI/MapView.swift index 9bdaba79e..61a9f4630 100644 --- a/ios/maps/SwiftUI/MapView.swift +++ b/ios/maps/SwiftUI/MapView.swift @@ -485,7 +485,7 @@ open class TouchHandler: MCTouchInterface { open func onTwoFingerMoveComplete() -> Bool { false } - + open func onScroll(_ posScreen: MCVec2F, scrollDelta: Float) -> Bool { false } From 03f3d330d458ff0dd3a775ba1708fb376c490731 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 19 Feb 2026 09:34:05 +0000 Subject: [PATCH 2/2] Add swift-format commit to .git-blame-ignore-revs --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 12a28dbdb..8c7affef6 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -17,3 +17,4 @@ f45ecf1f3b911a2606feeb22951cfbc88f526832 de6a066f513b111ba8b968d225dce93a99473a38 3df05b9d0167331dc6860201b5bb6970f63613c9 838fce6928f73a29004870cdd8dbe847b28f26c4 +a5c301e57048fff9c2127d31317f52a5516ec6b1