on computer graphics and interactive...

53

Upload: others

Post on 20-May-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation
Page 2: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

The 42nd International Conference and Exhibition on Computer Graphics and Interactive Techniques

Using Next-Generation APIs on Mobile GPUsJesse HallGoogle

Page 3: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

MobileTile-Based Architectures• “Mobile GPU” usually means “Tile-Based GPU”

- Most Android and all iOS devices use tile-based rendering - Tiling reduces use of expensive off-chip memory bandwidth

• Vulkan and Metal make apps aware of tiling - Explicit render passes with load/store operations - Transient framebuffer attachments (Vulkan) - Two levels of command recording parallelism

Page 4: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Immediate Rendering

Page 5: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Immediate Rendering

VS Raster/Shade

Page 6: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Immediate Rendering

VS Raster/Shade

Page 7: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

Page 8: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AVS

Page 9: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

A

-A

AVSA

Binning Lists

Page 10: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVSAB

Binning Lists

Page 11: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Tile Memory

Page 12: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Tile Memory

Page 13: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Resolve

FramebufferTile

Memory

Page 14: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Resolve

FramebufferTile

Memory

Page 15: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Resolve

FramebufferTile

Memory

Page 16: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile-Based Rendering

AB

-B

A-

B AVS

Raster/Shade

AB

Binning Lists

Resolve

FramebufferTile

Memory

Page 17: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile Memory Initialization• Load: Load attachment contents into tile memoryVK_ATTACHMENT_LOAD_OP_LOAD | MTLLoadActionLoad

• Clear: Initialize tile memory with solid colorVK_ATTACHMENT_LOAD_OP_CLEAR | MTLLoadActionClear

• Don’t Care: Tile memory is uninitialized, use when opaque color will be written to every sample VK_ATTACHMENT_LOAD_OP_DONT_CARE | MTLLoadActionDontCare

Page 18: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile Memory Disposition• Store: Commit tile memory to memoryVK_ATTACHMENT_STORE_OP_STORE | MTLStoreActionStore

• Don’t Care: Attachment contents are undefined VK_ATTACHMENT_STORE_OP_DONT_CARE | MTLStoreActionDontCare

Page 19: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Tile Memory Multisample Resolve• Multisample resolve occurs at end of render pass

- Color attachments have a multisample VkImage | MTLTexture - And an optional single-sample resolve VkImage | MTLTexture - Metal: Use MTLStoreActionMultisampleResolve for attachment

Page 20: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Transient Attachments• Depth images are typically cleared & discarded

- Tilers never need to read or write off-chip memory for these!

• In Vulkan, can use a lazily-committed VkImage- Must always attach a VkImage that has VkDeviceMemory - Create VkImage with VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT - But VkDeviceMemory may not have committed physical memory - Tilers will often be able to avoid committing memory

Page 21: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Multi-threading a Single Pass• Passes are the unit of scheduling on some tilers

- Must begin and end in the same command buffer - But we need to be able to parallelize recording of draws in a pass…

• Vulkan and Metal offer second-level parallelism- Vulkan: VK_CMD_BUFFER_LEVEL_SECONDARY - Metal: MTLParallelRenderCommandEncoder - Use when you need to issue draws in parallel within a single pass

Page 22: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Page 23: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Thread 1:

Page 24: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Thread 1:vkBeginCommandBuffer(PRIMARY)

Page 25: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Thread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPass

Page 26: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Draw Draw Draw

Thread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPassvkCmdDraw [x3]

Page 27: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Serial Pass

Draw Draw Draw

Thread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPassvkCmdDraw [x3]vkCmdEndRenderPassvkEndCommandBuffer

Page 28: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel Pass

Page 29: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1: Threads 2..4:

Page 30: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1:vkBeginCommandBuffer(PRIMARY)

Threads 2..4:vkBeginCommandBuffer(SECONDARY)

Page 31: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPass

Draw

Draw

Draw

Threads 2..4:vkBeginCommandBuffer(SECONDARY)vkCmdDraw

Page 32: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPass

Draw

Draw

Draw

Threads 2..4:vkBeginCommandBuffer(SECONDARY)vkCmdDrawvkEndCommandBuffer

Page 33: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPass

vkCmdExecuteSecondaryCommands

Draw

Draw

Draw

Threads 2..4:vkBeginCommandBuffer(SECONDARY)vkCmdDrawvkEndCommandBuffer

Page 34: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Vulkan: Parallel PassThread 1:vkBeginCommandBuffer(PRIMARY)vkCmdBeginRenderPass

vkCmdExecuteSecondaryCommandsvkCmdEndRenderPassvkEndCommandBuffer

Draw

Draw

Draw

Threads 2..4:vkBeginCommandBuffer(SECONDARY)vkCmdDrawvkEndCommandBuffer

Page 35: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Page 36: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Thread 1:

Page 37: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Thread 1:cb = queue.commandBuffer()

Page 38: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Thread 1:cb = queue.commandBuffer()rce = cb.renderCommandEncoder()

Page 39: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Thread 1:cb = queue.commandBuffer()rce = cb.renderCommandEncoder()rce.drawPrimitives() [x3] Draw Draw Draw

Page 40: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Serial Pass

Thread 1:cb = queue.commandBuffer()rce = cb.renderCommandEncoder()rce.drawPrimitives() [x3]rce.endEncoding()cb.commit()

Draw Draw Draw

Page 41: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel Pass

Page 42: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1: Threads 2..4:

Page 43: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()

Threads 2..4:

Page 44: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

Threads 2..4:

Page 45: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

Threads 2..4:

rce = prce.renderCommandEncoder()

Page 46: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

Draw

Draw

Draw

Threads 2..4:

rce = prce.renderCommandEncoder()rce.drawPrimitives()rce.endEncoding()

Page 47: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

prce.endEncoding()Draw

Draw

Draw

Threads 2..4:

rce = prce.renderCommandEncoder()rce.drawPrimitives()rce.endEncoding()

Page 48: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

prce.endEncoding()cb.commit() Draw

Draw

Draw

Threads 2..4:

rce = prce.renderCommandEncoder()rce.drawPrimitives()rce.endEncoding()

Page 49: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Metal: Parallel PassThread 1:cb = queue.commandBuffer()prce = cb.parallelRenderCommandEncoder()

prce.endEncoding()cb.commit() Draw

Draw

Draw

Threads 2..4:

rce = prce.renderCommandEncoder()rce.drawPrimitives()rce.endEncoding()

Page 50: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Render Pass Merging• Vulkan allows merging some render passes

- Render-to-texture-then-use, 1:1 pixel correspondence

Diffuse

Normal

Lighting

Depth

ColorGBuf

Light

Shade

Page 51: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

• Original passes become “subpasses”

• Intermediate data stays in on chip tile memory

Render Pass Merging

DiffuseNormal LightingDepth

ColorGBuf Light Shade

Page 52: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

• Describe subpass dependencies to the driver- Driver maps to 1+ tiling passes and assigns per-pixel storage - Natural fallback to render-to-texture on immediate renderers

• Use description when creating Pipelines

• May be implemented as Pixel Local Storage- Merged passes don’t guarantee fragment ordering in a pass - Drivers can expose a PLS extension for more explicit control

Merging Render Passes

Page 53: on Computer Graphics and Interactive Techniquesnextgenapis.realtimerendering.com/presentations/4_Hall... · 2015-08-17 · on Computer Graphics and Interactive Techniques Using Next-Generation

Summary• Tile-based GPUs are first-class citizens now

• Choose load/store operations carefully

• Think about whether you need coarse (inter-pass) or fine (intra-pass) parallelism

• Look for opportunities to merge render passes