├── .gitignore ├── .travis.yml ├── Example ├── GPUUtilization.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── GPUUtilization-Example.xcscheme ├── GPUUtilization.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── GPUUtilization │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── GPUUtilization-Info.plist │ ├── GPUUtilization-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── ColorMap.textureset │ │ │ ├── Contents.json │ │ │ └── Universal.mipmapset │ │ │ ├── ColorMap.png │ │ │ └── Contents.json │ ├── RTAppDelegate.h │ ├── RTAppDelegate.m │ ├── RTCollectionViewController.h │ ├── RTCollectionViewController.m │ ├── RTGameViewController.h │ ├── RTGameViewController.m │ ├── RTGradientView.h │ ├── RTGradientView.m │ ├── RTMetalViewController.h │ ├── RTMetalViewController.m │ ├── RTRootViewController.h │ ├── RTRootViewController.m │ ├── RTTableViewController.h │ ├── RTTableViewController.m │ ├── Renderer.h │ ├── Renderer.m │ ├── ShaderTypes.h │ ├── Shaders.metal │ ├── art.scnassets │ │ ├── ship.scn │ │ └── texture.png │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m ├── Podfile ├── Podfile.lock └── Tests │ ├── Tests-Info.plist │ ├── Tests-Prefix.pch │ ├── Tests.m │ └── en.lproj │ └── InfoPlist.strings ├── GPUUtilization.podspec ├── GPUUtilization ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── GPUUtilization.h │ ├── GPUUtilization.m │ └── IOKit.h ├── LICENSE ├── README.md └── _Pods.xcodeproj /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/GPUUtilization.xcworkspace -scheme GPUUtilization-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/GPUUtilization.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0DD995E57C5F923128FDC620 /* Pods_GPUUtilization_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E63A0FF94F0DE6285548D660 /* Pods_GPUUtilization_Example.framework */; }; 11 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 12 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; 13 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 14 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F596195388D20070C39A /* InfoPlist.strings */; }; 15 | 6003F59A195388D20070C39A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F599195388D20070C39A /* main.m */; }; 16 | 6003F59E195388D20070C39A /* RTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F59D195388D20070C39A /* RTAppDelegate.m */; }; 17 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; }; 18 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; 19 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 20 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 21 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 22 | 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; 23 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 24 | 9C9E5D102154944C004745F4 /* RTCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C9E5D0F2154944C004745F4 /* RTCollectionViewController.m */; }; 25 | 9CB2D577215397020081176F /* RTGameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D576215397020081176F /* RTGameViewController.m */; }; 26 | 9CB2D57A2153977F0081176F /* RTTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D5792153977F0081176F /* RTTableViewController.m */; }; 27 | 9CB2D57D21539A950081176F /* RTRootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D57C21539A950081176F /* RTRootViewController.m */; }; 28 | 9CB2D5812153A06A0081176F /* art.scnassets in Resources */ = {isa = PBXBuildFile; fileRef = 9CB2D562215395E60081176F /* art.scnassets */; }; 29 | 9CB2D5822153A0740081176F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; }; 30 | 9CB2D5C12153A13D0081176F /* RTMetalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D5C02153A13D0081176F /* RTMetalViewController.m */; }; 31 | 9CB2D5C22153A1460081176F /* Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D5A92153A0D70081176F /* Renderer.m */; }; 32 | 9CB2D5C32153A1750081176F /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9CB2D5AE2153A0D70081176F /* Shaders.metal */; }; 33 | 9CBC6DB82153DC9500AB206A /* RTGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CBC6DB72153DC9500AB206A /* RTGradientView.m */; }; 34 | F54827074FFAADB0AD5B3565 /* Pods_GPUUtilization_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B40E255125B8E918D8536AB6 /* Pods_GPUUtilization_Tests.framework */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXContainerItemProxy section */ 38 | 6003F5B3195388D20070C39A /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = 6003F582195388D10070C39A /* Project object */; 41 | proxyType = 1; 42 | remoteGlobalIDString = 6003F589195388D20070C39A; 43 | remoteInfo = GPUUtilization; 44 | }; 45 | /* End PBXContainerItemProxy section */ 46 | 47 | /* Begin PBXFileReference section */ 48 | 27BAE02577DA97175A31E82A /* Pods-GPUUtilization_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GPUUtilization_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GPUUtilization_Tests/Pods-GPUUtilization_Tests.debug.xcconfig"; sourceTree = ""; }; 49 | 3199CB4861D35D71B7539700 /* Pods-GPUUtilization_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GPUUtilization_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GPUUtilization_Example/Pods-GPUUtilization_Example.debug.xcconfig"; sourceTree = ""; }; 50 | 6003F58A195388D20070C39A /* GPUUtilization_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GPUUtilization_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 52 | 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 53 | 6003F591195388D20070C39A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 54 | 6003F595195388D20070C39A /* GPUUtilization-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GPUUtilization-Info.plist"; sourceTree = ""; }; 55 | 6003F597195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 56 | 6003F599195388D20070C39A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 57 | 6003F59B195388D20070C39A /* GPUUtilization-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GPUUtilization-Prefix.pch"; sourceTree = ""; }; 58 | 6003F59C195388D20070C39A /* RTAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTAppDelegate.h; sourceTree = ""; }; 59 | 6003F59D195388D20070C39A /* RTAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTAppDelegate.m; sourceTree = ""; }; 60 | 6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 61 | 6003F5AE195388D20070C39A /* GPUUtilization_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GPUUtilization_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 62 | 6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 63 | 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; 64 | 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 65 | 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 66 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 67 | 6E7CA35EBC465C89D2DE788D /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 68 | 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 69 | 85BC099EF4109F2F37CF5FB1 /* Pods-GPUUtilization_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GPUUtilization_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-GPUUtilization_Tests/Pods-GPUUtilization_Tests.release.xcconfig"; sourceTree = ""; }; 70 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 71 | 9C9E5D0E2154944C004745F4 /* RTCollectionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCollectionViewController.h; sourceTree = ""; }; 72 | 9C9E5D0F2154944C004745F4 /* RTCollectionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTCollectionViewController.m; sourceTree = ""; }; 73 | 9CB2D562215395E60081176F /* art.scnassets */ = {isa = PBXFileReference; lastKnownFileType = wrapper.scnassets; path = art.scnassets; sourceTree = ""; }; 74 | 9CB2D575215397020081176F /* RTGameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTGameViewController.h; sourceTree = ""; }; 75 | 9CB2D576215397020081176F /* RTGameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTGameViewController.m; sourceTree = ""; }; 76 | 9CB2D5782153977F0081176F /* RTTableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTTableViewController.h; sourceTree = ""; }; 77 | 9CB2D5792153977F0081176F /* RTTableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTTableViewController.m; sourceTree = ""; }; 78 | 9CB2D57B21539A950081176F /* RTRootViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTRootViewController.h; sourceTree = ""; }; 79 | 9CB2D57C21539A950081176F /* RTRootViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTRootViewController.m; sourceTree = ""; }; 80 | 9CB2D5A82153A0D70081176F /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = ""; }; 81 | 9CB2D5A92153A0D70081176F /* Renderer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Renderer.m; sourceTree = ""; }; 82 | 9CB2D5AE2153A0D70081176F /* Shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; }; 83 | 9CB2D5B02153A0D70081176F /* ShaderTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTypes.h; sourceTree = ""; }; 84 | 9CB2D5BF2153A13D0081176F /* RTMetalViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTMetalViewController.h; sourceTree = ""; }; 85 | 9CB2D5C02153A13D0081176F /* RTMetalViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTMetalViewController.m; sourceTree = ""; }; 86 | 9CBC6DB62153DC9500AB206A /* RTGradientView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTGradientView.h; sourceTree = ""; }; 87 | 9CBC6DB72153DC9500AB206A /* RTGradientView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RTGradientView.m; sourceTree = ""; }; 88 | B40E255125B8E918D8536AB6 /* Pods_GPUUtilization_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GPUUtilization_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 89 | C341FF313B32872FDB6BC805 /* GPUUtilization.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GPUUtilization.podspec; path = ../GPUUtilization.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 90 | D48A032BCD980F15F021F474 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 91 | DE3866649ACD608B15A24958 /* Pods-GPUUtilization_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GPUUtilization_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-GPUUtilization_Example/Pods-GPUUtilization_Example.release.xcconfig"; sourceTree = ""; }; 92 | E63A0FF94F0DE6285548D660 /* Pods_GPUUtilization_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GPUUtilization_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 93 | /* End PBXFileReference section */ 94 | 95 | /* Begin PBXFrameworksBuildPhase section */ 96 | 6003F587195388D20070C39A /* Frameworks */ = { 97 | isa = PBXFrameworksBuildPhase; 98 | buildActionMask = 2147483647; 99 | files = ( 100 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */, 101 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */, 102 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */, 103 | 0DD995E57C5F923128FDC620 /* Pods_GPUUtilization_Example.framework in Frameworks */, 104 | ); 105 | runOnlyForDeploymentPostprocessing = 0; 106 | }; 107 | 6003F5AB195388D20070C39A /* Frameworks */ = { 108 | isa = PBXFrameworksBuildPhase; 109 | buildActionMask = 2147483647; 110 | files = ( 111 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */, 112 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */, 113 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */, 114 | F54827074FFAADB0AD5B3565 /* Pods_GPUUtilization_Tests.framework in Frameworks */, 115 | ); 116 | runOnlyForDeploymentPostprocessing = 0; 117 | }; 118 | /* End PBXFrameworksBuildPhase section */ 119 | 120 | /* Begin PBXGroup section */ 121 | 45B3010ED1D975C3043FDCBC /* Pods */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 3199CB4861D35D71B7539700 /* Pods-GPUUtilization_Example.debug.xcconfig */, 125 | DE3866649ACD608B15A24958 /* Pods-GPUUtilization_Example.release.xcconfig */, 126 | 27BAE02577DA97175A31E82A /* Pods-GPUUtilization_Tests.debug.xcconfig */, 127 | 85BC099EF4109F2F37CF5FB1 /* Pods-GPUUtilization_Tests.release.xcconfig */, 128 | ); 129 | name = Pods; 130 | sourceTree = ""; 131 | }; 132 | 6003F581195388D10070C39A = { 133 | isa = PBXGroup; 134 | children = ( 135 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */, 136 | 6003F593195388D20070C39A /* Example for GPUUtilization */, 137 | 6003F5B5195388D20070C39A /* Tests */, 138 | 6003F58C195388D20070C39A /* Frameworks */, 139 | 6003F58B195388D20070C39A /* Products */, 140 | 45B3010ED1D975C3043FDCBC /* Pods */, 141 | ); 142 | sourceTree = ""; 143 | }; 144 | 6003F58B195388D20070C39A /* Products */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 6003F58A195388D20070C39A /* GPUUtilization_Example.app */, 148 | 6003F5AE195388D20070C39A /* GPUUtilization_Tests.xctest */, 149 | ); 150 | name = Products; 151 | sourceTree = ""; 152 | }; 153 | 6003F58C195388D20070C39A /* Frameworks */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 6003F58D195388D20070C39A /* Foundation.framework */, 157 | 6003F58F195388D20070C39A /* CoreGraphics.framework */, 158 | 6003F591195388D20070C39A /* UIKit.framework */, 159 | 6003F5AF195388D20070C39A /* XCTest.framework */, 160 | E63A0FF94F0DE6285548D660 /* Pods_GPUUtilization_Example.framework */, 161 | B40E255125B8E918D8536AB6 /* Pods_GPUUtilization_Tests.framework */, 162 | ); 163 | name = Frameworks; 164 | sourceTree = ""; 165 | }; 166 | 6003F593195388D20070C39A /* Example for GPUUtilization */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 9CB2D562215395E60081176F /* art.scnassets */, 170 | 6003F5A8195388D20070C39A /* Images.xcassets */, 171 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, 172 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 173 | 9CB2D5A82153A0D70081176F /* Renderer.h */, 174 | 9CB2D5A92153A0D70081176F /* Renderer.m */, 175 | 6003F59C195388D20070C39A /* RTAppDelegate.h */, 176 | 6003F59D195388D20070C39A /* RTAppDelegate.m */, 177 | 9C9E5D0E2154944C004745F4 /* RTCollectionViewController.h */, 178 | 9C9E5D0F2154944C004745F4 /* RTCollectionViewController.m */, 179 | 9CB2D575215397020081176F /* RTGameViewController.h */, 180 | 9CB2D576215397020081176F /* RTGameViewController.m */, 181 | 9CBC6DB62153DC9500AB206A /* RTGradientView.h */, 182 | 9CBC6DB72153DC9500AB206A /* RTGradientView.m */, 183 | 9CB2D5BF2153A13D0081176F /* RTMetalViewController.h */, 184 | 9CB2D5C02153A13D0081176F /* RTMetalViewController.m */, 185 | 9CB2D57B21539A950081176F /* RTRootViewController.h */, 186 | 9CB2D57C21539A950081176F /* RTRootViewController.m */, 187 | 9CB2D5782153977F0081176F /* RTTableViewController.h */, 188 | 9CB2D5792153977F0081176F /* RTTableViewController.m */, 189 | 9CB2D5AE2153A0D70081176F /* Shaders.metal */, 190 | 9CB2D5B02153A0D70081176F /* ShaderTypes.h */, 191 | 6003F594195388D20070C39A /* Supporting Files */, 192 | ); 193 | name = "Example for GPUUtilization"; 194 | path = GPUUtilization; 195 | sourceTree = ""; 196 | }; 197 | 6003F594195388D20070C39A /* Supporting Files */ = { 198 | isa = PBXGroup; 199 | children = ( 200 | 6003F595195388D20070C39A /* GPUUtilization-Info.plist */, 201 | 6003F596195388D20070C39A /* InfoPlist.strings */, 202 | 6003F599195388D20070C39A /* main.m */, 203 | 6003F59B195388D20070C39A /* GPUUtilization-Prefix.pch */, 204 | ); 205 | name = "Supporting Files"; 206 | sourceTree = ""; 207 | }; 208 | 6003F5B5195388D20070C39A /* Tests */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 6003F5BB195388D20070C39A /* Tests.m */, 212 | 6003F5B6195388D20070C39A /* Supporting Files */, 213 | ); 214 | path = Tests; 215 | sourceTree = ""; 216 | }; 217 | 6003F5B6195388D20070C39A /* Supporting Files */ = { 218 | isa = PBXGroup; 219 | children = ( 220 | 6003F5B7195388D20070C39A /* Tests-Info.plist */, 221 | 6003F5B8195388D20070C39A /* InfoPlist.strings */, 222 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */, 223 | ); 224 | name = "Supporting Files"; 225 | sourceTree = ""; 226 | }; 227 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = { 228 | isa = PBXGroup; 229 | children = ( 230 | C341FF313B32872FDB6BC805 /* GPUUtilization.podspec */, 231 | D48A032BCD980F15F021F474 /* README.md */, 232 | 6E7CA35EBC465C89D2DE788D /* LICENSE */, 233 | ); 234 | name = "Podspec Metadata"; 235 | sourceTree = ""; 236 | }; 237 | /* End PBXGroup section */ 238 | 239 | /* Begin PBXNativeTarget section */ 240 | 6003F589195388D20070C39A /* GPUUtilization_Example */ = { 241 | isa = PBXNativeTarget; 242 | buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "GPUUtilization_Example" */; 243 | buildPhases = ( 244 | C2482A16DB7BDD5A55C03EF6 /* [CP] Check Pods Manifest.lock */, 245 | 6003F586195388D20070C39A /* Sources */, 246 | 6003F587195388D20070C39A /* Frameworks */, 247 | 6003F588195388D20070C39A /* Resources */, 248 | 1C104E1639FDBB3358DDA589 /* [CP] Embed Pods Frameworks */, 249 | ); 250 | buildRules = ( 251 | ); 252 | dependencies = ( 253 | ); 254 | name = GPUUtilization_Example; 255 | productName = GPUUtilization; 256 | productReference = 6003F58A195388D20070C39A /* GPUUtilization_Example.app */; 257 | productType = "com.apple.product-type.application"; 258 | }; 259 | 6003F5AD195388D20070C39A /* GPUUtilization_Tests */ = { 260 | isa = PBXNativeTarget; 261 | buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "GPUUtilization_Tests" */; 262 | buildPhases = ( 263 | 09F4AA7ACD36CBF3E77E0C8F /* [CP] Check Pods Manifest.lock */, 264 | 6003F5AA195388D20070C39A /* Sources */, 265 | 6003F5AB195388D20070C39A /* Frameworks */, 266 | 6003F5AC195388D20070C39A /* Resources */, 267 | ); 268 | buildRules = ( 269 | ); 270 | dependencies = ( 271 | 6003F5B4195388D20070C39A /* PBXTargetDependency */, 272 | ); 273 | name = GPUUtilization_Tests; 274 | productName = GPUUtilizationTests; 275 | productReference = 6003F5AE195388D20070C39A /* GPUUtilization_Tests.xctest */; 276 | productType = "com.apple.product-type.bundle.unit-test"; 277 | }; 278 | /* End PBXNativeTarget section */ 279 | 280 | /* Begin PBXProject section */ 281 | 6003F582195388D10070C39A /* Project object */ = { 282 | isa = PBXProject; 283 | attributes = { 284 | CLASSPREFIX = RT; 285 | LastUpgradeCheck = 0940; 286 | ORGANIZATIONNAME = rickytan; 287 | TargetAttributes = { 288 | 6003F589195388D20070C39A = { 289 | DevelopmentTeam = 36X754M3QH; 290 | }; 291 | 6003F5AD195388D20070C39A = { 292 | TestTargetID = 6003F589195388D20070C39A; 293 | }; 294 | }; 295 | }; 296 | buildConfigurationList = 6003F585195388D10070C39A /* Build configuration list for PBXProject "GPUUtilization" */; 297 | compatibilityVersion = "Xcode 3.2"; 298 | developmentRegion = English; 299 | hasScannedForEncodings = 0; 300 | knownRegions = ( 301 | en, 302 | Base, 303 | ); 304 | mainGroup = 6003F581195388D10070C39A; 305 | productRefGroup = 6003F58B195388D20070C39A /* Products */; 306 | projectDirPath = ""; 307 | projectRoot = ""; 308 | targets = ( 309 | 6003F589195388D20070C39A /* GPUUtilization_Example */, 310 | 6003F5AD195388D20070C39A /* GPUUtilization_Tests */, 311 | ); 312 | }; 313 | /* End PBXProject section */ 314 | 315 | /* Begin PBXResourcesBuildPhase section */ 316 | 6003F588195388D20070C39A /* Resources */ = { 317 | isa = PBXResourcesBuildPhase; 318 | buildActionMask = 2147483647; 319 | files = ( 320 | 9CB2D5822153A0740081176F /* LaunchScreen.storyboard in Resources */, 321 | 9CB2D5812153A06A0081176F /* art.scnassets in Resources */, 322 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, 323 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 324 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | 6003F5AC195388D20070C39A /* Resources */ = { 329 | isa = PBXResourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXResourcesBuildPhase section */ 337 | 338 | /* Begin PBXShellScriptBuildPhase section */ 339 | 09F4AA7ACD36CBF3E77E0C8F /* [CP] Check Pods Manifest.lock */ = { 340 | isa = PBXShellScriptBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | ); 344 | inputPaths = ( 345 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 346 | "${PODS_ROOT}/Manifest.lock", 347 | ); 348 | name = "[CP] Check Pods Manifest.lock"; 349 | outputPaths = ( 350 | "$(DERIVED_FILE_DIR)/Pods-GPUUtilization_Tests-checkManifestLockResult.txt", 351 | ); 352 | runOnlyForDeploymentPostprocessing = 0; 353 | shellPath = /bin/sh; 354 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 355 | showEnvVarsInLog = 0; 356 | }; 357 | 1C104E1639FDBB3358DDA589 /* [CP] Embed Pods Frameworks */ = { 358 | isa = PBXShellScriptBuildPhase; 359 | buildActionMask = 2147483647; 360 | files = ( 361 | ); 362 | inputPaths = ( 363 | "${SRCROOT}/Pods/Target Support Files/Pods-GPUUtilization_Example/Pods-GPUUtilization_Example-frameworks.sh", 364 | "${BUILT_PRODUCTS_DIR}/GPUUtilization/GPUUtilization.framework", 365 | ); 366 | name = "[CP] Embed Pods Frameworks"; 367 | outputPaths = ( 368 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GPUUtilization.framework", 369 | ); 370 | runOnlyForDeploymentPostprocessing = 0; 371 | shellPath = /bin/sh; 372 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-GPUUtilization_Example/Pods-GPUUtilization_Example-frameworks.sh\"\n"; 373 | showEnvVarsInLog = 0; 374 | }; 375 | C2482A16DB7BDD5A55C03EF6 /* [CP] Check Pods Manifest.lock */ = { 376 | isa = PBXShellScriptBuildPhase; 377 | buildActionMask = 2147483647; 378 | files = ( 379 | ); 380 | inputPaths = ( 381 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 382 | "${PODS_ROOT}/Manifest.lock", 383 | ); 384 | name = "[CP] Check Pods Manifest.lock"; 385 | outputPaths = ( 386 | "$(DERIVED_FILE_DIR)/Pods-GPUUtilization_Example-checkManifestLockResult.txt", 387 | ); 388 | runOnlyForDeploymentPostprocessing = 0; 389 | shellPath = /bin/sh; 390 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 391 | showEnvVarsInLog = 0; 392 | }; 393 | /* End PBXShellScriptBuildPhase section */ 394 | 395 | /* Begin PBXSourcesBuildPhase section */ 396 | 6003F586195388D20070C39A /* Sources */ = { 397 | isa = PBXSourcesBuildPhase; 398 | buildActionMask = 2147483647; 399 | files = ( 400 | 9C9E5D102154944C004745F4 /* RTCollectionViewController.m in Sources */, 401 | 9CB2D5C32153A1750081176F /* Shaders.metal in Sources */, 402 | 9CB2D577215397020081176F /* RTGameViewController.m in Sources */, 403 | 6003F59E195388D20070C39A /* RTAppDelegate.m in Sources */, 404 | 9CBC6DB82153DC9500AB206A /* RTGradientView.m in Sources */, 405 | 9CB2D5C22153A1460081176F /* Renderer.m in Sources */, 406 | 6003F59A195388D20070C39A /* main.m in Sources */, 407 | 9CB2D57D21539A950081176F /* RTRootViewController.m in Sources */, 408 | 9CB2D5C12153A13D0081176F /* RTMetalViewController.m in Sources */, 409 | 9CB2D57A2153977F0081176F /* RTTableViewController.m in Sources */, 410 | ); 411 | runOnlyForDeploymentPostprocessing = 0; 412 | }; 413 | 6003F5AA195388D20070C39A /* Sources */ = { 414 | isa = PBXSourcesBuildPhase; 415 | buildActionMask = 2147483647; 416 | files = ( 417 | 6003F5BC195388D20070C39A /* Tests.m in Sources */, 418 | ); 419 | runOnlyForDeploymentPostprocessing = 0; 420 | }; 421 | /* End PBXSourcesBuildPhase section */ 422 | 423 | /* Begin PBXTargetDependency section */ 424 | 6003F5B4195388D20070C39A /* PBXTargetDependency */ = { 425 | isa = PBXTargetDependency; 426 | target = 6003F589195388D20070C39A /* GPUUtilization_Example */; 427 | targetProxy = 6003F5B3195388D20070C39A /* PBXContainerItemProxy */; 428 | }; 429 | /* End PBXTargetDependency section */ 430 | 431 | /* Begin PBXVariantGroup section */ 432 | 6003F596195388D20070C39A /* InfoPlist.strings */ = { 433 | isa = PBXVariantGroup; 434 | children = ( 435 | 6003F597195388D20070C39A /* en */, 436 | ); 437 | name = InfoPlist.strings; 438 | sourceTree = ""; 439 | }; 440 | 6003F5B8195388D20070C39A /* InfoPlist.strings */ = { 441 | isa = PBXVariantGroup; 442 | children = ( 443 | 6003F5B9195388D20070C39A /* en */, 444 | ); 445 | name = InfoPlist.strings; 446 | sourceTree = ""; 447 | }; 448 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */ = { 449 | isa = PBXVariantGroup; 450 | children = ( 451 | 71719F9E1E33DC2100824A3D /* Base */, 452 | ); 453 | name = LaunchScreen.storyboard; 454 | sourceTree = ""; 455 | }; 456 | /* End PBXVariantGroup section */ 457 | 458 | /* Begin XCBuildConfiguration section */ 459 | 6003F5BD195388D20070C39A /* Debug */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ALWAYS_SEARCH_USER_PATHS = NO; 463 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 464 | CLANG_CXX_LIBRARY = "libc++"; 465 | CLANG_ENABLE_MODULES = YES; 466 | CLANG_ENABLE_OBJC_ARC = YES; 467 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 468 | CLANG_WARN_BOOL_CONVERSION = YES; 469 | CLANG_WARN_COMMA = YES; 470 | CLANG_WARN_CONSTANT_CONVERSION = YES; 471 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 472 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 473 | CLANG_WARN_EMPTY_BODY = YES; 474 | CLANG_WARN_ENUM_CONVERSION = YES; 475 | CLANG_WARN_INFINITE_RECURSION = YES; 476 | CLANG_WARN_INT_CONVERSION = YES; 477 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 478 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 479 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 480 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 481 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 482 | CLANG_WARN_STRICT_PROTOTYPES = YES; 483 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 484 | CLANG_WARN_UNREACHABLE_CODE = YES; 485 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 486 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 487 | COPY_PHASE_STRIP = NO; 488 | ENABLE_STRICT_OBJC_MSGSEND = YES; 489 | ENABLE_TESTABILITY = YES; 490 | GCC_C_LANGUAGE_STANDARD = gnu99; 491 | GCC_DYNAMIC_NO_PIC = NO; 492 | GCC_NO_COMMON_BLOCKS = YES; 493 | GCC_OPTIMIZATION_LEVEL = 0; 494 | GCC_PREPROCESSOR_DEFINITIONS = ( 495 | "DEBUG=1", 496 | "$(inherited)", 497 | ); 498 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 499 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 500 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 501 | GCC_WARN_UNDECLARED_SELECTOR = YES; 502 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 503 | GCC_WARN_UNUSED_FUNCTION = YES; 504 | GCC_WARN_UNUSED_VARIABLE = YES; 505 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 506 | ONLY_ACTIVE_ARCH = YES; 507 | SDKROOT = iphoneos; 508 | TARGETED_DEVICE_FAMILY = "1,2"; 509 | }; 510 | name = Debug; 511 | }; 512 | 6003F5BE195388D20070C39A /* Release */ = { 513 | isa = XCBuildConfiguration; 514 | buildSettings = { 515 | ALWAYS_SEARCH_USER_PATHS = NO; 516 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 517 | CLANG_CXX_LIBRARY = "libc++"; 518 | CLANG_ENABLE_MODULES = YES; 519 | CLANG_ENABLE_OBJC_ARC = YES; 520 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 521 | CLANG_WARN_BOOL_CONVERSION = YES; 522 | CLANG_WARN_COMMA = YES; 523 | CLANG_WARN_CONSTANT_CONVERSION = YES; 524 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 525 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 526 | CLANG_WARN_EMPTY_BODY = YES; 527 | CLANG_WARN_ENUM_CONVERSION = YES; 528 | CLANG_WARN_INFINITE_RECURSION = YES; 529 | CLANG_WARN_INT_CONVERSION = YES; 530 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 531 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 532 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 533 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 534 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 535 | CLANG_WARN_STRICT_PROTOTYPES = YES; 536 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 537 | CLANG_WARN_UNREACHABLE_CODE = YES; 538 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 539 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 540 | COPY_PHASE_STRIP = YES; 541 | ENABLE_NS_ASSERTIONS = NO; 542 | ENABLE_STRICT_OBJC_MSGSEND = YES; 543 | GCC_C_LANGUAGE_STANDARD = gnu99; 544 | GCC_NO_COMMON_BLOCKS = YES; 545 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 546 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 547 | GCC_WARN_UNDECLARED_SELECTOR = YES; 548 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 549 | GCC_WARN_UNUSED_FUNCTION = YES; 550 | GCC_WARN_UNUSED_VARIABLE = YES; 551 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 552 | SDKROOT = iphoneos; 553 | TARGETED_DEVICE_FAMILY = "1,2"; 554 | VALIDATE_PRODUCT = YES; 555 | }; 556 | name = Release; 557 | }; 558 | 6003F5C0195388D20070C39A /* Debug */ = { 559 | isa = XCBuildConfiguration; 560 | baseConfigurationReference = 3199CB4861D35D71B7539700 /* Pods-GPUUtilization_Example.debug.xcconfig */; 561 | buildSettings = { 562 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 563 | DEVELOPMENT_TEAM = 36X754M3QH; 564 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 565 | GCC_PREFIX_HEADER = "GPUUtilization/GPUUtilization-Prefix.pch"; 566 | INFOPLIST_FILE = "GPUUtilization/GPUUtilization-Info.plist"; 567 | MODULE_NAME = ExampleApp; 568 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 569 | PRODUCT_NAME = "$(TARGET_NAME)"; 570 | WRAPPER_EXTENSION = app; 571 | }; 572 | name = Debug; 573 | }; 574 | 6003F5C1195388D20070C39A /* Release */ = { 575 | isa = XCBuildConfiguration; 576 | baseConfigurationReference = DE3866649ACD608B15A24958 /* Pods-GPUUtilization_Example.release.xcconfig */; 577 | buildSettings = { 578 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 579 | DEVELOPMENT_TEAM = 36X754M3QH; 580 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 581 | GCC_PREFIX_HEADER = "GPUUtilization/GPUUtilization-Prefix.pch"; 582 | INFOPLIST_FILE = "GPUUtilization/GPUUtilization-Info.plist"; 583 | MODULE_NAME = ExampleApp; 584 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 585 | PRODUCT_NAME = "$(TARGET_NAME)"; 586 | WRAPPER_EXTENSION = app; 587 | }; 588 | name = Release; 589 | }; 590 | 6003F5C3195388D20070C39A /* Debug */ = { 591 | isa = XCBuildConfiguration; 592 | baseConfigurationReference = 27BAE02577DA97175A31E82A /* Pods-GPUUtilization_Tests.debug.xcconfig */; 593 | buildSettings = { 594 | BUNDLE_LOADER = "$(TEST_HOST)"; 595 | FRAMEWORK_SEARCH_PATHS = ( 596 | "$(SDKROOT)/Developer/Library/Frameworks", 597 | "$(inherited)", 598 | "$(DEVELOPER_FRAMEWORKS_DIR)", 599 | ); 600 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 601 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 602 | GCC_PREPROCESSOR_DEFINITIONS = ( 603 | "DEBUG=1", 604 | "$(inherited)", 605 | ); 606 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 607 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 608 | PRODUCT_NAME = "$(TARGET_NAME)"; 609 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GPUUtilization_Example.app/GPUUtilization_Example"; 610 | WRAPPER_EXTENSION = xctest; 611 | }; 612 | name = Debug; 613 | }; 614 | 6003F5C4195388D20070C39A /* Release */ = { 615 | isa = XCBuildConfiguration; 616 | baseConfigurationReference = 85BC099EF4109F2F37CF5FB1 /* Pods-GPUUtilization_Tests.release.xcconfig */; 617 | buildSettings = { 618 | BUNDLE_LOADER = "$(TEST_HOST)"; 619 | FRAMEWORK_SEARCH_PATHS = ( 620 | "$(SDKROOT)/Developer/Library/Frameworks", 621 | "$(inherited)", 622 | "$(DEVELOPER_FRAMEWORKS_DIR)", 623 | ); 624 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 625 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 626 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 627 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 628 | PRODUCT_NAME = "$(TARGET_NAME)"; 629 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GPUUtilization_Example.app/GPUUtilization_Example"; 630 | WRAPPER_EXTENSION = xctest; 631 | }; 632 | name = Release; 633 | }; 634 | /* End XCBuildConfiguration section */ 635 | 636 | /* Begin XCConfigurationList section */ 637 | 6003F585195388D10070C39A /* Build configuration list for PBXProject "GPUUtilization" */ = { 638 | isa = XCConfigurationList; 639 | buildConfigurations = ( 640 | 6003F5BD195388D20070C39A /* Debug */, 641 | 6003F5BE195388D20070C39A /* Release */, 642 | ); 643 | defaultConfigurationIsVisible = 0; 644 | defaultConfigurationName = Release; 645 | }; 646 | 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "GPUUtilization_Example" */ = { 647 | isa = XCConfigurationList; 648 | buildConfigurations = ( 649 | 6003F5C0195388D20070C39A /* Debug */, 650 | 6003F5C1195388D20070C39A /* Release */, 651 | ); 652 | defaultConfigurationIsVisible = 0; 653 | defaultConfigurationName = Release; 654 | }; 655 | 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "GPUUtilization_Tests" */ = { 656 | isa = XCConfigurationList; 657 | buildConfigurations = ( 658 | 6003F5C3195388D20070C39A /* Debug */, 659 | 6003F5C4195388D20070C39A /* Release */, 660 | ); 661 | defaultConfigurationIsVisible = 0; 662 | defaultConfigurationName = Release; 663 | }; 664 | /* End XCConfigurationList section */ 665 | }; 666 | rootObject = 6003F582195388D10070C39A /* Project object */; 667 | } 668 | -------------------------------------------------------------------------------- /Example/GPUUtilization.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/GPUUtilization.xcodeproj/xcshareddata/xcschemes/GPUUtilization-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Example/GPUUtilization.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/GPUUtilization.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/GPUUtilization/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 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Example/GPUUtilization/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 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | -------------------------------------------------------------------------------- /Example/GPUUtilization/GPUUtilization-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | GPUUtil 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 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 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 | -------------------------------------------------------------------------------- /Example/GPUUtilization/GPUUtilization-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import UIKit; 15 | @import Foundation; 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Images.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 | } 99 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Images.xcassets/ColorMap.textureset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | }, 6 | "properties" : { 7 | "origin" : "bottom-left", 8 | "interpretation" : "non-premultiplied-colors" 9 | }, 10 | "textures" : [ 11 | { 12 | "idiom" : "universal", 13 | "filename" : "Universal.mipmapset" 14 | } 15 | ] 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Images.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickytan/GPUUtilization/8a156fd8ddc968df809b5eaa4ae68f1ab8b0cd27/Example/GPUUtilization/Images.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png -------------------------------------------------------------------------------- /Example/GPUUtilization/Images.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | }, 6 | "levels" : [ 7 | { 8 | "filename" : "ColorMap.png", 9 | "mipmap-level" : "base" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTAppDelegate.h 3 | // GPUUtilization 4 | // 5 | // Created by rickytan on 09/20/2018. 6 | // Copyright (c) 2018 rickytan. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface RTAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTAppDelegate.m 3 | // GPUUtilization 4 | // 5 | // Created by rickytan on 09/20/2018. 6 | // Copyright (c) 2018 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTAppDelegate.h" 10 | 11 | #import 12 | 13 | @implementation RTAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | 18 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 19 | UILabel * gpuLabel = [[UILabel alloc] init]; 20 | gpuLabel.backgroundColor = [UIColor whiteColor]; 21 | gpuLabel.font = [UIFont fontWithName:@"Courier" size:14]; 22 | gpuLabel.text = @"GPU: 0%"; 23 | gpuLabel.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin; 24 | [gpuLabel sizeToFit]; 25 | 26 | CGRect rect = gpuLabel.frame; 27 | rect.origin.x = 100.f; 28 | rect.origin.y = application.statusBarFrame.size.height; 29 | gpuLabel.frame = rect; 30 | [self.window addSubview:gpuLabel]; 31 | 32 | NSTimer *timer = [NSTimer timerWithTimeInterval:0.5 33 | repeats:YES 34 | block:^(NSTimer * timer) { 35 | [GPUUtilization fetchCurrentUtilization:^(GPUUtilization *current) { 36 | gpuLabel.text = [NSString stringWithFormat:@"GPU: %2zd%%", current.deviceUtilization]; 37 | }]; 38 | }]; 39 | [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 40 | }); 41 | return YES; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTCollectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTCollectionViewController.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/21. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface RTCollectionViewController : UICollectionViewController 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTCollectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTCollectionViewController.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/21. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTCollectionViewController.h" 10 | 11 | @interface RTCollectionViewController () 12 | 13 | @end 14 | 15 | @implementation RTCollectionViewController 16 | 17 | static NSString * const reuseIdentifier = @"Cell"; 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | // Uncomment the following line to preserve selection between presentations 23 | // self.clearsSelectionOnViewWillAppear = NO; 24 | 25 | // Do any additional setup after loading the view. 26 | } 27 | 28 | #pragma mark 29 | 30 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 31 | return 1; 32 | } 33 | 34 | 35 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 36 | return 100; 37 | } 38 | 39 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 40 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 41 | 42 | return cell; 43 | } 44 | @end 45 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTGameViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTGameViewController.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RTGameViewController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTGameViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTGameViewController.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTGameViewController.h" 10 | 11 | @implementation RTGameViewController 12 | 13 | - (void)viewDidLoad 14 | { 15 | [super viewDidLoad]; 16 | 17 | // create a new scene 18 | SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/ship.scn"]; 19 | 20 | // create and add a camera to the scene 21 | SCNNode *cameraNode = [SCNNode node]; 22 | cameraNode.camera = [SCNCamera camera]; 23 | [scene.rootNode addChildNode:cameraNode]; 24 | 25 | // place the camera 26 | cameraNode.position = SCNVector3Make(0, 0, 15); 27 | 28 | // create and add a light to the scene 29 | SCNNode *lightNode = [SCNNode node]; 30 | lightNode.light = [SCNLight light]; 31 | lightNode.light.type = SCNLightTypeOmni; 32 | lightNode.position = SCNVector3Make(0, 10, 10); 33 | [scene.rootNode addChildNode:lightNode]; 34 | 35 | // create and add an ambient light to the scene 36 | SCNNode *ambientLightNode = [SCNNode node]; 37 | ambientLightNode.light = [SCNLight light]; 38 | ambientLightNode.light.type = SCNLightTypeAmbient; 39 | ambientLightNode.light.color = [UIColor darkGrayColor]; 40 | [scene.rootNode addChildNode:ambientLightNode]; 41 | 42 | // retrieve the ship node 43 | SCNNode *ship = [scene.rootNode childNodeWithName:@"ship" recursively:YES]; 44 | 45 | // animate the 3d object 46 | [ship runAction:[SCNAction repeatActionForever:[SCNAction rotateByX:0 y:2 z:0 duration:1]]]; 47 | 48 | // retrieve the SCNView 49 | SCNView *scnView = (SCNView *)self.view; 50 | 51 | // set the scene to the view 52 | scnView.scene = scene; 53 | 54 | // allows the user to manipulate the camera 55 | scnView.allowsCameraControl = YES; 56 | 57 | // show statistics such as fps and timing information 58 | scnView.showsStatistics = YES; 59 | 60 | // configure the view 61 | scnView.backgroundColor = [UIColor blackColor]; 62 | 63 | // add a tap gesture recognizer 64 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; 65 | NSMutableArray *gestureRecognizers = [NSMutableArray array]; 66 | [gestureRecognizers addObject:tapGesture]; 67 | [gestureRecognizers addObjectsFromArray:scnView.gestureRecognizers]; 68 | scnView.gestureRecognizers = gestureRecognizers; 69 | } 70 | 71 | - (void) handleTap:(UIGestureRecognizer*)gestureRecognize 72 | { 73 | // retrieve the SCNView 74 | SCNView *scnView = (SCNView *)self.view; 75 | 76 | // check what nodes are tapped 77 | CGPoint p = [gestureRecognize locationInView:scnView]; 78 | NSArray *hitResults = [scnView hitTest:p options:nil]; 79 | 80 | // check that we clicked on at least one object 81 | if([hitResults count] > 0){ 82 | // retrieved the first clicked object 83 | SCNHitTestResult *result = [hitResults objectAtIndex:0]; 84 | 85 | // get its material 86 | SCNMaterial *material = result.node.geometry.firstMaterial; 87 | 88 | // highlight it 89 | [SCNTransaction begin]; 90 | [SCNTransaction setAnimationDuration:0.5]; 91 | 92 | // on completion - unhighlight 93 | [SCNTransaction setCompletionBlock:^{ 94 | [SCNTransaction begin]; 95 | [SCNTransaction setAnimationDuration:0.5]; 96 | 97 | material.emission.contents = [UIColor blackColor]; 98 | 99 | [SCNTransaction commit]; 100 | }]; 101 | 102 | material.emission.contents = [UIColor redColor]; 103 | 104 | [SCNTransaction commit]; 105 | } 106 | } 107 | 108 | - (BOOL)shouldAutorotate 109 | { 110 | return YES; 111 | } 112 | 113 | - (BOOL)prefersStatusBarHidden { 114 | return YES; 115 | } 116 | 117 | - (UIInterfaceOrientationMask)supportedInterfaceOrientations 118 | { 119 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 120 | return UIInterfaceOrientationMaskAllButUpsideDown; 121 | } else { 122 | return UIInterfaceOrientationMaskAll; 123 | } 124 | } 125 | 126 | - (void)didReceiveMemoryWarning 127 | { 128 | [super didReceiveMemoryWarning]; 129 | // Release any cached data, images, etc that aren't in use. 130 | } 131 | 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTGradientView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTGradientView.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | @interface RTGradientView : UIView 13 | @property (nonatomic, readonly, strong) CAGradientLayer *layer; 14 | @property (nonatomic, strong) IBInspectable UIColor *startColor; 15 | @property (nonatomic, strong) IBInspectable UIColor *endColor; 16 | @property (nonatomic, assign) IBInspectable CGPoint startPoint; 17 | @property (nonatomic, assign) IBInspectable CGPoint endPoint; 18 | @end 19 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTGradientView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTGradientView.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTGradientView.h" 10 | 11 | @implementation RTGradientView 12 | @dynamic layer; 13 | 14 | + (Class)layerClass 15 | { 16 | return [CAGradientLayer class]; 17 | } 18 | 19 | - (instancetype)initWithFrame:(CGRect)frame 20 | { 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | self.backgroundColor = [UIColor clearColor]; 24 | self.layer.locations = @[@0, @1]; 25 | self.startPoint = CGPointZero; 26 | self.endPoint = CGPointMake(0, 1); 27 | } 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithCoder:(NSCoder *)coder 32 | { 33 | self = [super initWithCoder:coder]; 34 | if (self) { 35 | self.backgroundColor = [UIColor clearColor]; 36 | self.layer.locations = @[@0, @1]; 37 | self.startPoint = CGPointZero; 38 | self.endPoint = CGPointMake(0, 1); 39 | } 40 | return self; 41 | } 42 | 43 | - (void)awakeFromNib 44 | { 45 | [super awakeFromNib]; 46 | } 47 | 48 | - (void)setStartColor:(UIColor *)startColor 49 | { 50 | _startColor = startColor; 51 | self.layer.colors = @[(id)(self.startColor ?: [UIColor clearColor]).CGColor, 52 | (id)(self.endColor ?: [UIColor clearColor]).CGColor]; 53 | } 54 | 55 | - (void)setEndColor:(UIColor *)endColor 56 | { 57 | _endColor = endColor; 58 | self.layer.colors = @[(id)(self.startColor ?: [UIColor clearColor]).CGColor, 59 | (id)(self.endColor ?: [UIColor clearColor]).CGColor]; 60 | } 61 | 62 | - (void)setStartPoint:(CGPoint)startPoint 63 | { 64 | self.layer.startPoint = startPoint; 65 | } 66 | 67 | - (CGPoint)startPoint { return self.layer.startPoint; } 68 | 69 | - (void)setEndPoint:(CGPoint)endPoint 70 | { 71 | self.layer.endPoint = endPoint; 72 | } 73 | 74 | - (CGPoint)endPoint { return self.layer.endPoint; } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTMetalViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTMetalViewController.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "Renderer.h" 13 | 14 | @interface RTMetalViewController : UIViewController 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTMetalViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTMetalViewController.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTMetalViewController.h" 10 | 11 | @implementation RTMetalViewController 12 | { 13 | MTKView *_view; 14 | 15 | Renderer *_renderer; 16 | } 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | _view = (MTKView *)self.view; 23 | 24 | _view.device = MTLCreateSystemDefaultDevice(); 25 | _view.backgroundColor = UIColor.blackColor; 26 | 27 | if(!_view.device) 28 | { 29 | NSLog(@"Metal is not supported on this device"); 30 | self.view = [[UIView alloc] initWithFrame:self.view.frame]; 31 | return; 32 | } 33 | 34 | _renderer = [[Renderer alloc] initWithMetalKitView:_view]; 35 | 36 | [_renderer mtkView:_view drawableSizeWillChange:_view.bounds.size]; 37 | 38 | _view.delegate = _renderer; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTRootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTRootViewController.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RTRootViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTRootViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTRootViewController.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTRootViewController.h" 10 | #import "RTTableViewController.h" 11 | 12 | @interface RTRootViewController () 13 | 14 | @end 15 | 16 | @implementation RTRootViewController 17 | 18 | 19 | #pragma mark - Navigation 20 | 21 | // In a storyboard-based application, you will often want to do a little preparation before navigation 22 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 23 | if ([[segue destinationViewController] isKindOfClass:[RTTableViewController class]]) { 24 | RTTableViewController *tableVC = [segue destinationViewController]; 25 | tableVC.cellIdentifier = [self.tableView cellForRowAtIndexPath:self.tableView.indexPathForSelectedRow].textLabel.text; 26 | } 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RTTableViewController.h 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (Outlet) 12 | @property (nonatomic, strong) IBOutlet UIView *maskView; 13 | @end 14 | 15 | @interface RTTableViewController : UITableViewController 16 | @property (nonatomic, copy) NSString *cellIdentifier; 17 | @end 18 | -------------------------------------------------------------------------------- /Example/GPUUtilization/RTTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RTTableViewController.m 3 | // GPUUtilization_Example 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import "RTTableViewController.h" 10 | 11 | @interface RTTableViewController () 12 | 13 | @end 14 | 15 | @implementation RTTableViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | // Uncomment the following line to preserve selection between presentations. 21 | // self.clearsSelectionOnViewWillAppear = NO; 22 | 23 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 24 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; 25 | } 26 | 27 | - (void)didReceiveMemoryWarning { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | #pragma mark - Table view data source 33 | 34 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 35 | return 1; 36 | } 37 | 38 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 39 | return 100; 40 | } 41 | 42 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 43 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier forIndexPath:indexPath]; 44 | 45 | return cell; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Renderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer.h 3 | // metal 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Our platform independent renderer class. Implements the MTKViewDelegate protocol which 12 | // allows it to accept per-frame update and drawable resize callbacks. 13 | @interface Renderer : NSObject 14 | 15 | -(nonnull instancetype)initWithMetalKitView:(nonnull MTKView *)view; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Renderer.m: -------------------------------------------------------------------------------- 1 | // 2 | // Renderer.m 3 | // metal 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "Renderer.h" 13 | 14 | // Include header shared between C code here, which executes Metal API commands, and .metal files 15 | #import "ShaderTypes.h" 16 | 17 | static const NSUInteger MaxBuffersInFlight = 3; 18 | 19 | @implementation Renderer 20 | { 21 | dispatch_semaphore_t _inFlightSemaphore; 22 | id _device; 23 | id _commandQueue; 24 | 25 | id _dynamicUniformBuffer[MaxBuffersInFlight]; 26 | id _pipelineState; 27 | id _depthState; 28 | id _colorMap; 29 | MTLVertexDescriptor *_mtlVertexDescriptor; 30 | 31 | uint8_t _uniformBufferIndex; 32 | 33 | matrix_float4x4 _projectionMatrix; 34 | 35 | float _rotation; 36 | 37 | MTKMesh *_mesh; 38 | } 39 | 40 | -(nonnull instancetype)initWithMetalKitView:(nonnull MTKView *)view; 41 | { 42 | self = [super init]; 43 | if(self) 44 | { 45 | _device = view.device; 46 | _inFlightSemaphore = dispatch_semaphore_create(MaxBuffersInFlight); 47 | [self _loadMetalWithView:view]; 48 | [self _loadAssets]; 49 | } 50 | 51 | return self; 52 | } 53 | 54 | - (void)_loadMetalWithView:(nonnull MTKView *)view; 55 | { 56 | /// Load Metal state objects and initalize renderer dependent view properties 57 | 58 | view.depthStencilPixelFormat = MTLPixelFormatDepth32Float_Stencil8; 59 | view.colorPixelFormat = MTLPixelFormatBGRA8Unorm_sRGB; 60 | view.sampleCount = 1; 61 | 62 | _mtlVertexDescriptor = [[MTLVertexDescriptor alloc] init]; 63 | 64 | _mtlVertexDescriptor.attributes[VertexAttributePosition].format = MTLVertexFormatFloat3; 65 | _mtlVertexDescriptor.attributes[VertexAttributePosition].offset = 0; 66 | _mtlVertexDescriptor.attributes[VertexAttributePosition].bufferIndex = BufferIndexMeshPositions; 67 | 68 | _mtlVertexDescriptor.attributes[VertexAttributeTexcoord].format = MTLVertexFormatFloat2; 69 | _mtlVertexDescriptor.attributes[VertexAttributeTexcoord].offset = 0; 70 | _mtlVertexDescriptor.attributes[VertexAttributeTexcoord].bufferIndex = BufferIndexMeshGenerics; 71 | 72 | _mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stride = 12; 73 | _mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stepRate = 1; 74 | _mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stepFunction = MTLVertexStepFunctionPerVertex; 75 | 76 | _mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stride = 8; 77 | _mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stepRate = 1; 78 | _mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stepFunction = MTLVertexStepFunctionPerVertex; 79 | 80 | id defaultLibrary = [_device newDefaultLibrary]; 81 | 82 | id vertexFunction = [defaultLibrary newFunctionWithName:@"vertexShader"]; 83 | 84 | id fragmentFunction = [defaultLibrary newFunctionWithName:@"fragmentShader"]; 85 | 86 | MTLRenderPipelineDescriptor *pipelineStateDescriptor = [[MTLRenderPipelineDescriptor alloc] init]; 87 | pipelineStateDescriptor.label = @"MyPipeline"; 88 | pipelineStateDescriptor.sampleCount = view.sampleCount; 89 | pipelineStateDescriptor.vertexFunction = vertexFunction; 90 | pipelineStateDescriptor.fragmentFunction = fragmentFunction; 91 | pipelineStateDescriptor.vertexDescriptor = _mtlVertexDescriptor; 92 | pipelineStateDescriptor.colorAttachments[0].pixelFormat = view.colorPixelFormat; 93 | pipelineStateDescriptor.depthAttachmentPixelFormat = view.depthStencilPixelFormat; 94 | pipelineStateDescriptor.stencilAttachmentPixelFormat = view.depthStencilPixelFormat; 95 | 96 | NSError *error = NULL; 97 | _pipelineState = [_device newRenderPipelineStateWithDescriptor:pipelineStateDescriptor error:&error]; 98 | if (!_pipelineState) 99 | { 100 | NSLog(@"Failed to created pipeline state, error %@", error); 101 | } 102 | 103 | MTLDepthStencilDescriptor *depthStateDesc = [[MTLDepthStencilDescriptor alloc] init]; 104 | depthStateDesc.depthCompareFunction = MTLCompareFunctionLess; 105 | depthStateDesc.depthWriteEnabled = YES; 106 | _depthState = [_device newDepthStencilStateWithDescriptor:depthStateDesc]; 107 | 108 | for(NSUInteger i = 0; i < MaxBuffersInFlight; i++) 109 | { 110 | _dynamicUniformBuffer[i] = [_device newBufferWithLength:sizeof(Uniforms) 111 | options:MTLResourceStorageModeShared]; 112 | 113 | _dynamicUniformBuffer[i].label = @"UniformBuffer"; 114 | } 115 | 116 | _commandQueue = [_device newCommandQueue]; 117 | } 118 | 119 | - (void)_loadAssets 120 | { 121 | /// Load assets into metal objects 122 | 123 | NSError *error; 124 | 125 | MTKMeshBufferAllocator *metalAllocator = [[MTKMeshBufferAllocator alloc] 126 | initWithDevice: _device]; 127 | 128 | MDLMesh *mdlMesh = [MDLMesh newBoxWithDimensions:(vector_float3){4, 4, 4} 129 | segments:(vector_uint3){2, 2, 2} 130 | geometryType:MDLGeometryTypeTriangles 131 | inwardNormals:NO 132 | allocator:metalAllocator]; 133 | 134 | MDLVertexDescriptor *mdlVertexDescriptor = 135 | MTKModelIOVertexDescriptorFromMetal(_mtlVertexDescriptor); 136 | 137 | mdlVertexDescriptor.attributes[VertexAttributePosition].name = MDLVertexAttributePosition; 138 | mdlVertexDescriptor.attributes[VertexAttributeTexcoord].name = MDLVertexAttributeTextureCoordinate; 139 | 140 | mdlMesh.vertexDescriptor = mdlVertexDescriptor; 141 | 142 | _mesh = [[MTKMesh alloc] initWithMesh:mdlMesh 143 | device:_device 144 | error:&error]; 145 | 146 | if(!_mesh || error) 147 | { 148 | NSLog(@"Error creating MetalKit mesh %@", error.localizedDescription); 149 | } 150 | 151 | MTKTextureLoader* textureLoader = [[MTKTextureLoader alloc] initWithDevice:_device]; 152 | 153 | NSDictionary *textureLoaderOptions = 154 | @{ 155 | MTKTextureLoaderOptionTextureUsage : @(MTLTextureUsageShaderRead), 156 | MTKTextureLoaderOptionTextureStorageMode : @(MTLStorageModePrivate) 157 | }; 158 | 159 | _colorMap = [textureLoader newTextureWithName:@"ColorMap" 160 | scaleFactor:1.0 161 | bundle:nil 162 | options:textureLoaderOptions 163 | error:&error]; 164 | 165 | if(!_colorMap || error) 166 | { 167 | NSLog(@"Error creating texture %@", error.localizedDescription); 168 | } 169 | } 170 | 171 | - (void)_updateGameState 172 | { 173 | /// Update any game state before encoding renderint commands to our drawable 174 | 175 | Uniforms * uniforms = (Uniforms*)_dynamicUniformBuffer[_uniformBufferIndex].contents; 176 | 177 | uniforms->projectionMatrix = _projectionMatrix; 178 | 179 | vector_float3 rotationAxis = {1, 1, 0}; 180 | matrix_float4x4 modelMatrix = matrix4x4_rotation(_rotation, rotationAxis); 181 | matrix_float4x4 viewMatrix = matrix4x4_translation(0.0, 0.0, -8.0); 182 | 183 | uniforms->modelViewMatrix = matrix_multiply(viewMatrix, modelMatrix); 184 | 185 | _rotation += .01; 186 | } 187 | 188 | - (void)drawInMTKView:(nonnull MTKView *)view 189 | { 190 | /// Per frame updates here 191 | 192 | dispatch_semaphore_wait(_inFlightSemaphore, DISPATCH_TIME_FOREVER); 193 | 194 | _uniformBufferIndex = (_uniformBufferIndex + 1) % MaxBuffersInFlight; 195 | 196 | id commandBuffer = [_commandQueue commandBuffer]; 197 | commandBuffer.label = @"MyCommand"; 198 | 199 | __block dispatch_semaphore_t block_sema = _inFlightSemaphore; 200 | [commandBuffer addCompletedHandler:^(id buffer) 201 | { 202 | dispatch_semaphore_signal(block_sema); 203 | }]; 204 | 205 | [self _updateGameState]; 206 | 207 | /// Delay getting the currentRenderPassDescriptor until absolutely needed. This avoids 208 | /// holding onto the drawable and blocking the display pipeline any longer than necessary 209 | MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor; 210 | 211 | if(renderPassDescriptor != nil) 212 | { 213 | /// Final pass rendering code here 214 | 215 | id renderEncoder = 216 | [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; 217 | renderEncoder.label = @"MyRenderEncoder"; 218 | 219 | [renderEncoder pushDebugGroup:@"DrawBox"]; 220 | 221 | [renderEncoder setFrontFacingWinding:MTLWindingCounterClockwise]; 222 | [renderEncoder setCullMode:MTLCullModeBack]; 223 | [renderEncoder setRenderPipelineState:_pipelineState]; 224 | [renderEncoder setDepthStencilState:_depthState]; 225 | 226 | [renderEncoder setVertexBuffer:_dynamicUniformBuffer[_uniformBufferIndex] 227 | offset:0 228 | atIndex:BufferIndexUniforms]; 229 | 230 | [renderEncoder setFragmentBuffer:_dynamicUniformBuffer[_uniformBufferIndex] 231 | offset:0 232 | atIndex:BufferIndexUniforms]; 233 | 234 | for (NSUInteger bufferIndex = 0; bufferIndex < _mesh.vertexBuffers.count; bufferIndex++) 235 | { 236 | MTKMeshBuffer *vertexBuffer = _mesh.vertexBuffers[bufferIndex]; 237 | if((NSNull*)vertexBuffer != [NSNull null]) 238 | { 239 | [renderEncoder setVertexBuffer:vertexBuffer.buffer 240 | offset:vertexBuffer.offset 241 | atIndex:bufferIndex]; 242 | } 243 | } 244 | 245 | [renderEncoder setFragmentTexture:_colorMap 246 | atIndex:TextureIndexColor]; 247 | 248 | for(MTKSubmesh *submesh in _mesh.submeshes) 249 | { 250 | [renderEncoder drawIndexedPrimitives:submesh.primitiveType 251 | indexCount:submesh.indexCount 252 | indexType:submesh.indexType 253 | indexBuffer:submesh.indexBuffer.buffer 254 | indexBufferOffset:submesh.indexBuffer.offset]; 255 | } 256 | 257 | [renderEncoder popDebugGroup]; 258 | 259 | [renderEncoder endEncoding]; 260 | 261 | [commandBuffer presentDrawable:view.currentDrawable]; 262 | } 263 | 264 | [commandBuffer commit]; 265 | } 266 | 267 | - (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size 268 | { 269 | /// Respond to drawable size or orientation changes here 270 | 271 | float aspect = size.width / (float)size.height; 272 | _projectionMatrix = matrix_perspective_right_hand(65.0f * (M_PI / 180.0f), aspect, 0.1f, 100.0f); 273 | } 274 | 275 | #pragma mark Matrix Math Utilities 276 | 277 | matrix_float4x4 matrix4x4_translation(float tx, float ty, float tz) 278 | { 279 | return (matrix_float4x4) {{ 280 | { 1, 0, 0, 0 }, 281 | { 0, 1, 0, 0 }, 282 | { 0, 0, 1, 0 }, 283 | { tx, ty, tz, 1 } 284 | }}; 285 | } 286 | 287 | static matrix_float4x4 matrix4x4_rotation(float radians, vector_float3 axis) 288 | { 289 | axis = vector_normalize(axis); 290 | float ct = cosf(radians); 291 | float st = sinf(radians); 292 | float ci = 1 - ct; 293 | float x = axis.x, y = axis.y, z = axis.z; 294 | 295 | return (matrix_float4x4) {{ 296 | { ct + x * x * ci, y * x * ci + z * st, z * x * ci - y * st, 0}, 297 | { x * y * ci - z * st, ct + y * y * ci, z * y * ci + x * st, 0}, 298 | { x * z * ci + y * st, y * z * ci - x * st, ct + z * z * ci, 0}, 299 | { 0, 0, 0, 1} 300 | }}; 301 | } 302 | 303 | matrix_float4x4 matrix_perspective_right_hand(float fovyRadians, float aspect, float nearZ, float farZ) 304 | { 305 | float ys = 1 / tanf(fovyRadians * 0.5); 306 | float xs = ys / aspect; 307 | float zs = farZ / (nearZ - farZ); 308 | 309 | return (matrix_float4x4) {{ 310 | { xs, 0, 0, 0 }, 311 | { 0, ys, 0, 0 }, 312 | { 0, 0, zs, -1 }, 313 | { 0, 0, nearZ * zs, 0 } 314 | }}; 315 | } 316 | 317 | @end 318 | -------------------------------------------------------------------------------- /Example/GPUUtilization/ShaderTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShaderTypes.h 3 | // metal 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | // 10 | // Header containing types and enum constants shared between Metal shaders and Swift/ObjC source 11 | // 12 | #ifndef ShaderTypes_h 13 | #define ShaderTypes_h 14 | 15 | #ifdef __METAL_VERSION__ 16 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 17 | #define NSInteger metal::int32_t 18 | #else 19 | #import 20 | #endif 21 | 22 | #include 23 | 24 | typedef NS_ENUM(NSInteger, BufferIndex) 25 | { 26 | BufferIndexMeshPositions = 0, 27 | BufferIndexMeshGenerics = 1, 28 | BufferIndexUniforms = 2 29 | }; 30 | 31 | typedef NS_ENUM(NSInteger, VertexAttribute) 32 | { 33 | VertexAttributePosition = 0, 34 | VertexAttributeTexcoord = 1, 35 | }; 36 | 37 | typedef NS_ENUM(NSInteger, TextureIndex) 38 | { 39 | TextureIndexColor = 0, 40 | }; 41 | 42 | typedef struct 43 | { 44 | matrix_float4x4 projectionMatrix; 45 | matrix_float4x4 modelViewMatrix; 46 | } Uniforms; 47 | 48 | #endif /* ShaderTypes_h */ 49 | 50 | -------------------------------------------------------------------------------- /Example/GPUUtilization/Shaders.metal: -------------------------------------------------------------------------------- 1 | // 2 | // Shaders.metal 3 | // metal 4 | // 5 | // Created by Ricky on 2018/9/20. 6 | // Copyright © 2018年 rickytan. All rights reserved. 7 | // 8 | 9 | // File for Metal kernel and shader functions 10 | 11 | #include 12 | #include 13 | 14 | // Including header shared between this Metal shader code and Swift/C code executing Metal API commands 15 | #import "ShaderTypes.h" 16 | 17 | using namespace metal; 18 | 19 | typedef struct 20 | { 21 | float3 position [[attribute(VertexAttributePosition)]]; 22 | float2 texCoord [[attribute(VertexAttributeTexcoord)]]; 23 | } Vertex; 24 | 25 | typedef struct 26 | { 27 | float4 position [[position]]; 28 | float2 texCoord; 29 | } ColorInOut; 30 | 31 | vertex ColorInOut vertexShader(Vertex in [[stage_in]], 32 | constant Uniforms & uniforms [[ buffer(BufferIndexUniforms) ]]) 33 | { 34 | ColorInOut out; 35 | 36 | float4 position = float4(in.position, 1.0); 37 | out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * position; 38 | out.texCoord = in.texCoord; 39 | 40 | return out; 41 | } 42 | 43 | fragment float4 fragmentShader(ColorInOut in [[stage_in]], 44 | constant Uniforms & uniforms [[ buffer(BufferIndexUniforms) ]], 45 | texture2d colorMap [[ texture(TextureIndexColor) ]]) 46 | { 47 | constexpr sampler colorSampler(mip_filter::linear, 48 | mag_filter::linear, 49 | min_filter::linear); 50 | 51 | half4 colorSample = colorMap.sample(colorSampler, in.texCoord.xy); 52 | 53 | return float4(colorSample); 54 | } 55 | -------------------------------------------------------------------------------- /Example/GPUUtilization/art.scnassets/ship.scn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickytan/GPUUtilization/8a156fd8ddc968df809b5eaa4ae68f1ab8b0cd27/Example/GPUUtilization/art.scnassets/ship.scn -------------------------------------------------------------------------------- /Example/GPUUtilization/art.scnassets/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickytan/GPUUtilization/8a156fd8ddc968df809b5eaa4ae68f1ab8b0cd27/Example/GPUUtilization/art.scnassets/texture.png -------------------------------------------------------------------------------- /Example/GPUUtilization/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/GPUUtilization/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // GPUUtilization 4 | // 5 | // Created by rickytan on 09/20/2018. 6 | // Copyright (c) 2018 rickytan. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | #import "RTAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([RTAppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'GPUUtilization_Example' do 4 | pod 'GPUUtilization', :path => '../' 5 | 6 | target 'GPUUtilization_Tests' do 7 | inherit! :search_paths 8 | 9 | 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - GPUUtilization (0.1.0) 3 | 4 | DEPENDENCIES: 5 | - GPUUtilization (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | GPUUtilization: 9 | :path: "../" 10 | 11 | SPEC CHECKSUMS: 12 | GPUUtilization: 7a3d4547340036421623e13833156920f6b1fdd9 13 | 14 | PODFILE CHECKSUM: 3694ed88f5d3e13ad2e72c26dd20319b351c1989 15 | 16 | COCOAPODS: 1.5.3 17 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // The contents of this file are implicitly included at the beginning of every test case source file. 2 | 3 | #ifdef __OBJC__ 4 | 5 | 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /Example/Tests/Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GPUUtilizationTests.m 3 | // GPUUtilizationTests 4 | // 5 | // Created by rickytan on 09/20/2018. 6 | // Copyright (c) 2018 rickytan. All rights reserved. 7 | // 8 | 9 | @import XCTest; 10 | 11 | @interface Tests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation Tests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /Example/Tests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GPUUtilization.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint GPUUtilization.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'GPUUtilization' 11 | s.version = '0.5.0' 12 | s.summary = 'measure GPU hardware utilization on iOS Devices' 13 | 14 | s.description = <<-DESC 15 | This project is used to measure GPU Usage on iOS Devices within apps. 16 | DESC 17 | 18 | s.homepage = 'https://github.com/rickytan/GPUUtilization' 19 | s.license = { :type => 'MIT', :file => 'LICENSE' } 20 | s.author = { 'rickytan' => 'ricky.tan.xin@gmail.com' } 21 | s.source = { :git => 'https://github.com/rickytan/GPUUtilization.git', :tag => s.version.to_s } 22 | 23 | s.ios.deployment_target = '8.0' 24 | s.source_files = 'GPUUtilization/Classes/*' 25 | s.private_header_files = 'GPUUtilization/Classes/IOKit.h' 26 | s.frameworks = 'UIKit', 'IOKit' 27 | end 28 | -------------------------------------------------------------------------------- /GPUUtilization/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickytan/GPUUtilization/8a156fd8ddc968df809b5eaa4ae68f1ab8b0cd27/GPUUtilization/Assets/.gitkeep -------------------------------------------------------------------------------- /GPUUtilization/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickytan/GPUUtilization/8a156fd8ddc968df809b5eaa4ae68f1ab8b0cd27/GPUUtilization/Classes/.gitkeep -------------------------------------------------------------------------------- /GPUUtilization/Classes/GPUUtilization.h: -------------------------------------------------------------------------------- 1 | // GPUUtilization.h 2 | // 3 | // Copyright (c) 2018年 xcoder.tips 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #ifndef NS_NOESCAPE 26 | #define NS_NOESCAPE 27 | #endif 28 | 29 | /** 30 | @warning DO NOT INTEGRATE THIS IN APPSTORE VERSION, it will be @b rejected! 31 | */ 32 | @interface GPUUtilization : NSObject 33 | @property (nonatomic, readonly) NSInteger deviceUtilization; // percent 34 | @property (nonatomic, readonly) NSInteger rendererUtilization; // percent 35 | @property (nonatomic, readonly) NSInteger tilerUtilization; // percent 36 | @property (nonatomic, readonly) int64_t hardwareWaitTime; // nano second 37 | @property (nonatomic, readonly) int64_t finishGLWaitTime; // nano second 38 | @property (nonatomic, readonly) int64_t freeToAllocGPUAddressWaitTime; // nano second 39 | @property (nonatomic, readonly) NSInteger contextGLCount; 40 | @property (nonatomic, readonly) NSInteger renderCount; 41 | @property (nonatomic, readonly) NSInteger recoveryCount; 42 | @property (nonatomic, readonly) NSInteger textureCount; 43 | #if __has_feature(objc_class_property) 44 | @property (nonatomic, class, readonly) float gpuUsage; 45 | #else 46 | + (float)gpuUsage; 47 | #endif 48 | 49 | + (void)fetchCurrentUtilization:(void(NS_NOESCAPE^)(GPUUtilization *current))block; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /GPUUtilization/Classes/GPUUtilization.m: -------------------------------------------------------------------------------- 1 | // GPUUtilization.m 2 | // 3 | // Copyright (c) 2018年 xcoder.tips 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "GPUUtilization.h" 24 | #import "IOKit.h" 25 | 26 | 27 | const char *kIOServicePlane = "IOService"; 28 | 29 | #define GPU_UTILI_KEY(key, value) static NSString * const GPU ## key ##Key = @#value; 30 | 31 | GPU_UTILI_KEY(DeviceUtilization, Device Utilization %) 32 | GPU_UTILI_KEY(RendererUtilization, Renderer Utilization %) 33 | GPU_UTILI_KEY(TilerUtilization, Tiler Utilization %) 34 | GPU_UTILI_KEY(HardwareWaitTime, hardwareWaitTime) 35 | GPU_UTILI_KEY(FinishGLWaitTime, finishGLWaitTime) 36 | GPU_UTILI_KEY(FreeToAllocGPUAddressWaitTime, freeToAllocGPUAddressWaitTime) 37 | GPU_UTILI_KEY(ContextGLCount, contextGLCount) 38 | GPU_UTILI_KEY(RenderCount, CommandBufferRenderCount) 39 | GPU_UTILI_KEY(RecoveryCount, recoveryCount) 40 | GPU_UTILI_KEY(TextureCount, textureCount) 41 | 42 | @implementation GPUUtilization 43 | { 44 | NSDictionary * _utilizationInfo; 45 | } 46 | 47 | + (NSDictionary *)utilizeDictionary 48 | { 49 | NSDictionary *dictionary = nil; 50 | 51 | io_iterator_t iterator; 52 | #if TARGET_IPHONE_SIMULATOR 53 | 54 | if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching("IntelAccelerator"), &iterator) == kIOReturnSuccess) { 55 | 56 | for (io_registry_entry_t regEntry = IOIteratorNext(iterator); regEntry; regEntry = IOIteratorNext(iterator)) { 57 | CFMutableDictionaryRef serviceDictionary; 58 | if (IORegistryEntryCreateCFProperties(regEntry, &serviceDictionary, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { 59 | IOObjectRelease(regEntry); 60 | continue; 61 | } 62 | 63 | dictionary = ((__bridge NSDictionary *)serviceDictionary)[@"PerformanceStatistics"]; 64 | 65 | CFRelease(serviceDictionary); 66 | IOObjectRelease(regEntry); 67 | break; 68 | } 69 | IOObjectRelease(iterator); 70 | } 71 | 72 | #elif TARGET_OS_IOS 73 | if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceNameMatching("sgx"), &iterator) == kIOReturnSuccess) { 74 | 75 | for (io_registry_entry_t regEntry = IOIteratorNext(iterator); regEntry; regEntry = IOIteratorNext(iterator)) { 76 | 77 | io_iterator_t innerIterator; 78 | if (IORegistryEntryGetChildIterator(regEntry, kIOServicePlane, &innerIterator) == kIOReturnSuccess) { 79 | 80 | for (io_registry_entry_t gpuEntry = IOIteratorNext(innerIterator); gpuEntry ; gpuEntry = IOIteratorNext(innerIterator)) { 81 | CFMutableDictionaryRef serviceDictionary; 82 | if (IORegistryEntryCreateCFProperties(gpuEntry, &serviceDictionary, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) { 83 | IOObjectRelease(gpuEntry); 84 | continue; 85 | } 86 | else { 87 | dictionary = ((__bridge NSDictionary *)serviceDictionary)[@"PerformanceStatistics"]; 88 | 89 | CFRelease(serviceDictionary); 90 | IOObjectRelease(gpuEntry); 91 | break; 92 | } 93 | } 94 | IOObjectRelease(innerIterator); 95 | IOObjectRelease(regEntry); 96 | break; 97 | } 98 | IOObjectRelease(regEntry); 99 | } 100 | IOObjectRelease(iterator); 101 | } 102 | #endif 103 | 104 | return dictionary; 105 | } 106 | 107 | + (float)gpuUsage 108 | { 109 | return [[self utilizeDictionary][GPUDeviceUtilizationKey] floatValue]; 110 | } 111 | 112 | + (GPUUtilization *)current 113 | { 114 | return [[self alloc] initWithDictionary:[self utilizeDictionary]]; 115 | } 116 | 117 | + (void)fetchCurrentUtilization:(NS_NOESCAPE void (^)(GPUUtilization *))block 118 | { 119 | !block ?: block([self current]); 120 | } 121 | 122 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary 123 | { 124 | self = [super init]; 125 | if (self) { 126 | _utilizationInfo = [dictionary copy]; 127 | } 128 | return self; 129 | } 130 | 131 | - (NSInteger)deviceUtilization 132 | { 133 | return [_utilizationInfo[GPUDeviceUtilizationKey] integerValue]; 134 | } 135 | 136 | - (NSInteger)rendererUtilization 137 | { 138 | return [_utilizationInfo[GPURendererUtilizationKey] integerValue]; 139 | } 140 | 141 | - (NSInteger)tilerUtilization 142 | { 143 | return [_utilizationInfo[GPUTilerUtilizationKey] integerValue]; 144 | } 145 | 146 | - (int64_t)hardwareWaitTime 147 | { 148 | return [_utilizationInfo[GPUHardwareWaitTimeKey] longLongValue]; 149 | } 150 | 151 | - (int64_t)finishGLWaitTime 152 | { 153 | return [_utilizationInfo[GPUFinishGLWaitTimeKey] longLongValue]; 154 | } 155 | 156 | - (int64_t)freeToAllocGPUAddressWaitTime 157 | { 158 | return [_utilizationInfo[GPUFreeToAllocGPUAddressWaitTimeKey] longLongValue]; 159 | } 160 | 161 | - (NSInteger)contextGLCount 162 | { 163 | return [_utilizationInfo[GPUContextGLCountKey] integerValue]; 164 | } 165 | 166 | - (NSInteger)renderCount 167 | { 168 | return [_utilizationInfo[GPURenderCountKey] integerValue]; 169 | } 170 | 171 | - (NSInteger)recoveryCount 172 | { 173 | return [_utilizationInfo[GPURecoveryCountKey] integerValue]; 174 | } 175 | 176 | - (NSInteger)textureCount 177 | { 178 | return [_utilizationInfo[GPUTextureCountKey] integerValue]; 179 | } 180 | 181 | @end 182 | -------------------------------------------------------------------------------- /GPUUtilization/Classes/IOKit.h: -------------------------------------------------------------------------------- 1 | #ifndef IOKIT_H 2 | #define IOKIT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | typedef char io_name_t[128]; 9 | typedef char io_string_t[512]; 10 | typedef char io_struct_inband_t[4096]; 11 | typedef mach_port_t io_object_t; 12 | typedef io_object_t io_registry_entry_t; 13 | typedef io_object_t io_service_t; 14 | typedef io_object_t io_connect_t; 15 | typedef io_object_t io_iterator_t; 16 | 17 | enum 18 | { 19 | kIOCFSerializeToBinary = 0x00000001U, 20 | }; 21 | 22 | enum 23 | { 24 | kIOReturnSuccess = 0, 25 | }; 26 | 27 | enum 28 | { 29 | kIORegistryIterateRecursively = 0x00000001U, 30 | kIORegistryIterateParents = 0x00000002U, 31 | }; 32 | 33 | enum 34 | { 35 | kOSSerializeDictionary = 0x01000000U, 36 | kOSSerializeArray = 0x02000000U, 37 | kOSSerializeSet = 0x03000000U, 38 | kOSSerializeNumber = 0x04000000U, 39 | kOSSerializeSymbol = 0x08000000U, 40 | kOSSerializeString = 0x09000000U, 41 | kOSSerializeData = 0x0a000000U, 42 | kOSSerializeBoolean = 0x0b000000U, 43 | kOSSerializeObject = 0x0c000000U, 44 | 45 | kOSSerializeTypeMask = 0x7F000000U, 46 | kOSSerializeDataMask = 0x00FFFFFFU, 47 | 48 | kOSSerializeEndCollection = 0x80000000U, 49 | 50 | kOSSerializeMagic = 0x000000d3U, 51 | }; 52 | 53 | extern const mach_port_t kIOMasterPortDefault; 54 | 55 | CF_RETURNS_RETAINED CFDataRef IOCFSerialize(CFTypeRef object, CFOptionFlags options); 56 | CFTypeRef IOCFUnserializeWithSize(const char *buf, size_t len, CFAllocatorRef allocator, CFOptionFlags options, CFStringRef *err); 57 | 58 | kern_return_t IOObjectRetain(io_object_t object); 59 | kern_return_t IOObjectRelease(io_object_t object); 60 | boolean_t IOObjectConformsTo(io_object_t object, const io_name_t name); 61 | uint32_t IOObjectGetKernelRetainCount(io_object_t object); 62 | kern_return_t IOObjectGetClass(io_object_t object, io_name_t name); 63 | CFStringRef IOObjectCopyClass(io_object_t object); 64 | CFStringRef IOObjectCopySuperclassForClass(CFStringRef name); 65 | CFStringRef IOObjectCopyBundleIdentifierForClass(CFStringRef name); 66 | 67 | io_registry_entry_t IORegistryGetRootEntry(mach_port_t master); 68 | kern_return_t IORegistryEntryGetName(io_registry_entry_t entry, io_name_t name); 69 | kern_return_t IORegistryEntryGetRegistryEntryID(io_registry_entry_t entry, uint64_t *entryID); 70 | kern_return_t IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path); 71 | kern_return_t IORegistryEntryGetProperty(io_registry_entry_t entry, const io_name_t name, io_struct_inband_t buffer, uint32_t *size); 72 | kern_return_t IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, uint32_t options); 73 | CFTypeRef IORegistryEntryCreateCFProperty(io_registry_entry_t entry, CFStringRef key, CFAllocatorRef allocator, uint32_t options); 74 | kern_return_t IORegistryEntrySetCFProperties(io_registry_entry_t entry, CFTypeRef properties); 75 | 76 | kern_return_t IORegistryCreateIterator(mach_port_t master, const io_name_t plane, uint32_t options, io_iterator_t *it); 77 | kern_return_t IORegistryEntryCreateIterator(io_registry_entry_t entry, const io_name_t plane, uint32_t options, io_iterator_t *it); 78 | kern_return_t IORegistryEntryGetChildIterator(io_registry_entry_t entry, const io_name_t plane, io_iterator_t *it); 79 | kern_return_t IORegistryEntryGetParentIterator(io_registry_entry_t entry, const io_name_t plane, io_iterator_t *it); 80 | io_object_t IOIteratorNext(io_iterator_t it); 81 | boolean_t IOIteratorIsValid(io_iterator_t it); 82 | void IOIteratorReset(io_iterator_t it); 83 | 84 | CFMutableDictionaryRef IOServiceMatching(const char *name) CF_RETURNS_RETAINED; 85 | CFMutableDictionaryRef IOServiceNameMatching(const char *name) CF_RETURNS_RETAINED; 86 | io_service_t IOServiceGetMatchingService(mach_port_t master, CFDictionaryRef matching CF_RELEASES_ARGUMENT); 87 | kern_return_t IOServiceGetMatchingServices(mach_port_t master, CFDictionaryRef matching CF_RELEASES_ARGUMENT, io_iterator_t *it); 88 | kern_return_t _IOServiceGetAuthorizationID(io_service_t service, uint64_t *authID); 89 | kern_return_t _IOServiceSetAuthorizationID(io_service_t service, uint64_t authID); 90 | kern_return_t IOServiceOpen(io_service_t service, task_t task, uint32_t type, io_connect_t *client); 91 | kern_return_t IOServiceClose(io_connect_t client); 92 | kern_return_t IOCloseConnection(io_connect_t client); 93 | kern_return_t IOConnectAddRef(io_connect_t client); 94 | kern_return_t IOConnectRelease(io_connect_t client); 95 | kern_return_t IOConnectGetService(io_connect_t client, io_service_t *service); 96 | kern_return_t IOConnectAddClient(io_connect_t client, io_connect_t other); 97 | kern_return_t IOConnectSetNotificationPort(io_connect_t client, uint32_t type, mach_port_t port, uintptr_t ref); 98 | kern_return_t IOConnectMapMemory64(io_connect_t client, uint32_t type, task_t task, mach_vm_address_t *addr, mach_vm_size_t *size, uint32_t options); 99 | kern_return_t IOConnectUnmapMemory64(io_connect_t client, uint32_t type, task_t task, mach_vm_address_t addr); 100 | kern_return_t IOConnectSetCFProperties(io_connect_t client, CFTypeRef properties); 101 | kern_return_t IOConnectCallMethod(io_connect_t client, uint32_t selector, const uint64_t *in, uint32_t inCnt, const void *inStruct, size_t inStructCnt, uint64_t *out, uint32_t *outCnt, void *outStruct, size_t *outStructCnt); 102 | kern_return_t IOConnectCallScalarMethod(io_connect_t client, uint32_t selector, const uint64_t *in, uint32_t inCnt, uint64_t *out, uint32_t *outCnt); 103 | kern_return_t IOConnectCallStructMethod(io_connect_t client, uint32_t selector, const void *inStruct, size_t inStructCnt, void *outStruct, size_t *outStructCnt); 104 | kern_return_t IOConnectCallAsyncMethod(io_connect_t client, uint32_t selector, mach_port_t wake_port, uint64_t *ref, uint32_t refCnt, const uint64_t *in, uint32_t inCnt, const void *inStruct, size_t inStructCnt, uint64_t *out, uint32_t *outCnt, void *outStruct, size_t *outStructCnt); 105 | kern_return_t IOConnectCallAsyncScalarMethod(io_connect_t client, uint32_t selector, mach_port_t wake_port, uint64_t *ref, uint32_t refCnt, const uint64_t *in, uint32_t inCnt, uint64_t *out, uint32_t *outCnt); 106 | kern_return_t IOConnectCallAsyncStructMethod(io_connect_t client, uint32_t selector, mach_port_t wake_port, uint64_t *ref, uint32_t refCnt, const void *inStruct, size_t inStructCnt, void *outStruct, size_t *outStructCnt); 107 | kern_return_t IOConnectTrap6(io_connect_t client, uint32_t index, uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d, uintptr_t e, uintptr_t f); 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 rickytan 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GPUUtilization 2 | 3 | [![CI Status](https://img.shields.io/travis/rickytan/GPUUtilization.svg?style=flat)](https://travis-ci.org/rickytan/GPUUtilization) 4 | [![Version](https://img.shields.io/cocoapods/v/GPUUtilization.svg?style=flat)](https://cocoapods.org/pods/GPUUtilization) 5 | [![License](https://img.shields.io/cocoapods/l/GPUUtilization.svg?style=flat)](https://cocoapods.org/pods/GPUUtilization) 6 | [![Platform](https://img.shields.io/cocoapods/p/GPUUtilization.svg?style=flat)](https://cocoapods.org/pods/GPUUtilization) 7 | 8 | This project calls methods from `IOKit` to get the realtime GPU utilization of a iOS device, it maybe helpful for debug usage. 9 | 10 | **Warning:!!!** 11 | > Do not integrate this on a Appstore version, you will be REJECTED. 12 | 13 | ![img_1584](https://user-images.githubusercontent.com/1250207/45858576-a5d5e980-bd90-11e8-812d-9ee089709900.PNG) 14 | 15 | ![img_1585](https://user-images.githubusercontent.com/1250207/45858577-a5d5e980-bd90-11e8-8687-e391954acb4a.PNG) 16 | 17 | ## Installation 18 | 19 | GPUUtilization is available through [CocoaPods](https://cocoapods.org). To install 20 | it, simply add the following line to your Podfile: 21 | 22 | ```ruby 23 | pod 'GPUUtilization', :configurations => ['Debug'] 24 | ``` 25 | 26 | ## Author 27 | 28 | rickytan, ricky.tan.xin@gmail.com 29 | 30 | ## License 31 | 32 | GPUUtilization is available under the MIT license. See the LICENSE file for more info. 33 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------