Software practical final presentation Niels Buwen David Sprengel - - PowerPoint PPT Presentation

software practical final presentation
SMART_READER_LITE
LIVE PREVIEW

Software practical final presentation Niels Buwen David Sprengel - - PowerPoint PPT Presentation

Software practical final presentation Niels Buwen David Sprengel Vulkan vs OpenGL Conceptual differences and performance 23.04.2018 2 / 24 'Vulkan is not well-suited to simple test applications; neither is it a suitable aid for teaching


slide-1
SLIDE 1

Software practical final presentation

Niels Buwen David Sprengel

slide-2
SLIDE 2

23.04.2018 2 / 24

Vulkan vs OpenGL

Conceptual differences and performance

slide-3
SLIDE 3

23.04.2018 3 / 24

'Vulkan is not well-suited to simple test applications; neither is it a suitable aid for teaching graphics concepts.' – Graham Sellers, Vulkan Programming Guide

slide-4
SLIDE 4

23.04.2018 4 / 24

Outline

  • Introduction: goal and history
  • Similarities
  • Conceptual differences
  • Getting started
  • Performance
  • Summary
  • Demonstration (video)
slide-5
SLIDE 5

23.04.2018 5 / 24

Introduction

What are OpenGL and Vulkan?

  • API for 3D graphics applications
  • Platform-independent
  • Programming language-independent
  • Developed by the Khronos Group[1]

1 https://www.khronos.org/

slide-6
SLIDE 6

23.04.2018 6 / 24

Goal

1)Develop minimal OpenGL and Vulkan program 2)Implement Exercises from 'Computergrafik I'[1] and 'Computergraphics'[2] in OpenGL and Vulkan 3)Compare results

  • Performance
  • Programming experience
  • Visuals

1 Lecture by Susanne Krömker 2 Lecture by Filip Sadlo - https://vcg.iwr.uni-heidelberg.de/teaching/2016-17/cg/

slide-7
SLIDE 7

23.04.2018 7 / 24

History - OpenGL

  • Introduced in 1992
  • Used fixed-function-pipeline ( glBegin(),glEnd() )
  • In 2008: Version 3.0 with programmable-pipeline

(shaders)

  • 2012: Version 4.3 with compute shaders
  • Supports: Linux, macOS, Windows( but DirectX is

more common )

  • Separate API for Android and iOS ( OpenGL ES )
slide-8
SLIDE 8

23.04.2018 8 / 24

History - Vulkan

  • Created in 2014 as 'glNext'
  • From the very start only programmable-pipeline and

computing capabilities

  • Announced in 2015 at GDC
  • 26.02.2018: macOS and iOS support through

MoltenVK

  • Supports: Windows, Linux, macOS, Android, iOS
slide-9
SLIDE 9

23.04.2018 9 / 24

Similarities

  • Graphics/compute APIs
  • Programmable pipeline
  • Configurable pipeline
  • Cross-platform
  • GLSL/SPIR-V

Figure: Graphics pipeline

slide-10
SLIDE 10

23.04.2018 10 / 24

Conceptual Differences

OpenGL Vulkan Global state machine ( glClearColor() ) Object oriented local state ( VkInstance ) Everything is preconfigured Must configure everything! ( depth resources, pipeline, … ) Dynamic (can change shaders, pipeline parameters at runtime) Static (must recreate pipeline to change anything) Automatic memory management ( glGenBuffers() ) Manual memory management (buffers, images) Render loop: 'foreach object do draw()' Setup: 'record draw calls' Render loop: 'replay draw calls' Focus on graphics Unified management of compute kernels and graphical shaders

slide-11
SLIDE 11

23.04.2018 11 / 24

Minimal Project – OpenGL

  • Update GPU driver!
  • Install dev libs (xorg-dev)
  • Setup:

– Window ( 3rd party library, e.g. GLFW ) – Compile/link shaders – Minimal configuration ( clear color ) – Prepare data (VAO, VBO)

slide-12
SLIDE 12

23.04.2018 12 / 24

Minimal Project – OpenGL /2

  • Render loop

– Clear buffers (color buffer, z-buffer) – For each object:

  • Use shader
  • Update uniforms
  • Issue draw call
  • < 250 LoC
slide-13
SLIDE 13

23.04.2018 13 / 24

Minimal Project – Vulkan

  • Update GPU driver!
  • Install dev libs
  • Install SDK[1]
  • Setup:

– Window, create Instance, choose device, create

framebuffers, create renderpass, create command buffers, create sync primitives, create swapchain, …, many things ~1800 LoC

1 https://vulkan.lunarg.com/

slide-14
SLIDE 14

23.04.2018 14 / 24

Minimal Project – Vulkan /2

  • Record command buffers

– For each object: record draw call – Record clear operations

  • Render loop

– Aquire swapchain image (Extension) – Replay command buffers – Submit swapchain image (Extension)

slide-15
SLIDE 15

23.04.2018 15 / 24

Render loop – OpenGL

// Render loop glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindVertexArray(VAO); glUseProgram(SHADER); glDrawElements(MODE, COUNT, ...); glfwSwapbuffers(WINDOW);

slide-16
SLIDE 16

23.04.2018 16 / 24

Render loop – Vulkan

vkQueueWaitIdle(QUEUE); vkAcquireNextImageKHR(DEVICE, SWAPCHAIN, &IMAGE); VkSubmitInfo submit; VkPipelineStageFlags wait[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT} submit.waitSemaphoreCount = 1; submit.pWaitSemaphores = &IMAGE_AVAILABLE; submit.pWaitDstStageMask = wait;

slide-17
SLIDE 17

23.04.2018 17 / 24

Render loop – Vulkan /2

submit.commandBufferCount = 1; submit.pCommandBuffers = &COMMAND_BUFFER; submit.signalSemaphoreCount = 1; submit.pSignalSemaphores = &RENDER_FINISHED; VkPresentInfoKHR present; present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; present.waitSemaphoreCount = 1; present.pWaitSemaphores = &RENDER_FINISHED; present.swapchainCount = 1;

slide-18
SLIDE 18

23.04.2018 18 / 24

Render loop – Vulkan /3

present.pSwapchains = &SWAPCHAIN; present.pImageIndices = &IMAGE; present.pResults = nullptr; // actual command to draw something vkQueuePresentKHR(QUEUE, &present)

slide-19
SLIDE 19

23.04.2018 19 / 24

Performance – instanced

slide-20
SLIDE 20

23.04.2018 20 / 24

Performance – not instanced

slide-21
SLIDE 21

23.04.2018 21 / 24

Performance – Vulkan

There are some cases where Vulkan is faster

  • Many draw calls vs many instances
  • Hardware dependent (nVidia vs AMD)
  • Parallel command buffer creation

– Cannot concurrently issue OpenGL draw calls

slide-22
SLIDE 22

23.04.2018 22 / 24

Summary

  • Start with OpenGL!
  • Vulkan is more verbose

– Could be solved by nVidia's vkHLF[1]

  • No visual differences (so far)
  • Vulkan is faster in some specially designed cases
  • Lua[2] is our favourite embedded scripting language

1 Vulkan High Level Framework https://github.com/nvpro-pipeline/VkHLF 2 Lua programming language https://www.lua.org/

slide-23
SLIDE 23

23.04.2018 23 / 24

Demo

slide-24
SLIDE 24

23.04.2018 24 / 24

Questions

? ? ?