Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shu223
February 22, 2018
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍しているのか #potatotips
potatotips #48 (iOS/Android開発Tips共有会)での発表資料です。
https://potatotips.connpass.com/event/77702/
shu223
February 22, 2018
More Decks by shu223
See All by shu223
slidify-sample
shu223
1
1.6k
機械学習のブルーオーシャン Core ML by 堤 修一 #iOSDC Japan 2020
shu223
12
5.9k
エンジニアのための発信講座 #4 登壇しよう
shu223
0
160
エンジニアのための発信講座 #3
shu223
0
150
エンジニアのための発信講座 #2
shu223
2
270
エンジニアのための発信講座 #1
shu223
1
1k
今こそwatchOS #iosdc
shu223
5
11k
Depth in Depth #iOSDC
shu223
4
31k
技術書のジレンマとPEAKS + 書評ブログを書くTips #iOS11book
shu223
18
6k
Other Decks in Programming
See All in Programming
今さら聞けない .NET CLI
htkym
0
190
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.2k
仕様駆動開発の消費期限
watany
20
7.7k
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
380
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
880
プロポーザルを書いてもらう
pvcresin
0
300
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
React本体のコードリーディング
high_g_engineer
1
140
Go 1.27 における memory allocation の高速化
andpad
0
140
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
250
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
270
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
240
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
Speed Design
sergeychernyshev
33
2k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Visualization
eitanlees
152
17k
BBQ
matthewcrist
89
10k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
Measuring & Analyzing Core Web Vitals
bluesmoon
9
950
Transcript
Metal Accelerated͔Ͳ͏͔ΛௐΔํ๏ ͋ͳͨͷΞϓϦͷͲ͜ͰMetal͕҉༂͍ͯ͠Δͷ͔ Shuichi Tsutsumi @shu223
None
WWDC17ͷ͜ͷਤͰɺUIKitΛؚΉ ଟ͘ͷϑϨʔϜϫʔΫ͕෦Ͱ MetalΛ༻͍͍ͯΔ͜ͱ͕Θ͔ͬͨ
͕ɺ
ࡉ͔͍͜ͱ·Ͱ৭ʑͱΘ͔Βͳ͍ • UIKitͷԼճΓ͍͔ͭΒMetalʹͳͬͨͷ͔ʁ • UIKitͷͲͷॲཧ͕Metal AcceleratedͰɺͲͷॲཧ͕ͦ͏͡Όͳ͍ͷ͔ʁ • OpenGLʢiOSͰʣࠓMetalͷ্ʹ࣮͞Ε͍ͯΔͱAppleͷਓ͕WWDC ͷϥϘͰݴ͚ͬͯͨͲɺެࣜใͳ͍ •
2014ͷWWDCͰCore AnimationͷϨΠϠʹ͍ͭͯղઆ͕͋Δ͚Ͳɺ͜ ΕͬͯͲ͔͜ΒͲ͜·Ͱ͕ࠓ༗ޮͳใͳͷ͔ʁ • etc.
AppleͷެࣜใཔΈ • API Reference • Programming Guide • Forum •
WWDC Session • ʮWWDC LabͰதͷਓ͕ݴͬͯͨʯ ͔͠ɾɾɾ ͕࣌ؒܦͭͱɺެࣜใͰϝϯς͞Ε͍ͯͳ͍ͷূڌͱͯ͠ෆेʹͳΔ
ʮཪऔΓʯେมˍ͍͠
ʮMetal Accelerated͔Ͳ͏͔ʯ ΛࣗͰௐΒΕͳ͍͔ʁ
Metal Accelerated͔Ͳ͏͔ΛͳͥΓ͍ͨͷ͔ʁ • தͷਓʹΑͬͯϝϯς͞Ε͍ͯͯɺ࠷దԽ͞Ε͍ͯΔ͜ͱ͕Θ͔Δ • ࣗͷ࠷దԽख๏͕ద͔Ͳ͏͔ͷஅࡐྉʹͳΔ • ϨΠϠʹ౿ΈࠐΜͰࣗલ࣮͢Δ͔Ͳ͏͔ͷஅࡐྉʹͳΔ
XcodeͷGPU Reportʁ
MetalΛ໌ࣔతʹར༻͍ͯ͠ͳ͍ͱɺ XcodeͷGPU Reportग़ͯ͜ͳ͍
ͦ͜ͰInstruments
Metal System Trace
UIKit͔ͬͯ͠ͳ͍ʢʹMetalͬͯͳ͍ʣ ΞϓϦͰࢼͯ͠ΈΔ
τϨʔεͰ͖ͯΔʂ
UIKitͷԼͰʮ҉తʹʯΘΕ͍ͯΔ MetalͷଉਧΛײ͡Δ͜ͱ͕Ͱ͖Δʂ
࣌ܥྻํʹ֦େͯ͠ΈΔ
ͬ͘͟Γͨ͠ݟํ GPUͰ࣮ߦ͢ΔίϚϯυͷ࡞ʢonCPUʣ GPUίϚϯυΛૹ৴ʢon CPUʣ γΣʔμͷ࣮ߦʢon GPUʣ σΟεϓϨΠͷඳը CPUͰͷॲཧ → GPUͰͷॲཧ
→ ը໘දࣔ ͷҰ࿈ͷྲྀΕͱෛՙ͕ՄࢹԽ͞Ε͍ͯΔ
“Launching” Comand Buffer (SpringBoard) ͦͷޙඳըλεΫͳ͠ ʢUIKitඞཁ͕ͳ͚Εߋ৽ॲཧΛ͠ͳ͍ʣ “Foreground” ͜ͷ͋ͨΓΞϓϦىಈ࣌ͷඳը ॲཧͬΆ͍
ϘλϯΛԡͨ͠ΒUIImageViewͰը૾Λදࣔ͢Δ ʢͪΖΜMetalΘͳ͍ʣ
ΞϓϦىಈ࣌ͷॾʑ ϘλϯԡԼʙ UIImageViewͷը૾දࣔ
࣌ܥྻํʹ֦େ
ʮMetal Accelerated͔Ͳ͏͔ʯ ΛࣗͰௐΒΕͳ͍͔ʁ → InstrumentsͰௐΒΕͦ͏
ϦΞϧλΠϜʹݟΕͳ͍ ʮͲͷάϥϑ͕ͲͷॲཧΛද͍ͯ͠Δͷ͔ʁʯ ͕Θ͔ΓͮΒ͍
MetalͷlabelػೳΛར༻ͯ͠Ͳ͏͔ʁ private func pushLabel(_ label: String) { let commandBuffer =
commandQueue.makeCommandBuffer()! commandBuffer.label = label commandBuffer.commit() } ʮԿ͠ͳ͍MetalͷίϚϯυόοϑΝʯΛGPUʹϓογϡ͢Δ ϝιουΛ͓͍ͭͬͯͯ͘ɺ @IBAction func btnTapped(_ sender: UIButton) { pushLabel(“start”) imageView.image = UIImage(named: "highsierra") pushLabel(“end”) } ͜Μͳײ͡ͰݺͿͱɾɾɾ label͚͍ͩ࣋ͬͯΔ
Instruments্Ͱͦͷlabel͕දࣔ͞Εɾɾɾ ͳ͔ͬͨɾɾɾ
ʮۭͷίϚϯυόοϑΝʯ InstrumentsͰݟ͑ͳ͍ ࣮ߦ࣌ʹGPUʹૹΒΕͳ͍ͷ͔ɺ ͦͦϏϧυஈ֊Ͱ࠷దԽ͞ΕΔͷ͔ɺetc… ʢͲ͔͜ʹ༷ͱͯ͠ॻ͍ͯ͋Δ͔ʣ
தͷ͋ΔίϚϯυʹ͢Δ private func pushLabel(_ label: String) { let textureLoader =
MTKTextureLoader(device: device) let srcTex = try! textureLoader.newTexture(name: “hoge”, scaleFactor: 2.0, bundle: nil) let descriptor = MTLTextureDescriptor.texture2DDescriptor( pixelFormat: srcTex.pixelFormat, width: srcTex.width, height: srcTex.height, mipmapped: false) let destTex = device.makeTexture(descriptor: descriptor)! let commandBuffer = commandQueue.makeCommandBuffer()! commandBuffer.label = label let blitEncoder = commandBuffer.makeBlitCommandEncoder()! blitEncoder.copy( from: srcTex, sourceSlice: 0, sourceLevel: 0, sourceOrigin: MTLOriginMake(0, 0, 0), sourceSize: MTLSizeMake(srcTex.width, srcTex.height, srcTex.depth), to: destTex, destinationSlice: 0, destinationLevel: 0, destinationOrigin: MTLOriginMake(0, 0, 0)) blitEncoder.endEncoding() commandBuffer.commit() } ຊʹཉ͍͠ͷ͚ͩ͜͜
ޭʂ ηοτͨ͠label͕ݟ͍͑ͯΔ
·ͱΊ • ͍··ͰɺMetal Accelerated͔Ͳ͏͔Λ֬ೝ͢ΔʹɺެࣜใཔΈͩͬͨ - Guide, API Reference, Forum, WWDC
Session, WWDC LabͰݴͬͯͨ, etc…ʮཪऔΓʯ ͕͔ͬͨ͠ - MetalΛ໌ࣔతʹ༻͍͍ͯͳ͚ΕɺXcodeͷGPU ReportԠ͠ͳ͍ • InstrumentsͷMetal System TraceΛ༻͍ΔͱɺMetalΛ໌ࣔతʹ༻͍͍ͯͳ ͍߹ʹɺMetalͷಈ͖ΛΔ͜ͱ͕Ͱ͖Δ • ϦΞϧλΠϜʹτϨʔεͰ͖ͳ͍ͷͰɺҹͱͯ͠labelΛషΔํ๏ݕ౼ - ҰԠ͏·͍ͬͨ͘ - ͕ɺखʹMetalΛ͏ख๏ʹͳͬͯ͠·ͬͨͷͰɺ͓͢͢Ί͠ͳ͍