Metal Shader Debugging and Profiling

1649 篇文章 11 订阅
85 篇文章 1 订阅

https://medium.com/@nilotic2/metal-shader-debugging-and-profiling-48da25a400e8

Metal Shader Debugging and Profiling

WWDC 2018

Metal Frame Debugger

  • Step through API calls
  • Resource inspection
  • Shader edit and reload
  • GPU counters
  • Pipeline statics
  • Integrated into Xcode
  • Dependency viewer (new)
  • Geometry viewer (new)
  • Shader debugger (new)
  • Enhanced shader profiler (new)

Geometry Viewer

  • Visualize the post-vertex transform data in 3D
  • Access to all vertex data
  • Per-draw call view

Visibly Wrong Triangles

Out of Frustum Objects

Missing Triangles

Why use Shader Debugger?

  • Math heavy code
  • Highly parallel
  • Unity’s “Book of the Deed”
    - ~10 million vertex shader invocations
    - ~60 million pixels rendered

Shader Debugging

  • New tool for debugging Metal shaders
  • Rich variable visualization across thousands of threads
  • Real data from GPU
  • Flexible stepping
  • Integrated into Metal Frame Debugger

Demo

Problem (negative value)


Fining the bug

Values in realtime

Call Stack


Fix the Bug


Refresh

(You don’t need to rebuild)


Starting the Shader Debugger

Inspecting Variables

Following the Execution

Flexible stepping

Use filter to focus

Access to Other Threads

Set of threads are available based on the initial selection

  • Vertex — Primitive of the selected vertex
  • Fragment — Rectangle around the selected pixel
  • Compute — Threadgroup of the selected thread

See Variables in Context

  • Helps you understand your code
  • Important to for comparing good/ bad values
  • Hover for instant access

Comparing Good and Bad Pixels

  • Quickly compare threads
  • Execution history and variables and updated for the selected thread

Understanding Divergence

  • Mask shows which threads executed the same line to help you understand control flow

Demo

Problem


Finding the Bug


QA

Shader Debugger

  • Specifically designed for debugging Metal shaders
  • Great for
    - Fixing bugs!
    - Understanding your shader
    - Developing your shaders
  • Supports iOS, macOS, and tvOS
  • Available in Xcode 10

Knowing What to Optimized

Profiling tools built into Metal Frame Debugger

  • GPU counters

  • Pipeline statistics

  • Shader profiler

Shader Profiler

  • Provides per-pipeline timing information

  • Per-line execution cost (iOS and tvOS)

  • Shader edit and reload
  • Get into shader debugger

Enhanced Shader Profiler for A11

  • Instruction category cost breakdown per line
    - ALU — Float, half, and complex
    - Memory — Sample, load, and store operations
    - Synchronization — Wait memory, barriers, or atomics

  • Visibility into inline function cost

Demo

Access to Shader Sources

  • New Metal Compiler option
  • Xcode project
    - “Yes, include source code” from build settings
  • Command line
    - “-MO” compiler option

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值