Porting Roblox to Vulkan. Arseny

Similar documents
Using SPIR-V in practice with SPIRV-Cross

Vulkan 1.1 March Copyright Khronos Group Page 1

Achieving High-performance Graphics on Mobile With the Vulkan API

DEVELOPER DAY. Shader Toolchain: HLSL in Vulkan Lei Zhang, Google MONTRÉAL APRIL Copyright Khronos Group Page 1

Vulkan API 杨瑜, 资深工程师

OpenGL Status - November 2013 G-Truc Creation

EECS 487: Interactive Computer Graphics

Copyright Khronos Group Page 1

Vulkan Multipass mobile deferred done right

The Application Stage. The Game Loop, Resource Management and Renderer Design

Vulkan Launch Webinar 18 th February Copyright Khronos Group Page 1

DEVELOPER DAY MONTRÉAL APRIL Copyright Khronos Group Page 1

Introduction to SPIR-V Shaders

Engine Development & Support Team Lead for Korea UE4 Mobile Team Lead

Next Generation OpenGL Neil Trevett Khronos President NVIDIA VP Mobile Copyright Khronos Group Page 1

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

Prospects for a more robust, simpler and more efficient shader cross-compilation pipeline in Unity with SPIR-V

OpenGL ES 2.0 : Start Developing Now. Dan Ginsburg Advanced Micro Devices, Inc.

Vulkan (including Vulkan Fast Paths)

Mali Developer Resources. Kevin Ho ARM Taiwan FAE

Working with Metal Overview

Compute Shaders. Christian Hafner. Institute of Computer Graphics and Algorithms Vienna University of Technology

GDC 2014 Barthold Lichtenbelt OpenGL ARB chair

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Profiling and Debugging Games on Mobile Platforms

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

Doom 3 Dante. Performance on Mesa (i965) (Not a Demo!) Oliver McFadden 1

Mention driver developers in the room. Because of time this will be fairly high level, feel free to come talk to us afterwards

SPU Render. Arseny Zeux Kapoulkine CREAT Studios

Vulkan: Architecture positive How Vulkan maps to PowerVR GPUs Kevin sun Lead Developer Support Engineer, APAC PowerVR Graphics.

D3D12 & Vulkan: Lessons learned. Dr. Matthäus G. Chajdas Developer Technology Engineer, AMD

DEVELOPER DAY. Descriptor Indexing Hai Nguyen, Google MONTRÉAL APRIL Copyright Khronos Group Page 1

Press Briefing SIGGRAPH 2015 Neil Trevett Khronos President NVIDIA Vice President Mobile Ecosystem. Copyright Khronos Group Page 1

Vulkan on Mobile. Daniele Di Donato, ARM GDC 2016

Vulkan on Android: Gotchas and best practices

Driving Change. Vulkanising Mad Max

Mobile Graphics Ecosystem. Tom Olson OpenGL ES working group chair

Could you make the XNA functions yourself?

3D Graphics Dev Day. Copyright Khronos Group Page 1

Shader Series Primer: Fundamentals of the Programmable Pipeline in XNA Game Studio Express

Press Briefing SIGGRAPH 2015 Neil Trevett Khronos President NVIDIA Vice President Mobile Ecosystem. Copyright Khronos Group Page 1

Cg Toolkit. Cg 2.2 February 2010 Release Notes

CS195V Week 6. Image Samplers and Atomic Operations

Hi everyone! My name is Niklas and I ve been working at EA for the last 2.5 years. My main responsibility there have been to bring up the graphics

Mobile Graphics Trends: Applications. Marco Agus, KAUST & CRS4

Shaders CSCI 4229/5229 Computer Graphics Fall 2017

DEVELOPER DAY. Vulkan Subgroup Explained Daniel Koch NVIDIA MONTRÉAL APRIL Copyright Khronos Group Page 1

Practical Development for Vulkan. Dan Ginsburg, Valve Baldur Karlsson, Unity Dean Sekulic, Croteam

OpenGL on Android. Lecture 7. Android and Low-level Optimizations Summer School. 27 July 2015

Day: Thursday, 03/19 Time: 16:00-16:50 Location: Room 212A Level: Intermediate Type: Talk Tags: Developer - Tools & Libraries; Game Development

Copyright Khronos Group, Page Graphic Remedy. All Rights Reserved

Bifrost - The GPU architecture for next five billion

SIGGRAPH Briefing August 2014

Applications and Implementations

Vulkan and Animation 3/13/ &height=285&playerId=

Coding OpenGL ES 3.0 for Better Graphics Quality

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

DirectX Programming #4. Kang, Seongtae Computer Graphics, 2009 Spring

Investigating real-time rendering techniques approaching realism using the Vulkan API

CSE 591: GPU Programming. Introduction. Entertainment Graphics: Virtual Realism for the Masses. Computer games need to have: Klaus Mueller

