powerpoint presentation€¦ · power usage 5 % memory usage 25 %. [email protected]...

37

Upload: others

Post on 26-May-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 2: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 3: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 4: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 5: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 6: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 7: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 8: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 9: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

Attempt to load Vulkan Loader

Attempt to loadBasic functions

Attempt to createinstance

Attempt to createInstance with

stable API version

Attempt to loadAll functions

Get/Check patch version from driver

1.0.0

1.0.11success = dlopen(“libVulkan.so”)

VK_SUCCESS == vkCreateInstanceVK_SUCCESS == vkCreateDevice

success = vkGetInstanceProcAddr

Page 10: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 11: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

FIFO

Swapchain Images

#0 #1 #2

Internal queue

X*

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

#0X=#0

#1Y=#1

#2Z=#2

VBLANK

Swaps #0 stored in X with the backbuffer.

Latency

Y* Z*

Page 12: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

MAILBOX

Swapchain Images

#0 #1 #2

Internal queue (impl dependant)

X*

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

vkAcquireNextImage

vkQueuePresent

#0X=#0

#1X=#1

#2X=#2

VBLANK

Display controller will read from #1

Latency

Page 13: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 14: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

VK_PRESENT_MODE_MAILBOX_KHRVK_PRESENT_MODE_FIFO_KHR

Page 15: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

?

Page 16: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

.RGB_888VK_FORMAT_R8G8B8_UNORM

APPLICATION

JAVA ACTIVITY

CREATE SURFACE

CREATE SWAPCHAIN

APPLICATION

NATIVE ACTIVITY

CREATE SWAPCHAIN

Page 17: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

N+2

5

RENDERFRAME N RENDERFRAME N+1 RENDERFRAME N+2 RENDERFRAME N+3

VkCommandBuffer #0 VkCommandBuffer #1 VkCommandBuffer #2 VkCommandBuffer #0

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

?

Crash!

6 7 8 9

Page 18: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

RENDERFRAME N RENDERFRAME N+1

RENDERFRAME N+2

RENDERFRAME N+3

VkCommandBuffer#0

VkCommandBuffer#1

VkCommandBuffer#2

VkCommandBuffer#0

Create VkPipeline#0~#9

Check VkPipeline#0~#4

Use VkPipeline#0~#9

Use VkPipeline#0~#9

Use VkPipeline#5~#9

RENDERFRAME N+4

VkCommandBuffer#1

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

N+2

5 6 7 8 9

Check VkPipeline#0~#4

Check VkPipeline#0~#4

Use VkPipeline#5~#9

Page 19: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 20: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

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

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

}

#2

#1

#0

#2#1#0

• glslangValidator applies std140 layout by default

• Best to explicitly specify layout in shader code and make

sure buffer layout matches!

Page 21: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 22: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

VkPhysicalDeviceLimits::minUniformBufferOffsetAlignment

VkDeviceMemory vec2 vec2float float

Page 23: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 24: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

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 25: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

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 26: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

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

EmptyPlease use correct

type of input.

Page 27: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 28: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

VK_IMAGE_LAYOUT_GENERAL

VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL

VK_IMAGE_LAYOUT_PRESENT_SRC_KHR

Page 29: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

// Get Image Format PropertyVkFormatProperties 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 30: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

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 31: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

Without Geometry Sorting

With Geometry Sorting

Page 32: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 33: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User
Page 34: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

OpenGL ES 2.0 (ETC1) Vulkan (ASTC)

APK size 599 MB 521 MB

Memory (run-time) 1115 MB 557 MB

Page 35: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User

Vulkan + ASTC vs GLES + ETC1

PerformanceNormal 4 %

Throttling 30 %

Power usage 5 %

Memory usage 25 %

Page 36: PowerPoint Presentation€¦ · Power usage 5 % Memory usage 25 %. f.garnier@samsung.com gamedev@samsung.com @f.garnier_ Title: PowerPoint Presentation Author: Microsoft Office User