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.5k
機械学習のブルーオーシャン 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
Agentic UI
manfredsteyer
PRO
0
200
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
14
6.9k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
7k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
Inside Stream API
skrb
1
780
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
Oxcを導入して開発体験が向上した話
yug1224
4
340
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
Evolving SEO for Evolving Search Engines
ryanjones
0
220
Become a Pro
speakerdeck
PRO
31
6k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
220
Marketing to machines
jonoalderson
1
5.5k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
GitHub's CSS Performance
jonrohan
1033
470k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
980
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Λ͏ख๏ʹͳͬͯ͠·ͬͨͷͰɺ͓͢͢Ί͠ͳ͍