TG-Gallium Driver Stack. Softpipe, Cell and Beyond. Keith Whitwell

A Trip Down The (2011) Rasterization Pipeline

The Witness on Android Post Mortem. Denis Barkar 3 March, 2017

Shaders CSCI 4239/5239 Advanced Computer Graphics Spring 2014

D3D12 & Vulkan Done Right. Gareth Thomas Developer Technology Engineer, AMD

Designing a Modern GPU Interface

Understanding Shaders and WebGL. Chris Dalton & Olli Etuaho

GPU Computation Strategies & Tricks. Ian Buck NVIDIA

Vulkan: Scaling to Multiple Threads. Kevin sun Lead Developer Support Engineer, APAC PowerVR Graphics

Lecture 13: OpenGL Shading Language (GLSL)

Dave Shreiner, ARM March 2009

Get the most out of the new OpenGL ES 3.1 API. Hans-Kristian Arntzen Software Engineer

Metal for OpenGL Developers

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

CS427 Multicore Architecture and Parallel Computing

! Readings! ! Room-level, on-chip! vs.!

Mikkel Gjøl Graphics

Update on Khronos Open Standard APIs for Vision Processing Neil Trevett Khronos President NVIDIA Vice President Mobile Ecosystem

Mali Offline Compiler User Guide

Cg Toolkit. Cg 2.2 April 2009 Release Notes

Low-Overhead Rendering with Direct3D. Evan Hart Principal Engineer - NVIDIA

CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL

CSE 591/392: GPU Programming. Introduction. Klaus Mueller. Computer Science Department Stony Brook University

Radeon ProRender and Radeon Rays in a Gaming Rendering Workflow. Takahiro Harada, AMD 2017/3

Graphics Architectures and OpenCL. Michael Doggett Department of Computer Science Lund university

GPU Quality and Application Portability

Building X 2D rendering acceleration with OpenGL. Eric Anholt Intel Open Source Technology Center

The Ultimate Developers Toolkit. Jonathan Zarge Dan Ginsburg

Designing for Performance. Arseny Kapoulkine

GPGPU. Peter Laurens 1st-year PhD Student, NSC

CS179: GPU Programming

Parallel Programming on Larrabee. Tim Foley Intel Corp

last time put back pipeline figure today will be very codey OpenGL API library of routines to control graphics calls to compile and load shaders

Copyright Khronos Group Page 1

Copyright Khronos Group Page 1

GPU Memory Model. Adapted from:

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

Jomar Silva Technical Evangelist

What s New with GPGPU?

Cg Toolkit. Cg 2.0 May 2008 Release Notes

Transcription:

Porting Roblox to Vulkan Arseny Kapoulkine @zeuxcg 1

What is Roblox? Online multiplayer game creation platform All content is user generated Windows, macos, ios, Android, Xbox One 50M+ MAU, 1.5M+ CCU 2

Jailbreak Cops and robbers Two primary developers 1 artist, 1 programmer Peak 130K CCU in February 2018 3

Why Vulkan? Lots of performance challenges on Android Need maximum performance without tweaking content Need modern* GAPI features for current/future rendering projects Long term desire to discontinue OpenGL 4

It's going to be easy, right? D3D9, D3D11, GL2/3, GLES2/3, Metal, GNM*... What's one more API to support? Drivers should be pretty good since API is so much simpler... 5

I have not failed. I've just found 10,000 ways that won't work. Thomas A. Edison 6

