Metal 2 on A11 — Imageblocks
Metal 2 on A11 — Imageblocks
Tech Talks
![](https://cdn-images-1.medium.com/max/800/1*5slcIkCNich50_tEU1-6Xw.jpeg)
Imageblocks
- 2D data structure accessible from shaders
- Single pixel access from fragment functions
- Full access from kernel functions - Multi-plane layout
- Efficient bulk storage of pixels to textures - Supports optional format conversion
![](https://cdn-images-1.medium.com/max/800/1*EwNQUTYoFMFDhMNzM4cpOA.jpeg)
Accelerated Image Movement
![](https://cdn-images-1.medium.com/max/800/1*hXfusbBTauT-uYV7n9e2Ww.gif)
![](https://cdn-images-1.medium.com/max/800/1*veC_NnRV3yO7wUaiJJrSQw.gif)
Imageblocks in Compute Kernels
- Dimensions are defined via API
MTLComputeCommandEncoder.setImageBlockWidth(_:height:)
- Pixel structure defined in shading language
- Accessed using an
imageblock<T>
argument
![](https://cdn-images-1.medium.com/max/800/1*Bu1CVNslvLG2yO7yEBMmNA.jpeg)
Storing Imageblock Slices to Textures
- Adjacent subsets of imageblock planes are called slices
- Slices of up to 4 components can e stored together
![](https://cdn-images-1.medium.com/max/800/1*IoH2-FpkgQ2eEDB54lZWWw.jpeg)
![](https://cdn-images-1.medium.com/max/800/1*ytc-AZj2TXpFX2Y6OQSANw.jpeg)
Imageblocks in Fragment Functions
- Dimensions are defined via render pass API
-MTLRenderPassDescription.titleWidth
-MTLRenderPassDescription.titleHeight
- 2 ways to declare pixel structure
- Define it in the function (explicit)
- Use render pass attachments (implicit)
![](https://cdn-images-1.medium.com/max/800/1*Poowf6t3lruYkeibp6s4ZQ.jpeg)
![](https://cdn-images-1.medium.com/max/800/1*iNgbcb_0sVV6FY4DAZtbKQ.jpeg)
Implicit Imageblock
Improved space efficiency
![](https://cdn-images-1.medium.com/max/800/1*FUzM080GwjjEhElne17eIA.jpeg)
Choosing Between Implicit and Explicit Imageblocks
- Implicit
- Function must support multiple texture pixel formats
- Convenience of load and store actions - Explicit
- Define complex per-pixel data types
- Transient usage within a render pass
![](https://cdn-images-1.medium.com/max/800/1*l5s8XVQftSZMdtzhU4NVzw.jpeg)
Mixing Implicit and Explicit Imageblocks
- Choose the right tool for the job !
- Supports incremental adoption
- In shading language, supply 2 imageblock arguments
![](https://cdn-images-1.medium.com/max/800/1*19MpMXJaqZB-4Q3igd4tHA.jpeg)
New Packed Data Types
- New shading language types match API pixel formats
- Accelerated conversion to / from floating point
- Describe packed layouts everywhere
- Explicit imageblocks
- Vertex attributes
- Uniforms
![](https://cdn-images-1.medium.com/max/800/1*yjKPdd0WT3maKDEC7qLl0g.jpeg)
![](https://cdn-images-1.medium.com/max/800/1*xwIXAZ0lp_4LjCyPoYfx_g.jpeg)
![](https://cdn-images-1.medium.com/max/800/1*KLDCtpYH4g9clgYGTGz-hQ.jpeg)
GPU Debugger Support
![](https://cdn-images-1.medium.com/max/800/1*XRsZDJmORhDJjaQU1xr4NQ.jpeg)