Siggraph 2016 VULKAN AND NVIDIA: THE ESSENTIALS Tristan Lorach Manager of Developer Technology Group, NVIDIA US 7/25/2016
ANALOGY ON GRAPHIC APIS (getting ready for my 7 years old son’s questions on my job…) Car Toy Lego Kit Derby Kit 2
Analogy Different Valid Approaches (booring …) (cool... Messes-up the bedroom) (adult supervision required!) Fixed-function OpenGL Modern AZDO OpenGL with Vulkan Programmable Shaders 3
WHAT IS VULKAN ? …It’s a modern API Designed and maintained by Khronos Group • Designed for high performance on rendering and compute • [Extremely] low level : no more “baby - sitting” from our driver • Manage yourself memory, resource updates; batching; scheduling… • • [Extremely] verbose : Lots of structures to fill with parameters close to DX12 design… • Opposite of OpenGL: Multi-threading friendly : Vulkan will especially shine if • multi-threading used But still generic enough to work on many HW vendors & platforms • 4
Beneficial Vulkan Scenarios Can your graphics yes yes Is your graphics creation be parallelized? work CPU bound? You’ll yes yes Your graphics Vulkan do whatever start it takes to squeeze out platform is fixed friendly Max perf. You put You can yes yes a premium on manage your avoiding graphics resource hitches allocations 5
Beneficial Vulkan Scenarios Can your graphics yes yes Is your graphics creation be parallelized? work CPU bound? You’ll Tired with OpenGL Kinda … yes Alright… yes Your graphics Vulkan Want to learn new stuff ? do whatever start (state-machine) it takes to squeeze out platform is fixed friendly Spend lots of time coding ? or even D3D ? (Yes) (it’s a Yes) Max perf. No sleep ? You put You can yes yes a premium on manage your avoiding graphics resource hitches allocations 6
Unlikely to Benefit Scenarios to Reconsider Coding to Vulkan 1. Need for compatibility to pre-Vulkan platforms 2. Heavily GPU-bound application 3. Heavily CPU-bound application due to non-graphics work 4. Single-threaded application, unlikely to change 5. App can target middle-ware engine, avoiding 3D graphics API dependencies • Consider using an engine targeting Vulkan, instead of dealing with Vulkan yourself Good News in any case: NVIDIA OpenGL driver is great and will always be there ! 7
BIG PICTURE – OPENGL CASE Push-Buffer (FIFO) cmds Application OpenGL Driver Cmd bundles GPU memory OpenGL Commands Element buffer (EBO) Front-End . (decoder) Draw Indirect Buffer . Vertex Buffer (VBO) Vertex Puller (IA) Vertex Shader Uniform Block Graphics pipeline TCS (Tessellation) States Tessellator Texture Fetch TES (Tessellation) Resources Geometry Shader Image Load/Store OpenGL Transform Feedback resources Atomic Counter Rasterization Heap Shader Storage Fragment Shader Per-Fragment Ops FBO resources Dependencies Framebuffer (Textures / RB) Tr. Feedback buffer 8
BIG PICTURE – VULKAN Push-Buffer (FIFO) cmds Cmd bundles Application OpenGL Driver Cmd-buffers / queues GPU memory Element buffer (EBO) Front-End (decoder) Draw Indirect Buffer Fewer translation, Vertex Buffer (VBO) Validation checks Vertex Puller (IA) And internal mgt Vertex Shader Uniform Block Pipeline TCS (Tessellation) Render Descriptor States Minimal memory Tessellator Passes Sets Texture Fetch management TES (Tessellation) Geometry Shader Image Load/Store Resources Transform Feedback Atomic Counter Rasterization Shader Storage Fragment Shader Heap Per-Fragment Ops FBO resources Dependencies Framebuffer (Textures / RB) Tr. Feedback buffer 9
VULKAN COMPONENTS Cmd.Buffer Pool Command-buffer Barrier synchronization Framebuffer Render-Pass Image View Begin Render-Pass Heap Bind Graphics-pipeline Graphics pipeline Set misc. dynamic states Image … Bind Vertex/Idx Buffer(s) Memory Buffer Instance Update Buffer Image View Descriptor-Set Bind Descriptor-Set(s) Device DescriptorSet Pool Draw… Buffer Execute Commands 2 ndary Command-buffer Sampler … Queue End Render-Pass … 10
VULKAN COMPONENTS Cmd.Buffer Pool Command-buffer Command-buffer Barrier synchronization Framebuffer Render-Pass Image View Begin Render-Pass Heap Bind Graphics-pipeline Graphics pipeline Set misc. dynamic states Image … Bind Vertex/Idx Buffer(s) Memory Buffer Instance Update Buffer Image View Descriptor-Set Bind Descriptor-Set(s) Device(s) Device DescriptorSet Pool Draw… Buffer Execute Commands 2 ndary Command-buffer Sampler … Queue(s) End Render-Pass … 11
VULKAN OBJECTS: DEVICE Cmd.Buffer Pool Command-buffer Command-buffer Barrier synchronization Instance ~ ~ OpenGL Context Framebuffer Render-Pass Image View Begin Render-Pass Heap Instance-Layers Bind Graphics-pipeline Graphics pipeline Intercepting API calls for misc. purposes • Set misc. dynamic states Image Many layers available (api-dump; • … core/std/parms validation; screenshot…) Bind Vertex/Idx Buffer(s) Memory Buffer Instance Update Buffer Instance-Specific Extensions Image View Descriptor-Set Bind Descriptor-Set(s) Device Device(s) KHR_Surface (for Swap-chains) • DescriptorSet Pool EXT_debug_report • Draw… Buffer … • Execute Commands 2 ndary Command-buffer Sampler … Queue End Render-Pass Exposes some Devices… … 12
HOW DOES IT LOOK ? Instance creation Layer properties Extension properties 13
HOW DOES IT LOOK ? Instance creation Get Instance- Extension’s functions etc 14
VULKAN OBJECTS: DEVICE Cmd.Buffer Pool Command-buffer Command-buffer Barrier synchronization Framebuffer Render-Pass Image View Begin Render-Pass Heap Bind Graphics-pipeline VkPhysicalDevice Graphics pipeline Capabilities • Set misc. dynamic states Image • Memory Management … Bind Vertex/Idx Buffer(s) Memory Buffer Queues • Objects • Update Buffer Buffers • Image View Descriptor-Set Images • Bind Descriptor-Set(s) Device(s) Device • Sync Primitives Can have many … DescriptorSet Pool Draw… Buffer Execute Commands 2 ndary Command-buffer Sampler … Queue End Render-Pass … 15
NVIDIA’S VULKAN CAPABILITIES Properties listed from Physical Device NVIDIA is almost full featured Top to bottom: from GeForce, Quadro down to Tegra Check http://vulkan.gpuinfo.org/listreports.php 16
NVIDIA’S VULKAN CAPABILITIES GeForce GTX 980 Tegra X1 & K1 17
HOW DOES IT LOOK ? Device creation – enumerate physical devices; gather properties 18
HOW DOES IT LOOK ? Device creation – Create the device (!) 20
VULKAN COMPONENTS Cmd.Buffer Pool Command-buffer Barrier synchronization Framebuffer Render-Pass Image View Begin Render-Pass Heap Bind Graphics-pipeline Graphics pipeline Set misc. dynamic states Image … Bind Vertex/Idx Buffer(s) Memory Buffer Update Buffer Image View Descriptor-Set Bind Descriptor-Set(s) Device DescriptorSet Pool Draw… Buffer Execute Commands 2 ndary Command-buffer Sampler … Queue Queue End Render-Pass … 21
QUEUES Cmd.Buffer Pool Command-buffer Command-buffer Command queue was hidden in OpenGL Context… now explitly declared Barrier synchronization Multiple threads can submit work to a queue (or queues)! Framebuffer Render-Pass Image View Begin Render-Pass Heap Queues accept GPU work via CommandBuffer submissions Bind Graphics-pipeline Graphics pipeline few operations available around Queues:, “ submit work ” and “ wait for idle ” Set misc. dynamic states Image Queue submissions can include sync primitives for the queue to: … Bind Vertex/Idx Buffer(s) Memory Buffer Wait upon before processing the submitted work Update Buffer Image View Descriptor-Set Signal when the work in this submission is completed Bind Descriptor-Set(s) Device Queue “ families ” can accept different types of work, e.g. DescriptorSet Pool Draw… Buffer NVIDIA exposes 2 families: 1+16 Queues Execute Commands 2 ndary Command-buffer Sampler … 16 for all available types of work Queue Queue End Render-Pass … 1 for transfer operations only (Copy Engine) 22
HOW DOES IT LOOK ? Queue(s) 23
VULKAN COMPONENTS Cmd.Buffer Pool Command-buffer Cmd.Buffer Pool Command-buffer Barrier synchronization Barrier synchronization Framebuffer Render-Pass Image View Begin Render-Pass Begin Render-Pass Heap Bind Graphics-pipeline Bind Graphics-pipeline Graphics pipeline Set misc. dynamic states Set misc. dynamic states Image … … Bind Vertex/Idx Buffer(s) Memory Buffer Bind Vertex/Idx Buffer(s) Update Buffer Update Buffer Image View Descriptor-Set Bind Descriptor-Set(s) Bind Descriptor-Set(s) Device DescriptorSet Pool Draw… Buffer Draw… Execute Commands 2 ndary Command-buffer Execute Commands 2 ndary Command-buffer Sampler … … Queue End Render-Pass End Render-Pass … … 24
SYNCHRONIZATION Cmd-buffer barrier events and barriers Cmd-buffer used to synchronize work within a command event event buffer or sequence of command buffers submitted to a single queue Cmd-buffer Queue Queue semaphores used to synchronize work across queues or Semaphores across coarse-grained submissions to a single queue Queue fences used to synchronize work between the device and the host. Fences Device Host 25
Recommend
More recommend