Shaders Shared & familiar shading language, would like to keep it LightingVertexOutput ParticleLightingVS(Appdata IN) { LightingVertexOutput OUT; float2 uv = getlightinguv(in.lightuv, IN.disp); OUT.HPosition = float4(uv.x * 2 1, 1 uv.y * 2, 0, 1); OUT.LightPosition = lgridpreparesample(in.worldpos); #ifdef DX9 OUT.HPosition.xy += CB1.AtlasParams.xy * float2( 1, 1); #endif } return OUT; 7

Shader toolchain: OpenGL github.com/thekla/hlslparser: HLSL > GLSL github.com/aras p/glsl optimizer: GLSL > GLSL 8

Shader toolchain: Vulkan github.com/thekla/hlslparser: HLSL > GLSL glslang: GLSL > SPIRV 9

Shader toolchain: Vulkan, take 2 github.com/thekla/hlslparser: HLSL > GLSL github.com/aras p/glsl optimizer: GLSL > GLSL glslang: GLSL > SPIRV 10

Shader toolchain: Vulkan, actual take 2 github.com/thekla/hlslparser: HLSL > GLSL github.com/aras p/glsl optimizer: GLSL > GLSL std::regex: replace uniform variables with UBOs glslang: GLSL > SPIRV 11

Shader toolchain: Vulkan, future glslang / DXC: HLSL > SPIRV spirv opt: SPIRV > SPIRV Os spirv opt: SPIRV > SPIRV strip debug for OpName spirv val is essential! 12

API Shared & convenient interface, would like to keep it PassClear passclear; passclear.mask = Framebuffer::Mask_Color0; ctx >beginpass(fb, 0, Framebuffer::Mask_Color0, &passclear); ctx >bindprogram(program.get()); ctx >bindbuffer(0, &globaldata, sizeof(globaldata)); ctx >bindbuffer(1, &params, sizeof(params)); ctx >bindtexture(0, lightmap, SamplerState::Filter_Linear); ctx >draw(geometry, Geometry::Primitive_Triangles, 0, count); ctx >endpass(); 13

Implementation dumb parts Lazily create and cache everything Serialize pipeline cache to disk to minimize stalls Dynamic descriptor sets allocate, update, bind Generic memory allocator, predates AMD's github.com/gpuopen LibrariesAndSDKs/VulkanMemoryAllocator 14

Implementation smart* parts Defer resource destruction/reuse until frame is executed No layout tracking, transition on beginpass / endpass boundaries* Avoid descriptor allocation/updates dynamic descriptors Carefully optimize everything github.com/zeux/volk 15

"It's hard to beat the driver" Faster CPU dispatch, matching GPU performance Does NOT require a mindset change! YMMV Desktop: test level @ 5090 draw calls, single core NVidia: DX11 10 ms w/driver threading: 4.5 ms, Vulkan 3.6 ms AMD: DX11 11.4 ms w/driver threading: 5.2 ms, Vulkan 5.8 ms Intel: DX11 25 ms, Vulkan 12.8 ms Mobile: test level @ 1130 draw calls, single core Qualcomm: GL 9.8 ms, Vulkan 3.8 ms ARM: GL 15.3 ms, Vulkan 5.9 ms PowerVR: GL 29.0 ms*, Vulkan 7.8 ms 16

Vulkan on Android: stats of doom 17% of our Android users can use Vulkan >2M MAU! Android version stats: 6.0 0.8% 7.0 82.0% 7.1 14.5% 8.0 1.7% 8.1 1.0% Most users will have drivers released months after 1.0 spec 17

Synchronization 101 Rule #1: You don't understand barrier semantics Rule #2: Your barrier code is wrong No validation for synchronization... 2018? please? github.com/khronosgroup/vulkan Docs/wiki/Synchronization Examples github.com/tobski/simple_vulkan_synchronization 18

Command buffer management vkfreecommandbuffers can be a no op! Use vkresetcommandpool or vkresetcommandbuffer Need NxM VkCommandPool objects for multi threaded rendering 19

Shader compiler bugs, rollup Sampler function arguments don't work always Local struct variables don't work sometimes Varying OpName names have to match between VS & FS Entrypoint OpName must be equal to OpEntryPoint name Combined image & sampler descriptors have to be combined in SPIRV vkcreategraphicspipelines returns VK_INCOMPLETE Gaps in UBO binding indices can lead to incorrect rendering Simple control flow is miscompiled to always take the branch 20

Driver bugs, rollup VkInstanceCreateInfo::pApplicationInfo=NULL crashes in driver Barrier with VK_REMAINING_ARRAY_LAYERS crashes in driver stencilloadop=load only works with depth loadop=load loadop=dont_care doesn't work with swapchain image vkcmdblitimage ignores layercount for cubemaps vkcmdcopybuffertotexture mishandles Z offset for 3D textures Red and blue channels are swapped in swapchain image VK_SUBPASS_EXTERNAL dependencies don't work vkcmdbindpipeline disturbs vertex buffer bindings Incomplete initial data crashes vkcreatepipelinecache 21

Driver bugs, what to do? Report conformance bugs! github.com/khronosgroup/vk GL CTS Talk to platform holders / GPU vendors Samsung developer.samsung.com/game Google issuetracker.google.com Prepare to work around bugs Prepare to blacklist devices 22

Driver workarounds & blacklists uint32_t apiversion; // spec version; patch version not useful uint32_t driverversion; // semver, CL#, binary hash uint32_t vendorid; // 0x8086 uint32_t deviceid; // not generally useful We use a combination of vendorid and Android ABI version* For blacklisting we pattern match device model names 23

Bug reporting guide github.com/khronosgroup/ Found a bug in your code? Report to Vulkan LoaderAndValidationLayers Found a bug in the driver? Report to VK GL CTS Report to GPU vendors Found a bug in shader toolchain? Report to glslang / DXC / SPIRV Tools as appropriate Report missing validation to SPIRV Tools 24

Conclusion Vulkan is practical today Requires high pain tolerance, but gains are worth it Help us make Vulkan better! 25

Thank you! arseny@roblox.com 26