powerpoint presentation - khronos group...powerpoint presentation author microsoft office user...

39

Upload: others

Post on 17-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 2: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 3: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 4: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 5: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 6: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 7: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 8: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

Attempt to load Vulkan Loader

Populate instance functions

Create instance and enumerate devices

Obtain physical device properities

Get API version from device

Check version is >= 1.0.11

dlopen(“libVulkan.so”)

vkCreateInstance

vkEnumeratePhysicalDevices

vkGetInstanceProcAddr

vkGetPhysicalDeviceProperties

physDevProp.apiVersion & 0xfff >= 11

physDevProp.apiVersion

Page 9: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 10: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

FIFO

Presentable Images

#0 #1 #2

Internal queue

X*

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

#0 X=#0

#1 Y=#1

#2 Z=#2

VBLANK

Swaps #0 stored in X with the backbuffer

Latency

Y* Z*

Page 11: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

MAILBOX

Presentable Images

#0 #1 #2

Internal queue (implementation dependent)

X*

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

#0 X=#0

#1 X=#1

#2 X=#2

VBLANK

Display controller will read from #1

Latency

Page 12: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

• TL;DR: Use triple-buffered FIFO unless there’s a good reason not to!

Page 13: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

VK_PRESENT_MODE_MAILBOX_KHR VK_PRESENT_MODE_FIFO_KHR

Page 14: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 15: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 16: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

.RGB_888VK_FORMAT_R8G8B8_UNORM

Java SurfaceView

Vulkan Surface

Vulkan Swapchain

Page 17: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

N+2

FRAME 1 FRAME 2 FRAME 3 FRAME 4

VkCommandBuffer #A VkCommandBuffer #B VkCommandBuffer #C VkCommandBuffer #A

Create VkPipeline #0~#9

Use VkPipeline #0~#9

Use VkPipeline #0~#9

Use VkPipeline #5~#9

Destroy VkPipeline #0~#4

N

0 1 2 3 4

5 6 7 8 9

N+1

0 1 2 3 4

5 6 7 8 9

Use VkPipeline #5~#9

5 6 7 8 9

Page 18: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

N+2

FRAME 1 FRAME 2 FRAME 3 FRAME 4

VkCommandBuffer #A VkCommandBuffer #B VkCommandBuffer #C VkCommandBuffer #A

Create VkPipeline #0~#9

Use VkPipeline #0~#9

Use VkPipeline #0~#9

Use VkPipeline #5~#9

Destroy VkPipeline #0~#4

N

0 1 2 3 4

5 6 7 8 9

N+1

0 1 2 3 4

5 6 7 8 9

Use VkPipeline #5~#9

5 6 7 8 9

Crash!

Page 19: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

FRAME 1 FRAME 2 FRAME 3 FRAME 4

VkCommandBuffer #A VkCommandBuffer #B VkCommandBuffer #C VkCommandBuffer #A

Create VkPipeline #0~#9

Check VkPipeline #0~#4

Use VkPipeline #0~#9

Use VkPipeline #0~#9

Use VkPipeline #5~#9

FRAME 5

VkCommandBuffer #B

Destroy VkPipeline #0~#4

Check VkPipeline #0~#4

Check VkPipeline #0~#4

Use VkPipeline #5~#9

N+2 N

0 1 2 3 4

5 6 7 8 9

N+1

0 1 2 3 4

5 6 7 8 9 5 6 7 8 9

Page 20: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 21: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

layout(set=0, binding=0) uniform buf1{

float _unif1; // #0 vec3 _unif2; // #1 vec2 _unif3; // #2 }

#2

#1

#0

#2 #1 #0

• glslangValidator applies std140 layout by default • Need to explicitly specify layout in shader code OR make sure

buffer layout matches the glslang default!

Page 22: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 23: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment

VkDeviceMemory vec2 vec2 float float

Page 24: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 25: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

N N N N

N N N N

N N N+1 N+1

N = N Frame MVP Matrix

N+1 = N+1 Frame MVP Matrix(Changed)

Page 26: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

Swapchain

VkImage #0

VkImage #1

VkImage #2

VkCommandBuffer #0

VkCommandBuffer #1

VkCommandBuffer #2

UB #0

Swapchain

VkImage #0

VkImage #1

VkImage #2

VkCommandBuffer #0

VkCommandBuffer #1

VkCommandBuffer #2

UB #0 UB #1 UB #2

Swapchain

VkImage #0

VkImage #1

VkImage #2

VkCommandBuffer #0

VkCommandBuffer #1

VkCommandBuffer #2

UB #0

dynamicOffset

Page 27: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 28: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

Original data

SHADER

OpenGL ES Driver

Driver type conversion

Original data

SHADER

Vulkan Driver

uint32 x 4

vec4

uvec4 vec4

uint32 x 4

vec4

vec4

Original data

SHADER

Vulkan Driver

uint32 x 4

uvec4

uvec4

Empty Please use correct

type of input.

Page 29: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 30: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

VK_IMAGE_LAYOUT_GENERAL

VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL

VK_IMAGE_LAYOUT_PRESENT_SRC_KHR

Page 31: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

// Get Image Format Property VkFormatProperties formatProperty; vkGetPhysicalDeviceFormatProperties(physicalDevice, imageFormat, &formatProperty); if (formatProperty.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) /**/; else if (formatProperty.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) /**/;

Page 32: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

vkCmdCopyBufferToImage

VkImage with VK_TILING_OPTIMAL

VkBuffer& stagingBuffer = getStagingBuffer(imageBufferSize); VkBufferImageCopy region = getRegionFromImage(image); fillBuffer(stagingBuffer, pImageData); vkCmdCopyBufferToImage(commandBuffer, stagingBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);

DO NOT use VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT with

VK_TILING_OPTIMAL.

?

Image Data Fill image data into the VkBuffer

VkBuffer

VkCommandBuffer

Page 33: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

Without Geometry Sorting

With Geometry Sorting

Page 34: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 35: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 36: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

OpenGL ES 2.0 (ETC1) Vulkan (ASTC)

APK size 599 MB 521 MB

Memory (run-time) 1115 MB 557 MB

Page 37: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM
Page 38: PowerPoint Presentation - Khronos Group...PowerPoint Presentation Author Microsoft Office User Created Date 1/30/2017 11:31:35 AM

August 2016

Vulkan + ASTC vs OpenGL ES + ETC1

Performance Normal 4 %

Throttling 30 %

Power usage 5 %

Memory usage 25 %