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
Inside Stream API
skrb
1
780
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
620
JavaDoc 再入門
nagise
1
420
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
A2UI という光を覗いてみる
satohjohn
1
150
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
800
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
160
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
180
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
So, you think you're a good person
axbom
PRO
2
2.1k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
570
Faster Mobile Websites
deanohume
310
32k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
360
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
310
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Λ͏ख๏ʹͳͬͯ͠·ͬͨͷͰɺ͓͢͢Ί͠ͳ͍