├── README.md ├── MeshFrame ├── MeshFrame │ ├── sjy.bin │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── main.m │ ├── ViewController.h │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── FrameRenderer │ │ │ └── FrameRenderer.h │ ├── Utility │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── MeshFrame.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── MetalCube ├── MetalCube │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── ViewController.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── MeshRenderer │ │ │ ├── MeshRenderer.h │ │ │ └── mesh.metal │ ├── Utility │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── MetalCube.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── MetalLine ├── MetalLine │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── ViewController.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── LineRenderer │ │ │ └── LineRenderer.h │ ├── ViewController.m │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── MetalLine.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── MetalPoint ├── MetalPoint │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── AppDelegate.h │ ├── ViewController.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── PointRenderer │ │ │ ├── PointRenderer.h │ │ │ └── point.metal │ ├── ViewController.m │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── MetalPoint.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── GaussianBlurMPS ├── GaussianBlurMPS │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ ├── MetalRenderer │ │ │ └── VideoGaussianRenderer │ │ │ │ └── VideoGaussianRenderer.h │ │ └── MetalEncoder │ │ │ ├── GaussianBlurEncoder │ │ │ ├── GaussianBlurEncoder.h │ │ │ └── GaussianBlurEncoder.m │ │ │ └── TextureRendererEncoder │ │ │ ├── TextureRendererEncoder.h │ │ │ └── TextureRendererEncoder.metal │ ├── Utility │ │ ├── Device │ │ │ └── FrontCamera.h │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist └── GaussianBlurMPS.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── TextureRenderer ├── TextureRenderer │ ├── Assets.xcassets │ │ └── Contents.json │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── TextureRenderer │ │ │ ├── TextureRenderer.h │ │ │ └── TextureRenderer.metal │ ├── Utility │ │ ├── Device │ │ │ └── FrontCamera.h │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist └── TextureRenderer.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── others ├── MetalPoint │ ├── MetalPoint │ │ ├── Assets.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── ViewController.h │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Metal │ │ │ ├── MetalView │ │ │ │ └── MetalView.h │ │ │ ├── MetalContext │ │ │ │ ├── MetalContext.h │ │ │ │ └── MetalContext.mm │ │ │ ├── MetalRenderer │ │ │ │ └── PointRenderer │ │ │ │ │ └── PointRenderer.h │ │ │ └── MetalEncoder │ │ │ │ └── PointRenderEncoder │ │ │ │ ├── PointRendererEncoder.h │ │ │ │ └── PointRendererEncoder.metal │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ └── MetalPoint.xcodeproj │ │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── MeshFrameGlowing │ ├── MeshFrameGlowing │ ├── Assets.xcassets │ │ └── Contents.json │ ├── sjy.bin │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ ├── MetalEncoder │ │ │ ├── GaussianBlurEncoder │ │ │ │ ├── GaussianBlurEncoder.h │ │ │ │ └── GaussianBlurEncoder.m │ │ │ ├── ImageBlenderEncoder │ │ │ │ ├── ImageBlenderEncoder.h │ │ │ │ └── ImageBlenderEncoder.metal │ │ │ ├── TextureRendererEncoder │ │ │ │ ├── TextureRendererEncoder.h │ │ │ │ └── TextureRendererEncoder.metal │ │ │ ├── MeshDepthMaskEncoder │ │ │ │ ├── MeshDepthMaskEncoder.metal │ │ │ │ └── MeshDepthMaskEncoder.h │ │ │ └── LineRendererEncoder │ │ │ │ └── LineRendererEncoder.h │ │ └── MetalRenderer │ │ │ ├── FrameGlowingRenderer │ │ │ └── FrameGlowingRenderer.h │ │ │ └── FrameTestRenderer │ │ │ └── FrameTestRenderer.h │ ├── Utility │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── MeshFrameGlowing.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── MetalLinePrimitive ├── MetalLinePrimitive │ ├── Assets.xcassets │ │ └── Contents.json │ ├── AppDelegate.h │ ├── ViewController.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ └── MetalRenderer │ │ │ └── LineRenderer │ │ │ ├── LineRenderer.h │ │ │ └── line.metal │ ├── ViewController.m │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── MetalLinePrimitive.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── OffScreenRendering ├── OffScreenRendering │ ├── Assets.xcassets │ │ └── Contents.json │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Metal │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ ├── MetalContext.h │ │ │ └── MetalContext.mm │ │ ├── MetalEncoder │ │ │ ├── TextureRendererEncoder │ │ │ │ ├── TextureRendererEncoder.h │ │ │ │ └── TextureRendererEncoder.metal │ │ │ └── FrameRendererEncoder │ │ │ │ └── FrameRendererEncoder.h │ │ └── MetalRenderer │ │ │ └── FrameRenderer │ │ │ └── FrameRenderer.h │ ├── Utility │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard └── OffScreenRendering.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── TrueDepthStreaming ├── TrueDepthStreaming │ ├── Assets.xcassets │ │ └── Contents.json │ ├── AppDelegate.h │ ├── main.m │ ├── ViewController.h │ ├── Metal │ │ ├── MetalRenderer │ │ │ ├── VideoRenderer │ │ │ │ ├── VideoRenderer.h │ │ │ │ └── VideoRenderer.m │ │ │ └── DepthRenderer │ │ │ │ └── DepthRenderer.h │ │ ├── MetalView │ │ │ └── MetalView.h │ │ ├── MetalContext │ │ │ └── MetalContext.h │ │ └── MetalEncoder │ │ │ ├── DisparityToTextureEncoder │ │ │ ├── DisparityToTextureEncoder.h │ │ │ └── DisparityToTextureEncoder.metal │ │ │ └── TextureRendererEncoder │ │ │ ├── TextureRendererEncoder.h │ │ │ └── TextureRendererEncoder.metal │ ├── Utility │ │ ├── Device │ │ │ └── FrontCamera.h │ │ └── Math │ │ │ ├── OrbitControl.hpp │ │ │ └── MathUtilities.hpp │ ├── Info.plist │ └── Base.lproj │ │ └── LaunchScreen.storyboard └── TrueDepthStreaming.xcodeproj │ └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── HelloMetal ├── HelloMetal.xcodeproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── HelloMetal │ ├── AppDelegate.h │ ├── ViewController.h │ ├── main.m │ ├── Metal │ ├── MetalView │ │ └── MetalView.h │ ├── MetalContext │ │ ├── MetalContext.h │ │ └── MetalContext.mm │ └── MetalRenderer │ │ ├── LineRenderer │ │ ├── LineRenderer.h │ │ └── line.metal │ │ └── TriangleRenderer │ │ ├── TriangleRenderer.h │ │ └── triangle.metal │ ├── ViewController.m │ ├── Info.plist │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ └── Assets.xcassets │ └── AppIcon.appiconset │ └── Contents.json └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # Learn-Metal 2 | Learn-Metal 3 | 4 | # Basic Metal 5 | Search Metal by Example 6 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/sjy.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjy234sjy234/Learn-Metal/HEAD/MeshFrame/MeshFrame/sjy.bin -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MetalCube/MetalCube/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MetalLine/MetalLine/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/sjy.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sjy234sjy234/Learn-Metal/HEAD/others/MeshFrameGlowing/MeshFrameGlowing/sjy.bin -------------------------------------------------------------------------------- /MeshFrame/MeshFrame.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MetalCube/MetalCube.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MetalLine/MetalLine.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TextureRenderer 4 | // 5 | // Created by 沈江洋 on 2018/9/3. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/8. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ViewController : UIViewController 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MetalCube/MetalCube.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MetalLine/MetalLine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ViewController : UIViewController 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MeshFrame 4 | // 5 | // Created by 沈江洋 on 2018/8/29. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/27. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/17. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HelloMetal 4 | // 5 | // Created by 沈江洋 on 27/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OffScreenRendering 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface ViewController : UIViewController 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/8. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TextureRenderer 4 | // 5 | // Created by 沈江洋 on 2018/9/3. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface ViewController : UIViewController 14 | 15 | 16 | @end 17 | 18 | 19 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/27. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | #import "MetalView.h" 12 | #import "MeshRenderer.h" 13 | 14 | @interface ViewController : UIViewController 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | #import "MetalView.h" 12 | #import "LineRenderer.h" 13 | 14 | @interface ViewController : UIViewController 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | #import "MetalView.h" 12 | #import "PointRenderer.h" 13 | 14 | @interface ViewController : UIViewController 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | #import "MetalView.h" 12 | #import "TriangleRenderer.h" 13 | 14 | @interface ViewController : UIViewController 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MetalLinePrimitive 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OffScreenRendering 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MeshFrame 4 | // 5 | // Created by 沈江洋 on 2018/8/29. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/27. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/17. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalLinePrimitive 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | #import "MetalView.h" 12 | #import "LineRenderer.h" 13 | 14 | @interface ViewController : UIViewController 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HelloMetal 4 | // 5 | // Created by 沈江洋 on 27/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/8. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TextureRenderer 4 | // 5 | // Created by 沈江洋 on 2018/9/3. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/27. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "MetalContext.h" 13 | #import "MetalView.h" 14 | #import "FrameRenderer.h" 15 | 16 | @interface ViewController : UIViewController 17 | 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalLinePrimitive 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OffScreenRendering 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ViewController : UIViewController 13 | 14 | @property (weak, nonatomic) IBOutlet UIButton *startStreamButton; 15 | 16 | @property (weak, nonatomic) IBOutlet UIButton *stopStreamButton; 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalRenderer/VideoRenderer/VideoRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoRenderer.h 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | 12 | @interface VideoRenderer : NSObject 13 | 14 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 15 | - (void)render: (CVPixelBufferRef)videoPixelBuffer; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalView/MetalView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol MetalViewDelegate 4 | 5 | - (void)onTouchesBegan:(CGPoint) pos; 6 | 7 | - (void)onTouchesMoved: (CGPoint) offset; 8 | 9 | - (void)onPinch: (BOOL) isZoomOut; 10 | 11 | @end 12 | 13 | @interface MetalView : UIView 14 | 15 | @property (nonatomic, assign) id delegate; 16 | 17 | @property (nonatomic, readonly) CAMetalLayer *metalLayer; 18 | @property (nonatomic, readonly) UITouch *currentTouch; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Metal/MetalRenderer/LineRenderer/LineRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineRenderer.h 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface LineRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)draw; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalRenderer/LineRenderer/LineRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineRenderer.h 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface LineRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)draw; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Metal/MetalRenderer/PointRenderer/PointRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PointRenderer.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface PointRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)draw; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalRenderer/TriangleRenderer/TriangleRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // TriangleRenderer.h 3 | // HelloMetal 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface TriangleRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)draw; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Metal/MetalRenderer/LineRenderer/LineRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineRenderer.h 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface LineRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)draw; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalRenderer/VideoGaussianRenderer/VideoGaussianRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoGaussianRenderer.h 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | 12 | @interface VideoGaussianRenderer : NSObject 13 | 14 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context andSigma: (const float) sigma; 15 | - (void)render: (CVPixelBufferRef)videoPixelBuffer; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalRenderer/DepthRenderer/DepthRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // DepthRenderer.h 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | 12 | @interface DepthRenderer : NSObject 13 | 14 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 15 | //- (void)render: (CVPixelBufferRef)videoPixelBuffer; 16 | - (void)render: (CVPixelBufferRef)depthPixelBuffer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Metal/MetalRenderer/TextureRenderer/TextureRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextureRenderer.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 28/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | @interface TextureRenderer : NSObject 17 | 18 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 19 | - (void)draw: (id) inTexture; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalContext/MetalContext.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @protocol MTLDevice, MTLLibrary, MTLCommandQueue; 5 | 6 | @interface MetalContext : NSObject 7 | 8 | @property (strong) id device; 9 | @property (strong) id library; 10 | @property (strong) id commandQueue; 11 | 12 | +(instancetype)shareMetalContext; 13 | 14 | + (instancetype)newContext; 15 | 16 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer; 17 | 18 | - (id)bufferWithF16PixelBuffer:(CVPixelBufferRef)f16PixelBuffer; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Metal/MetalRenderer/MeshRenderer/MeshRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // MeshRenderer.h 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface MeshRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)drawMesh: (id)vertexBuffer withIndexBuffer: (id)indexBuffer withMvpMatrix: (id)mvpTransform; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalEncoder/DisparityToTextureEncoder/DisparityToTextureEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // DisparityToTextureEncoder.h 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MetalContext.h" 12 | 13 | @interface DisparityToTextureEncoder : NSObject 14 | 15 | - (instancetype)initWithContext: (MetalContext *)context; 16 | - (void)encodeToCommandBuffer: (id) commandBuffer inDisparityBuffer:(const id)inDisparityBuffer outTexture: (id) outTexture; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalEncoder/GaussianBlurEncoder/GaussianBlurEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // GaussianBlurEncoder.h 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MetalContext.h" 12 | 13 | @interface GaussianBlurEncoder : NSObject 14 | 15 | - (instancetype)initWithContext: (MetalContext *)context andSigma: (const float) sigma; 16 | - (void)encodeToCommandBuffer: (id) commandBuffer srcTexture: (id) srcTexture dstTexture: (id) dstTexture; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/GaussianBlurEncoder/GaussianBlurEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // GaussianBlurEncoder.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MetalContext.h" 12 | 13 | @interface GaussianBlurEncoder : NSObject 14 | 15 | - (instancetype)initWithContext: (MetalContext *)context andSigma: (const float) sigma; 16 | - (void)encodeToCommandBuffer: (id) commandBuffer srcTexture: (id) srcTexture dstTexture: (id) dstTexture; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextureRendererEncoder.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 28/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | @interface TextureRendererEncoder : NSObject 17 | 18 | - (instancetype)initWithContext: (MetalContext *)context; 19 | - (void)encodeToCommandBuffer: (id) commandBuffer sourceTexture: (id) inTexture destinationTexture: (id) outTexture; 20 | @end 21 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/ImageBlenderEncoder/ImageBlenderEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageBlenderEncoder.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MetalContext.h" 12 | 13 | @interface ImageBlenderEncoder : NSObject 14 | 15 | - (instancetype)initWithContext: (MetalContext *)context andAlpha: (const float) alpha; 16 | - (void)encodeToCommandBuffer: (id) commandBuffer firstTexture: (id) firstTexture secondTexture: (id) secondTexture dstTexture: (id) dstTexture; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Metal/MetalRenderer/LineRenderer/line.metal: -------------------------------------------------------------------------------- 1 | // 2 | // line.metal 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | float4 color; 16 | }; 17 | 18 | vertex Vertex line_vertex_main(device Vertex *vertices [[buffer(0)]], 19 | uint vid [[vertex_id]]) 20 | { 21 | Vertex outVertex = vertices[vid]; 22 | return outVertex; 23 | } 24 | 25 | fragment float4 line_fragment_main(Vertex inVertex [[stage_in]]) 26 | { 27 | return inVertex.color; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextureRendererEncoder.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 28/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | @interface TextureRendererEncoder : NSObject 17 | 18 | - (instancetype)initWithContext: (MetalContext *)context; 19 | - (void)encodeToCommandBuffer: (id) commandBuffer sourceTexture: (id) inTexture destinationTexture: (id) outTexture; 20 | @end 21 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextureRendererEncoder.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 28/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | @interface TextureRendererEncoder : NSObject 17 | 18 | - (instancetype)initWithContext: (MetalContext *)context; 19 | - (void)encodeToCommandBuffer: (id) commandBuffer sourceTexture: (id) inTexture destinationTexture: (id) outTexture; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TextureRendererEncoder.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 28/12/2017. 6 | // Copyright © 2017 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | @interface TextureRendererEncoder : NSObject 17 | 18 | - (instancetype)initWithContext: (MetalContext *)context; 19 | - (void)encodeToCommandBuffer: (id) commandBuffer sourceTexture: (id) inTexture destinationTexture: (id) outTexture; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalRenderer/LineRenderer/line.metal: -------------------------------------------------------------------------------- 1 | // 2 | // line.metal 3 | // MetalLine 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | float4 color; 16 | }; 17 | 18 | vertex Vertex line_vertex_main(device Vertex *vertices [[buffer(0)]], 19 | uint vid [[vertex_id]]) 20 | { 21 | Vertex outVertex; 22 | outVertex.position = vertices[vid].position; 23 | outVertex.color = vertices[vid].color; 24 | return outVertex; 25 | } 26 | 27 | fragment float4 line_fragment_main(Vertex inVertex [[stage_in]]) 28 | { 29 | return inVertex.color; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Metal/MetalRenderer/FrameRenderer/FrameRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrameRenderer.h 3 | // MeshFrame 4 | // 5 | // Created by 沈江洋 on 2018/8/29. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface FrameRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)setThickNess: (float) thickness; 19 | - (void)setupFrameWithVertex: (const float *) vertices andIndex: (const uint32_t *)indices andVertexNum: (int) vertexNum andFaceNum: (int) faceNum; 20 | - (void)drawWithMvpMatrix: (simd::float4x4)mvpTransform; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalRenderer/PointRenderer/PointRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // PointRenderer.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/9. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "MetalContext.h" 12 | 13 | @interface PointRenderer : NSObject 14 | 15 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 16 | - (void)setBackColor: (const simd::float4) color; 17 | - (void)setPointSize: (const float) size; 18 | - (void)setPointColor: (const simd::float4) color; 19 | - (void)renderPoints: (const float *) points 20 | pointNum: (const int) pNum 21 | mvpMatrix: (const simd::float4x4)mvpTransform; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalRenderer/TriangleRenderer/triangle.metal: -------------------------------------------------------------------------------- 1 | // 2 | // triangle.metal 3 | // HelloMetal 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | float4 color; 16 | }; 17 | 18 | vertex Vertex triangle_vertex_main(device Vertex *vertices [[buffer(0)]], 19 | uint vid [[vertex_id]]) 20 | { 21 | Vertex outVertex; 22 | outVertex.position = vertices[vid].position; 23 | outVertex.color = vertices[vid].color; 24 | return outVertex; 25 | } 26 | 27 | fragment float4 triangle_fragment_main(Vertex inVertex [[stage_in]]) 28 | { 29 | return inVertex.color; 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace metal; 4 | 5 | struct TextureVertex 6 | { 7 | float4 position [[position]]; 8 | float2 texCoords; 9 | }; 10 | 11 | vertex TextureVertex texture_vertex_main(constant TextureVertex *vertices [[buffer(0)]], 12 | uint vid [[vertex_id]]) 13 | { 14 | return vertices[vid]; 15 | } 16 | 17 | fragment float4 texture_fragment_main(TextureVertex vert [[stage_in]], 18 | texture2d videoTexture [[texture(0)]], 19 | sampler samplr [[sampler(0)]]) 20 | { 21 | float3 texColor = videoTexture.sample(samplr, vert.texCoords).rgb; 22 | float2 texCoords=vert.texCoords; 23 | return float4(texColor, 1); 24 | } 25 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace metal; 4 | 5 | struct TextureVertex 6 | { 7 | float4 position [[position]]; 8 | float2 texCoords; 9 | }; 10 | 11 | vertex TextureVertex texture_vertex_main(constant TextureVertex *vertices [[buffer(0)]], 12 | uint vid [[vertex_id]]) 13 | { 14 | return vertices[vid]; 15 | } 16 | 17 | fragment float4 texture_fragment_main(TextureVertex vert [[stage_in]], 18 | texture2d videoTexture [[texture(0)]], 19 | sampler samplr [[sampler(0)]]) 20 | { 21 | float3 texColor = videoTexture.sample(samplr, vert.texCoords).rgb; 22 | float2 texCoords=vert.texCoords; 23 | return float4(texColor, 1); 24 | } 25 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace metal; 4 | 5 | struct TextureVertex 6 | { 7 | float4 position [[position]]; 8 | float2 texCoords; 9 | }; 10 | 11 | vertex TextureVertex texture_vertex_main(constant TextureVertex *vertices [[buffer(0)]], 12 | uint vid [[vertex_id]]) 13 | { 14 | return vertices[vid]; 15 | } 16 | 17 | fragment float4 texture_fragment_main(TextureVertex vert [[stage_in]], 18 | texture2d videoTexture [[texture(0)]], 19 | sampler samplr [[sampler(0)]]) 20 | { 21 | float3 texColor = videoTexture.sample(samplr, vert.texCoords).rgb; 22 | float2 texCoords=vert.texCoords; 23 | return float4(texColor, 1); 24 | } 25 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Utility/Device/FrontCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrontCamera.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 22/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @protocol FrontCameraDelegate 13 | 14 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer andDepthBuffer: (CVPixelBufferRef) depthPixelBuffer ; 15 | 16 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer; 17 | 18 | @end 19 | 20 | @interface FrontCamera : NSObject 21 | 22 | @property (nonatomic, assign) id delegate; 23 | 24 | - (instancetype)initWithDepthTag: (BOOL) isEnabled; 25 | - (void)startCapture; 26 | - (void)stopCapture; 27 | - (void)setExposurePoint: (CGPoint) pos; 28 | - (void)getFrameWidth: (size_t *) width andFrameHeight: (size_t *)height; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Utility/Device/FrontCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrontCamera.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 22/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @protocol FrontCameraDelegate 13 | 14 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer andDepthBuffer: (CVPixelBufferRef) depthPixelBuffer ; 15 | 16 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer; 17 | 18 | @end 19 | 20 | @interface FrontCamera : NSObject 21 | 22 | @property (nonatomic, assign) id delegate; 23 | 24 | - (instancetype)initWithDepthTag: (BOOL) isEnabled; 25 | - (void)startCapture; 26 | - (void)stopCapture; 27 | - (void)setExposurePoint: (CGPoint) pos; 28 | - (void)getFrameWidth: (size_t *) width andFrameHeight: (size_t *)height; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Utility/Device/FrontCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrontCamera.h 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 22/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @protocol FrontCameraDelegate 13 | 14 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer andDepthBuffer: (CVPixelBufferRef) depthPixelBuffer ; 15 | 16 | - (void)didOutputVideoBuffer: (CVPixelBufferRef) videoPixelBuffer; 17 | 18 | @end 19 | 20 | @interface FrontCamera : NSObject 21 | 22 | @property (nonatomic, assign) id delegate; 23 | 24 | - (instancetype)initWithDepthTag: (BOOL) isEnabled; 25 | - (void)startCapture; 26 | - (void)stopCapture; 27 | - (void)setExposurePoint: (CGPoint) pos; 28 | - (void)getFrameWidth: (size_t *) width andFrameHeight: (size_t *)height; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalEncoder/DisparityToTextureEncoder/DisparityToTextureEncoder.metal: -------------------------------------------------------------------------------- 1 | // 2 | // DisparityToTextureEncoder.metal 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | // disparityToTexture compute kernel 13 | kernel void 14 | disparityToTexture(constant half* currentDisparityBuffer [[buffer(0)]], 15 | texture2d outTexture [[texture(0)]], 16 | uint2 gid [[thread_position_in_grid]], 17 | uint2 tspg [[threads_per_grid]]) 18 | { 19 | uint invid = gid.y * tspg.x + gid.x; 20 | half inDisparity = currentDisparityBuffer[invid]; 21 | half inDepth = 1.0 / inDisparity; 22 | float4 outColor = {inDepth, inDepth, inDepth, inDepth}; 23 | outTexture.write(outColor, gid); 24 | } 25 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalEncoder/FrameRendererEncoder/FrameRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrameRendererEncoder.h 3 | // MeshFrame 4 | // 5 | // Created by 沈江洋 on 2018/8/29. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface FrameRendererEncoder : NSObject 16 | 17 | - (instancetype)initWithContext: (MetalContext *)context; 18 | - (void)setThickNess: (const float) thickness; 19 | - (void)setupFrameWithVertex: (const float *) vertices andIndex: (const uint32_t *)indices andVertexNum: (int) vertexNum andFaceNum: (int) faceNum; 20 | - (void)encodeToCommandBuffer: (id) commandBuffer dstColorTexture: (id) colorTexture dstDepthTexture: (id) depthTexture mvpMatrix: (const simd::float4x4)mvpTransform; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Metal/MetalRenderer/PointRenderer/point.metal: -------------------------------------------------------------------------------- 1 | // 2 | // point.metal 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | float4 color; 16 | }; 17 | 18 | struct PVertex{ 19 | float4 position [[position]]; 20 | float4 color; 21 | float size[[point_size]]; 22 | }; 23 | 24 | vertex PVertex point_vertex_main(device Vertex *vertices [[buffer(0)]], 25 | uint vid [[vertex_id]]) 26 | { 27 | PVertex outVertex; 28 | outVertex.position = vertices[vid].position; 29 | outVertex.color = vertices[vid].color; 30 | outVertex.size = 30; 31 | 32 | return outVertex; 33 | } 34 | 35 | fragment float4 point_fragment_main(PVertex inVertex [[stage_in]]) 36 | { 37 | return inVertex.color; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Metal/MetalRenderer/MeshRenderer/mesh.metal: -------------------------------------------------------------------------------- 1 | // 2 | // mesh.metal 3 | // MetalCube 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | float4 color; 16 | }; 17 | 18 | struct MvpTransform 19 | { 20 | float4x4 matrix; 21 | }; 22 | 23 | vertex Vertex mesh_vertex_main(device Vertex *vertices [[buffer(0)]], 24 | constant MvpTransform *mvpTransform [[buffer(1)]], 25 | uint vid [[vertex_id]]) 26 | { 27 | Vertex vertexOut; 28 | vertexOut.position = mvpTransform->matrix * vertices[vid].position; 29 | vertexOut.color = vertices[vid].color; 30 | 31 | return vertexOut; 32 | } 33 | 34 | fragment float4 mesh_fragment_main(Vertex vertexIn [[stage_in]]) 35 | { 36 | return float4(vertexIn.color); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalRenderer/FrameRenderer/FrameRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrameRenderer.h 3 | // OffScreenRendering 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import "MetalContext.h" 14 | 15 | @interface FrameRenderer : NSObject 16 | 17 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context; 18 | - (void)setThickNess: (const float) thickness; 19 | - (void)setupFrameWithVertex: (const float *) vertices andIndex: (const uint32_t *)indices andVertexNum: (const int) vertexNum andFaceNum: (const int) faceNum; 20 | - (void)encodeToCommandBuffer: (id) commandBuffer dstColorTexture: (id) colorTexture dstDepthTexture: (id) depthTexture mvpMatrix: (simd::float4x4)mvpTransform; 21 | - (void)renderWithMvpMatrix: (const simd::float4x4)mvpTransform; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/MeshDepthMaskEncoder/MeshDepthMaskEncoder.metal: -------------------------------------------------------------------------------- 1 | // 2 | // MeshDepthMaskEncoder.metal 3 | // MeshFrameGlowing 4 | // 5 | // Created by 美戴科技 on 2018/10/10. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct Vertex 13 | { 14 | float4 position [[position]]; 15 | }; 16 | 17 | struct InputFloat3 18 | { 19 | float x; 20 | float y; 21 | float z; 22 | }; 23 | 24 | vertex Vertex meshDepthMaskEncoder_vertex_main(constant InputFloat3 *vertices [[buffer(0)]], 25 | constant float4x4 &mvpTransform [[buffer(1)]], 26 | uint vid [[vertex_id]]) 27 | { 28 | Vertex vertexOut; 29 | vertexOut.position = mvpTransform * float4(vertices[vid].x, vertices[vid].y, vertices[vid].z, 1.0); 30 | return vertexOut; 31 | } 32 | 33 | fragment half4 meshDepthMaskEncoder_fragment_main(Vertex vertexIn [[stage_in]]) 34 | { 35 | return {1.0,1.0,1.0,0.0}; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/ImageBlenderEncoder/ImageBlenderEncoder.metal: -------------------------------------------------------------------------------- 1 | // 2 | // ImageBlenderEncoder.metal 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct BlendAlpha 13 | { 14 | float val; 15 | }; 16 | 17 | // imageBlender compute kernel 18 | kernel void 19 | imageBlender(texture2d firstTexture [[texture(0)]], 20 | texture2d secondTexture [[texture(1)]], 21 | texture2d dstTexture [[texture(2)]], 22 | constant BlendAlpha* blendAlpha [[buffer(0)]], 23 | uint2 gid [[thread_position_in_grid]], 24 | uint2 tspg [[threads_per_grid]]) 25 | { 26 | float4 firstColor = firstTexture.read(gid); 27 | float4 secondColor = secondTexture.read(gid); 28 | float4 outColor = firstColor * blendAlpha->val + secondColor * (1.0 - blendAlpha->val); 29 | dstTexture.write(outColor, gid); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Metal/MetalRenderer/TextureRenderer/TextureRenderer.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace metal; 4 | 5 | struct TextureVertex 6 | { 7 | float4 position [[position]]; 8 | float2 texCoords; 9 | }; 10 | 11 | struct InputFloat3 12 | { 13 | float x; 14 | float y; 15 | float z; 16 | }; 17 | 18 | vertex TextureVertex texture_vertex_main(constant InputFloat3 *inVertex [[buffer(0)]], 19 | uint vid [[vertex_id]]) 20 | { 21 | TextureVertex vert; 22 | vert.position = float4(inVertex[vid].x, inVertex[vid].y, inVertex[vid].z, 1.0); 23 | vert.texCoords = float2(0.5 + inVertex[vid].x / 2.0, 0.5 - inVertex[vid].y / 2.0); 24 | return vert; 25 | } 26 | 27 | fragment half4 texture_fragment_main(TextureVertex vert [[stage_in]], 28 | texture2d videoTexture [[texture(0)]], 29 | sampler samplr [[sampler(0)]]) 30 | { 31 | float3 texColor = videoTexture.sample(samplr, vert.texCoords).rgb; 32 | float2 texCoords=vert.texCoords; 33 | return half4((half3)texColor, 1); 34 | } 35 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/TextureRendererEncoder/TextureRendererEncoder.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace metal; 4 | 5 | struct TextureVertex 6 | { 7 | float4 position [[position]]; 8 | float2 texCoords; 9 | }; 10 | 11 | struct InputFloat3 12 | { 13 | float x; 14 | float y; 15 | float z; 16 | }; 17 | 18 | vertex TextureVertex texture_vertex_main(constant InputFloat3 *inVertex [[buffer(0)]], 19 | uint vid [[vertex_id]]) 20 | { 21 | TextureVertex vert; 22 | vert.position = float4(inVertex[vid].x, inVertex[vid].y, inVertex[vid].z, 1.0); 23 | vert.texCoords = float2(0.5 + inVertex[vid].x / 2.0, 0.5 - inVertex[vid].y / 2.0); 24 | return vert; 25 | } 26 | 27 | fragment half4 texture_fragment_main(TextureVertex vert [[stage_in]], 28 | texture2d videoTexture [[texture(0)]], 29 | sampler samplr [[sampler(0)]]) 30 | { 31 | float3 texColor = videoTexture.sample(samplr, vert.texCoords).rgb; 32 | float2 texCoords=vert.texCoords; 33 | return half4((half3)texColor, 1); 34 | } 35 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalEncoder/PointRenderEncoder/PointRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // PointRendererEncoder.h 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/8. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "MetalContext.h" 13 | 14 | @interface PointRendererEncoder : NSObject 15 | 16 | - (instancetype)initWithContext: (MetalContext *)context; 17 | - (void)setClearColor:(const MTLClearColor) color; 18 | - (void)setClearDepth:(const double) depth; 19 | - (void)setPointSize: (const float) size; 20 | - (void)setPointColor: (const simd::float4) color; 21 | - (void)encodeToCommandBuffer: (const id) commandBuffer 22 | outColor: (const id) colorTexture 23 | outDepth: (const id) depthTexture 24 | clearColor: (const BOOL) isClearColor 25 | clearDepth: (const BOOL) isClearDepth 26 | pointBuffer: (const id) pointBuffer 27 | mvpMatrix: (const simd::float4x4)mvpTransform; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/MeshDepthMaskEncoder/MeshDepthMaskEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // MeshDepthMaskEncoder.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 美戴科技 on 2018/10/10. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @interface MeshDepthMaskEncoder : NSObject 19 | 20 | - (instancetype)initWithContext: (MetalContext *)context; 21 | - (void)setClearColor:(const MTLClearColor) color; 22 | - (void)setClearDepth:(const double) depth; 23 | - (void)encodeToCommandBuffer: (const id) commandBuffer 24 | dstColorTexture: (const id) colorTexture 25 | dstDepthTexture: (const id) depthTexture 26 | clearColor: (const BOOL) isClearColor 27 | clearDepth: (const BOOL) isClearDepth 28 | pointBuffer: (const id) pointBuffer 29 | indexBuffer: (const id) indexBuffer 30 | mvpMatrix: (simd::float4x4)mvpTransform; 31 | 32 | @end 33 | 34 | NS_ASSUME_NONNULL_END 35 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalRenderer/FrameGlowingRenderer/FrameGlowingRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrameGlowingRenderer.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | 12 | @interface FrameGlowingRenderer : NSObject 13 | 14 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context andBlurSigma: (const float) sigma andBlendAlpha: (const float) alpha; 15 | - (void)setThickNess: (const float) thickness; 16 | - (void)setBackColor: (const simd::float4) color; 17 | - (void)setLineColor: (const simd::float4) color; 18 | - (void)setupFrameWithVertex: (const float *) vertices 19 | andIndex: (const uint32_t *)indices 20 | andVertexNum: (const int) vertexNum 21 | andFaceNum: (const int) faceNum; 22 | - (void)setupFrameWithQuadrangleVertex: (const float *) vertices 23 | andIndex: (const uint32_t *)indices 24 | andVertexNum: (const int) vertexNum 25 | andFaceNum: (const int) faceNum; 26 | - (void)renderWithMvpMatrix: (const simd::float4x4)mvpTransform; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/LineRendererEncoder/LineRendererEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineRendererEncoder.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 美戴科技 on 2018/10/10. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | #import "MetalContext.h" 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @interface LineRendererEncoder : NSObject 19 | 20 | - (instancetype)initWithContext: (MetalContext *)context; 21 | - (void)setClearColor:(const MTLClearColor) color; 22 | - (void)setClearDepth:(const double) depth; 23 | - (void)setThickNess: (float) thickness; 24 | - (void)setLineColor: (const simd::float4) color; 25 | - (void)encodeToCommandBuffer: (id) commandBuffer 26 | dstColorTexture: (id) colorTexture 27 | dstDepthTexture: (id) depthTexture 28 | clearColor: (const BOOL) isClearColor 29 | clearDepth: (const BOOL) isClearDepth 30 | pointBuffer: (const id) pointBuffer 31 | indexBuffer: (const id) indexBuffer 32 | mvpMatrix: (simd::float4x4)mvpTransform; 33 | 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Utility/Math/OrbitControl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // OrbitControl.hpp 3 | // Learn-Metal 4 | // 5 | // Created by 沈江洋 on 25/01/2018. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #ifndef OrbitControl_hpp 10 | #define OrbitControl_hpp 11 | 12 | #include 13 | #include 14 | #include "MathUtilities.hpp" 15 | 16 | using namespace simd; 17 | 18 | //left-hand coordinates, suppose camera moving 19 | class OrbitControl 20 | { 21 | 22 | public: 23 | OrbitControl(); 24 | void init(float3 target, float3 camera); 25 | void reset(); 26 | void rotateLeft(); 27 | void rotateRight(); 28 | void rotateUp(); 29 | void rotateDown(); 30 | void zoomIn(); 31 | void zoomOut(); 32 | void toLeftNearest(); 33 | void toRightNearest(); 34 | float4x4 getTransform(); 35 | 36 | private: 37 | float m_pitch; 38 | float m_pitchVelocity; 39 | float2 m_pitchRange; 40 | 41 | float m_yaw; 42 | float m_yawVelocity; 43 | float2 m_yawRange; 44 | 45 | float m_dist; 46 | float m_distVelocity; 47 | float2 m_distRange; 48 | 49 | float3 m_target; 50 | float3 m_camera; 51 | float3 m_perDistTranslate; 52 | float4x4 m_preTranslate; 53 | float4x4 m_aftTranslate; 54 | 55 | bool m_isInitted; 56 | }; 57 | 58 | #endif /* OrbitControl_hpp */ 59 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | /// Builds a translation matrix that translates by the supplied vector 6 | float4x4 matrix_float4x4_translation(const float3 &t); 7 | 8 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 9 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 10 | 11 | /// Builds a rotation matrix that rotates about the supplied axis by an 12 | /// angle (given in radians). The axis should be normalized. 13 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 14 | 15 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 16 | 17 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 18 | 19 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 20 | /// vertical field of view (in radians), and near and far distances 21 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 22 | 23 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 24 | 25 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 26 | 27 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 28 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalRenderer/FrameTestRenderer/FrameTestRenderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // FrameTestRenderer.h 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MetalContext.h" 11 | 12 | @interface FrameTestRenderer : NSObject 13 | 14 | - (instancetype)initWithLayer1:(CAMetalLayer *)layer1 15 | andLayer2:(CAMetalLayer *)layer2 16 | andLayer3:(CAMetalLayer *)layer3 17 | andContext: (MetalContext *)context 18 | andBlurSigma: (const float) sigma 19 | andBlendAlpha: (const float) alpha; 20 | - (void)setThickNess: (const float) thickness; 21 | - (void)setBackColor: (const simd::float4) color; 22 | - (void)setLineColor: (const simd::float4) color; 23 | - (void)setupFrameWithVertex: (const float *) vertices andIndex: (const uint32_t *)indices andVertexNum: (const int) vertexNum andFaceNum: (const int) faceNum; 24 | - (void)setupFrameWithQuadrangleVertex: (const float *) vertices 25 | andIndex: (const uint32_t *)indices 26 | andVertexNum: (const int) vertexNum 27 | andFaceNum: (const int) faceNum; 28 | - (void)renderWithMvpMatrix: (const simd::float4x4)mvpTransform; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | /// Builds a translation matrix that translates by the supplied vector 6 | float4x4 matrix_float4x4_translation(const float3 &t); 7 | 8 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 9 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 10 | 11 | /// Builds a rotation matrix that rotates about the supplied axis by an 12 | /// angle (given in radians). The axis should be normalized. 13 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 14 | 15 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 16 | 17 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 18 | 19 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 20 | /// vertical field of view (in radians), and near and far distances 21 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 22 | 23 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 24 | 25 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 26 | 27 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 28 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | typedef struct 6 | { 7 | float4 position; 8 | float2 texCoords; 9 | } TextureVertex; 10 | 11 | /// Builds a translation matrix that translates by the supplied vector 12 | float4x4 matrix_float4x4_translation(const float3 &t); 13 | 14 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 15 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 16 | 17 | /// Builds a rotation matrix that rotates about the supplied axis by an 18 | /// angle (given in radians). The axis should be normalized. 19 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 20 | 21 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 22 | 23 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 24 | 25 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 26 | /// vertical field of view (in radians), and near and far distances 27 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 28 | 29 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 30 | 31 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 32 | 33 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 34 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | typedef struct 6 | { 7 | float4 position; 8 | float2 texCoords; 9 | } TextureVertex; 10 | 11 | /// Builds a translation matrix that translates by the supplied vector 12 | float4x4 matrix_float4x4_translation(const float3 &t); 13 | 14 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 15 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 16 | 17 | /// Builds a rotation matrix that rotates about the supplied axis by an 18 | /// angle (given in radians). The axis should be normalized. 19 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 20 | 21 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 22 | 23 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 24 | 25 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 26 | /// vertical field of view (in radians), and near and far distances 27 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 28 | 29 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 30 | 31 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 32 | 33 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 34 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | typedef struct 6 | { 7 | float4 position; 8 | float2 texCoords; 9 | } TextureVertex; 10 | 11 | /// Builds a translation matrix that translates by the supplied vector 12 | float4x4 matrix_float4x4_translation(const float3 &t); 13 | 14 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 15 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 16 | 17 | /// Builds a rotation matrix that rotates about the supplied axis by an 18 | /// angle (given in radians). The axis should be normalized. 19 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 20 | 21 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 22 | 23 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 24 | 25 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 26 | /// vertical field of view (in radians), and near and far distances 27 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 28 | 29 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 30 | 31 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 32 | 33 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 34 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | typedef struct 6 | { 7 | float4 position; 8 | float2 texCoords; 9 | } TextureVertex; 10 | 11 | /// Builds a translation matrix that translates by the supplied vector 12 | float4x4 matrix_float4x4_translation(const float3 &t); 13 | 14 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 15 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 16 | 17 | /// Builds a rotation matrix that rotates about the supplied axis by an 18 | /// angle (given in radians). The axis should be normalized. 19 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 20 | 21 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 22 | 23 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 24 | 25 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 26 | /// vertical field of view (in radians), and near and far distances 27 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 28 | 29 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 30 | 31 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 32 | 33 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 34 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Utility/Math/MathUtilities.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace simd; 4 | 5 | typedef struct 6 | { 7 | float4 position; 8 | float2 texCoords; 9 | } TextureVertex; 10 | 11 | /// Builds a translation matrix that translates by the supplied vector 12 | float4x4 matrix_float4x4_translation(const float3 &t); 13 | 14 | /// Builds a scale matrix that uniformly scales all axes by the supplied factor 15 | float4x4 matrix_float4x4_uniform_scale(const float &scale); 16 | 17 | /// Builds a rotation matrix that rotates about the supplied axis by an 18 | /// angle (given in radians). The axis should be normalized. 19 | float4x4 matrix_float4x4_rotation(const float3 &axis, const float &angle); 20 | 21 | float3x3 matrix_float3x3_rotation(const float3 &axis, const float &angle); 22 | 23 | float3x3 matrix_float3x3_rotation(const float &rotatex, const float &rotatey, const float &rotatez); 24 | 25 | /// Builds a symmetric perspective projection matrix with the supplied aspect ratio, 26 | /// vertical field of view (in radians), and near and far distances 27 | float4x4 matrix_float4x4_perspective(const float &aspect, const float & fovy, const float & near, const float & far); 28 | 29 | void matrix_transform_extract(const float4x4 &transform, float3x3 &rotate, float3 &translate); 30 | 31 | void matrix_transform_compose(float4x4 &transform, const float3x3 &rotate, const float3 &translate); 32 | 33 | void matrix_eulerian_angle(const float4x4 &rotateM, float3 &rotateV); 34 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalEncoder/GaussianBlurEncoder/GaussianBlurEncoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // GaussianBlurEncoder.m 3 | // MeshFrameGlowing 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "GaussianBlurEncoder.h" 10 | 11 | @interface GaussianBlurEncoder () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | @property (nonatomic, strong) MPSUnaryImageKernel *gaussianBlurKernel; 15 | 16 | @end 17 | 18 | @implementation GaussianBlurEncoder 19 | 20 | - (instancetype)initWithContext: (MetalContext *)context andSigma: (const float) sigma 21 | { 22 | if ((self = [super init])) 23 | { 24 | _metalContext=context; 25 | self.gaussianBlurKernel = [[MPSImageGaussianBlur alloc] initWithDevice: _metalContext.device sigma: sigma]; 26 | [self.gaussianBlurKernel setEdgeMode: MPSImageEdgeModeClamp]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)encodeToCommandBuffer: (id) commandBuffer srcTexture: (id) srcTexture dstTexture: (id) dstTexture 32 | { 33 | if(!commandBuffer) 34 | { 35 | NSLog(@"invalid commandBuffer"); 36 | return ; 37 | } 38 | if(!srcTexture || !dstTexture) 39 | { 40 | NSLog(@"invalid texture"); 41 | return ; 42 | } 43 | 44 | [_gaussianBlurKernel encodeToCommandBuffer: commandBuffer sourceTexture: srcTexture destinationTexture: dstTexture]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | 15 | @property (nonatomic) MetalView *myMetalView; 16 | 17 | @property (nonatomic) LineRenderer *lineRenderer; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | self.metalContext = [MetalContext shareMetalContext]; 27 | 28 | self.myMetalView=[[MetalView alloc] init]; 29 | self.myMetalView.frame=CGRectMake(10, 150, 300, 300); 30 | self.myMetalView.backgroundColor = [UIColor grayColor]; 31 | self.myMetalView.delegate = self; 32 | [self.view addSubview:self.myMetalView]; 33 | 34 | self.lineRenderer = [[LineRenderer alloc] initWithLayer: self.myMetalView.metalLayer andContext: _metalContext]; 35 | [self.lineRenderer draw]; 36 | 37 | // Do any additional setup after loading the view, typically from a nib. 38 | } 39 | 40 | //MetalViewDelegate 41 | - (void)onPinch:(BOOL)isZoomOut 42 | { 43 | if(isZoomOut) 44 | { 45 | NSLog(@"zoom out"); 46 | } 47 | else 48 | { 49 | NSLog(@"zoom in"); 50 | } 51 | } 52 | 53 | - (void)didReceiveMemoryWarning { 54 | [super didReceiveMemoryWarning]; 55 | // Dispose of any resources that can be recreated. 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | 15 | @property (nonatomic) MetalView *myMetalView; 16 | 17 | @property (nonatomic) PointRenderer *pointRenderer; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | self.metalContext = [MetalContext shareMetalContext]; 27 | 28 | self.myMetalView=[[MetalView alloc] init]; 29 | self.myMetalView.frame=CGRectMake(10, 150, 300, 300); 30 | self.myMetalView.backgroundColor = [UIColor grayColor]; 31 | self.myMetalView.delegate = self; 32 | [self.view addSubview:self.myMetalView]; 33 | 34 | self.pointRenderer = [[PointRenderer alloc] initWithLayer: self.myMetalView.metalLayer andContext: _metalContext]; 35 | [self.pointRenderer draw]; 36 | 37 | // Do any additional setup after loading the view, typically from a nib. 38 | } 39 | 40 | //MetalViewDelegate 41 | - (void)onPinch:(BOOL)isZoomOut 42 | { 43 | if(isZoomOut) 44 | { 45 | NSLog(@"zoom out"); 46 | } 47 | else 48 | { 49 | NSLog(@"zoom in"); 50 | } 51 | } 52 | 53 | - (void)didReceiveMemoryWarning { 54 | [super didReceiveMemoryWarning]; 55 | // Dispose of any resources that can be recreated. 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/8/18. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | 15 | @property (nonatomic) MetalView *myMetalView; 16 | 17 | @property (nonatomic) TriangleRenderer *triangleRenderer; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | self.metalContext = [MetalContext shareMetalContext]; 27 | 28 | self.myMetalView=[[MetalView alloc] init]; 29 | self.myMetalView.frame=CGRectMake(10, 150, 300, 300); 30 | self.myMetalView.backgroundColor = [UIColor grayColor]; 31 | self.myMetalView.delegate = self; 32 | [self.view addSubview:self.myMetalView]; 33 | 34 | self.triangleRenderer = [[TriangleRenderer alloc] initWithLayer: self.myMetalView.metalLayer andContext: _metalContext]; 35 | [self.triangleRenderer draw]; 36 | 37 | // Do any additional setup after loading the view, typically from a nib. 38 | } 39 | 40 | //MetalViewDelegate 41 | - (void)onPinch:(BOOL)isZoomOut 42 | { 43 | if(isZoomOut) 44 | { 45 | NSLog(@"zoom out"); 46 | } 47 | else 48 | { 49 | NSLog(@"zoom in"); 50 | } 51 | } 52 | 53 | - (void)didReceiveMemoryWarning { 54 | [super didReceiveMemoryWarning]; 55 | // Dispose of any resources that can be recreated. 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // MetalLinePrimitive 4 | // 5 | // Created by 沈江洋 on 2018/8/28. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | 15 | @property (nonatomic) MetalView *myMetalView; 16 | 17 | @property (nonatomic) LineRenderer *lineRenderer; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | self.metalContext = [MetalContext shareMetalContext]; 27 | 28 | self.myMetalView=[[MetalView alloc] init]; 29 | self.myMetalView.frame=CGRectMake(10, 150, 300, 300); 30 | self.myMetalView.backgroundColor = [UIColor grayColor]; 31 | self.myMetalView.delegate = self; 32 | [self.view addSubview:self.myMetalView]; 33 | 34 | self.lineRenderer = [[LineRenderer alloc] initWithLayer: self.myMetalView.metalLayer andContext: _metalContext]; 35 | [self.lineRenderer draw]; 36 | 37 | // Do any additional setup after loading the view, typically from a nib. 38 | } 39 | 40 | //MetalViewDelegate 41 | - (void)onPinch:(BOOL)isZoomOut 42 | { 43 | if(isZoomOut) 44 | { 45 | NSLog(@"zoom out"); 46 | } 47 | else 48 | { 49 | NSLog(@"zoom in"); 50 | } 51 | } 52 | 53 | - (void)didReceiveMemoryWarning { 54 | [super didReceiveMemoryWarning]; 55 | // Dispose of any resources that can be recreated. 56 | } 57 | 58 | @end 59 | 60 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalEncoder/PointRenderEncoder/PointRendererEncoder.metal: -------------------------------------------------------------------------------- 1 | // 2 | // PointRendererEncoder.metal 3 | // MetalPoint 4 | // 5 | // Created by 沈江洋 on 2018/9/8. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | #include 13 | using namespace metal; 14 | 15 | struct Vertex{ 16 | float4 position [[position]]; 17 | float size[[point_size]]; 18 | half4 color; 19 | }; 20 | 21 | struct InputFloat3 22 | { 23 | float x; 24 | float y; 25 | float z; 26 | }; 27 | 28 | struct PointSize 29 | { 30 | float val; 31 | }; 32 | 33 | struct PointColor 34 | { 35 | float4 val; 36 | }; 37 | 38 | struct MvpTransform 39 | { 40 | float4x4 val; 41 | }; 42 | 43 | vertex Vertex pointRenderer_vertex_main(constant InputFloat3 *vertices [[buffer(0)]], 44 | constant PointSize *pointSize [[buffer(1)]], 45 | constant PointColor *pointColor [[buffer(2)]], 46 | constant MvpTransform *mvpTransform [[buffer(3)]], 47 | uint vid [[vertex_id]]) 48 | { 49 | Vertex outVertex; 50 | outVertex.position = mvpTransform->val * float4(vertices[vid].x, vertices[vid].y, vertices[vid].z, 1.0); 51 | outVertex.size = pointSize->val; 52 | outVertex.color = (half4)(pointColor->val); 53 | return outVertex; 54 | } 55 | 56 | fragment half4 pointRenderer_fragment_main(Vertex inVertex [[stage_in]]) 57 | { 58 | return inVertex.color; 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalEncoder/GaussianBlurEncoder/GaussianBlurEncoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // GaussianBlurEncoder.m 3 | // GaussianBlurMPS 4 | // 5 | // Created by 沈江洋 on 2018/9/5. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "GaussianBlurEncoder.h" 10 | 11 | @interface GaussianBlurEncoder () 12 | 13 | @property (nonatomic, strong) MetalContext *metalContext; 14 | @property (nonatomic, strong) MPSUnaryImageKernel *gaussianBlurKernel; 15 | 16 | @end 17 | 18 | @implementation GaussianBlurEncoder 19 | 20 | - (instancetype)initWithContext: (MetalContext *)context andSigma: (const float) sigma 21 | { 22 | if ((self = [super init])) 23 | { 24 | _metalContext=context; 25 | self.gaussianBlurKernel = [[MPSImageGaussianBlur alloc] initWithDevice: _metalContext.device sigma: sigma]; 26 | [self.gaussianBlurKernel setEdgeMode: MPSImageEdgeModeClamp]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)encodeToCommandBuffer: (id) commandBuffer srcTexture: (id) srcTexture dstTexture: (id) dstTexture 32 | { 33 | if(!commandBuffer) 34 | { 35 | NSLog(@"invalid commandBuffer"); 36 | return ; 37 | } 38 | if(!srcTexture || !dstTexture) 39 | { 40 | NSLog(@"invalid texture"); 41 | return ; 42 | } 43 | if(srcTexture.width != dstTexture.width || srcTexture.height != dstTexture.height) 44 | { 45 | NSLog(@"invalid size for blending"); 46 | return ; 47 | } 48 | 49 | [_gaussianBlurKernel encodeToCommandBuffer: commandBuffer sourceTexture: srcTexture destinationTexture: dstTexture]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSCameraUsageDescription 6 | camera request 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSCameraUsageDescription 6 | camera request 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIFileSharingEnabled 6 | 7 | NSCameraUsageDescription 8 | camera request 9 | CFBundleDevelopmentRegion 10 | $(DEVELOPMENT_LANGUAGE) 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SELF DEFINED 2 | *.DS_Store 3 | 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | DerivedData/ 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | # Pods/ 41 | # 42 | # Add this line if you want to avoid checking in source code from the Xcode workspace 43 | # *.xcworkspace 44 | 45 | # Carthage 46 | # 47 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 48 | # Carthage/Checkouts 49 | 50 | Carthage/Build 51 | 52 | # fastlane 53 | # 54 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 55 | # screenshots whenever they are needed. 56 | # For more information about the recommended setup visit: 57 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 58 | 59 | fastlane/report.xml 60 | fastlane/Preview.html 61 | fastlane/screenshots/**/*.png 62 | fastlane/test_output 63 | 64 | # Code Injection 65 | # 66 | # After new code Injection tools there's a generated folder /iOSInjectionProject 67 | # https://github.com/johnno1962/injectionforxcode 68 | 69 | iOSInjectionProject/ 70 | 71 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MetalCube/MetalCube/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MetalLine/MetalLine/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /TextureRenderer/TextureRenderer/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MetalLinePrimitive/MetalLinePrimitive/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /OffScreenRendering/OffScreenRendering/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /others/MeshFrameGlowing/MeshFrameGlowing/Metal/MetalContext/MetalContext.mm: -------------------------------------------------------------------------------- 1 | #import "MetalContext.h" 2 | #import 3 | 4 | @implementation MetalContext 5 | 6 | static MetalContext *_instance; 7 | +(instancetype)shareMetalContext 8 | { 9 | static dispatch_once_t onceToken; 10 | dispatch_once(&onceToken, ^{ 11 | if (_instance == nil) { 12 | _instance = [[self alloc] initWithDevice:nil]; 13 | } 14 | }); 15 | return _instance; 16 | } 17 | 18 | + (instancetype)newContext 19 | { 20 | return [[self alloc] initWithDevice:nil]; 21 | } 22 | 23 | - (instancetype)initWithDevice:(id)device 24 | { 25 | if ((self = [super init])) 26 | { 27 | _device = device ?: MTLCreateSystemDefaultDevice(); 28 | _library = [_device newDefaultLibrary]; 29 | _commandQueue = [_device newCommandQueue]; 30 | } 31 | return self; 32 | } 33 | 34 | - (id) textureFromPixelBuffer:(CVPixelBufferRef)videoPixelBuffer 35 | { 36 | id texture = nil; 37 | { 38 | size_t width = CVPixelBufferGetWidth(videoPixelBuffer); 39 | size_t height = CVPixelBufferGetHeight(videoPixelBuffer); 40 | MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm; 41 | CVMetalTextureCacheRef textureCache; 42 | CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, _device, nil, &textureCache); 43 | CVMetalTextureRef metalTextureRef = NULL; 44 | CVReturn status = CVMetalTextureCacheCreateTextureFromImage(NULL, textureCache, videoPixelBuffer, NULL, pixelFormat, width, height, 0, &metalTextureRef); 45 | if(status == kCVReturnSuccess) 46 | { 47 | texture = CVMetalTextureGetTexture(metalTextureRef); 48 | CFRelease(metalTextureRef); 49 | CFRelease(textureCache); 50 | } 51 | } 52 | return texture; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /TrueDepthStreaming/TrueDepthStreaming/Metal/MetalRenderer/VideoRenderer/VideoRenderer.m: -------------------------------------------------------------------------------- 1 | // 2 | // VideoRenderer.m 3 | // TrueDepthStreaming 4 | // 5 | // Created by 沈江洋 on 2018/9/6. 6 | // Copyright © 2018 沈江洋. All rights reserved. 7 | // 8 | 9 | #import "VideoRenderer.h" 10 | #import "TextureRendererEncoder.h" 11 | 12 | @interface VideoRenderer () 13 | 14 | @property (nonatomic, strong) CAMetalLayer *layer; 15 | @property (nonatomic, strong) MetalContext *metalContext; 16 | @property (nonatomic, strong) TextureRendererEncoder *textureRendererEncoder; 17 | 18 | @end 19 | 20 | @implementation VideoRenderer 21 | 22 | - (instancetype)initWithLayer:(CAMetalLayer *)layer andContext: (MetalContext *)context 23 | { 24 | if ((self = [super init])) 25 | { 26 | _layer = layer; 27 | _metalContext=context; 28 | self.textureRendererEncoder = [[TextureRendererEncoder alloc] initWithContext: _metalContext]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)render: (CVPixelBufferRef)videoPixelBuffer 34 | { 35 | if(!videoPixelBuffer) 36 | { 37 | NSLog(@"invalid pixel buffer"); 38 | return; 39 | } 40 | 41 | id inTexture = [_metalContext textureFromPixelBuffer: videoPixelBuffer]; 42 | id drawable = [_layer nextDrawable]; 43 | if(drawable) 44 | { 45 | //new commander buffer 46 | id commandBuffer = [_metalContext.commandQueue commandBuffer]; 47 | commandBuffer.label = @"VideoRendererCommand"; 48 | 49 | //encode drawable render process 50 | [_textureRendererEncoder encodeToCommandBuffer: commandBuffer sourceTexture: inTexture destinationTexture: drawable.texture]; 51 | [commandBuffer presentDrawable:drawable]; 52 | 53 | //commit commander buffer 54 | [commandBuffer commit]; 55 | } 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /HelloMetal/HelloMetal/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MeshFrame/MeshFrame/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MetalCube/MetalCube/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MetalLine/MetalLine/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /MetalPoint/MetalPoint/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /others/MetalPoint/MetalPoint/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /GaussianBlurMPS/GaussianBlurMPS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } --------------------------------------------------------------------------------