From the Dark Side of the Moon. GPU Programming with BGFX and Eclipse. Tony McCrary, l33t labs

Similar documents
Performance Optimization and Debug Tools for mobile games with PlayCanvas

Computer Graphics Hardware An Overview

Radeon HD 2900 and Geometry Generation. Michael Doggett

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Introduction to GPGPU. Tiziano Diamanti

JavaFX Session Agenda

Optimizing AAA Games for Mobile Platforms

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

Writing Applications for the GPU Using the RapidMind Development Platform

QCD as a Video Game?

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Developer Tools. Tim Purcell NVIDIA

Computer Graphics on Mobile Devices VL SS ECTS

How To Teach Computer Graphics

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

GPGPU Computing. Yong Cao

Parallel Web Programming

Using the Game Boy Advance to Teach Computer Systems and Architecture

Low power GPUs a view from the industry. Edvard Sørgård

Introduction to Computer Graphics with WebGL

OpenGL Performance Tuning

BRINGING UNREAL ENGINE 4 TO OPENGL Nick Penwarden Epic Games Mathias Schott, Evan Hart NVIDIA

Introduction to GPU Programming Languages

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Web Based 3D Visualization for COMSOL Multiphysics

Optimization for DirectX9 Graphics. Ashu Rege

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Introduction to Computer Graphics

Introduction GPU Hardware GPU Computing Today GPU Computing Example Outlook Summary. GPU Computing. Numerical Simulation - from Models to Software

Introduction to Computer Graphics

L20: GPU Architecture and Models

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

Example of Standard API

The Future Of Animation Is Games

GPU Architecture. Michael Doggett ATI

ipad, a revolutionary device - Apple

GPU(Graphics Processing Unit) with a Focus on Nvidia GeForce 6 Series. By: Binesh Tuladhar Clay Smith

NVIDIA GeForce GTX 580 GPU Datasheet

Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc.

Introducing PgOpenCL A New PostgreSQL Procedural Language Unlocking the Power of the GPU! By Tim Child

Radeon GPU Architecture and the Radeon 4800 series. Michael Doggett Graphics Architecture Group June 27, 2008

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

Chapter 2 - Graphics Programming with JOGL

Android Virtualization from Sierraware. Simply Secure

What is GPUOpen? Currently, we have divided console & PC development Black box libraries go against the philosophy of game development Game

GPU Profiling with AMD CodeXL

Introduction to WebGL

Lecture Notes, CEng 477

Real-Time Realistic Rendering. Michael Doggett Docent Department of Computer Science Lund university

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

AMD GPU Architecture. OpenCL Tutorial, PPAM Dominik Behr September 13th, 2009

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Vulkan on NVIDIA GPUs. Piers Daniell, Driver Software Engineer, OpenGL and Vulkan

Game Design From Concepts To Implementation

Visualizing Data: Scalable Interactivity

Lecture 1 Introduction to Android

Midgard GPU Architecture. October 2014

Advanced Graphics and Animations for ios Apps

Press Briefing. GDC, March Neil Trevett Vice President Mobile Ecosystem, NVIDIA President Khronos. Copyright Khronos Group Page 1

ARM Processors for Computer-On-Modules. Christian Eder Marketing Manager congatec AG

Visualizing gem5 via ARM DS-5 Streamline. Dam Sunwoo ARM R&D December 2012

Windows Phone 7 Game Development using XNA

Lecture 3: Modern GPUs A Hardware Perspective Mohamed Zahran (aka Z) mzahran@cs.nyu.edu

Overview. Lecture 1: an introduction to CUDA. Hardware view. Hardware view. hardware view software view CUDA programming

How To Develop For A Powergen 2.2 (Tegra) With Nsight) And Gbd (Gbd) On A Quadriplegic (Powergen) Powergen Powergen 3

Programmable Graphics Hardware

Equalizer. Parallel OpenGL Application Framework. Stefan Eilemann, Eyescale Software GmbH

Vector Web Mapping Past, Present and Future. Jing Wang MRF Geosystems Corporation

TEGRA X1 DEVELOPER TOOLS SEBASTIEN DOMINE, SR. DIRECTOR SW ENGINEERING

AT&T Connect System Requirements for End Users v9.5. March 2013

CLOUD GAMING WITH NVIDIA GRID TECHNOLOGIES Franck DIARD, Ph.D., SW Chief Software Architect GDC 2014

Choosing a Computer for Running SLX, P3D, and P5

Intel Graphics Media Accelerator 900

Reminders. Lab opens from today. Many students want to use the extra I/O pins on

Effective Java Programming. efficient software development

This Unit: Putting It All Together. CIS 501 Computer Architecture. Sources. What is Computer Architecture?

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Overview of CS 282 & Android

Geo-Scale Data Visualization in a Web Browser. Patrick Cozzi pcozzi@agi.com

Android Development: Part One

A Crash Course on Programmable Graphics Hardware

Dynamic Resolution Rendering

Color correction in 3D environments Nicholas Blackhawk

Intel Media Server Studio - Metrics Monitor (v1.1.0) Reference Manual

Standardization with ARM on COM Qseven. Zeljko Loncaric, Marketing engineer congatec

Finding Performance and Power Issues on Android Systems. By Eric W Moore

QNX Software Development Platform 6.6. Screen Graphics Subsystem Developer's Guide

farmerswife Contents Hourline Display Lists 1.1 Server Application 1.2 Client Application farmerswife.com

OpenGL & Delphi. Max Kleiner. 1/22

How To Use An Amd Graphics Card In Greece And (Amd) With Greege (Greege) With An Amd Greeper 2.2.

Crosswalk: build world class hybrid mobile apps

A Hybrid Visualization System for Molecular Models

Accelerating Intensity Layer Based Pencil Filter Algorithm using CUDA

Hardware design for ray tracing

Transcription:

From the Dark Side of the Moon GPU Programming with BGFX and Eclipse Tony McCrary, l33t labs

What is BGFX? Open source C/C++ GPU rendering library Developed by Branimir Karadzic Provides a way to render 2D/3D graphics BGFX executes rendering commands on OpenGL, Direct3D, Apple Metal

What is BGFX? BGFX provides a low level style API BGFX is NOT a scene graph, based around sorted draw calls

What is Twilight BGFX? Manual Java binding to BGFX Also includes a binding to NanoVG, a 2D vector graphics library Simple windowing library based on SDL (Simple Direct media Layer) SWT integration - Render 2D/3D graphics into SWT controls Eclipse integration - Shader editor and project builder

What is a GPU? GPU stands for Graphics Programming Unit Originally designed to accelerate graphics for video games and scientific/engineering purposes Specialized hardware designed for high floating point performance Extremely parallel execution model

GPU graphics pipeline Based around rasterizing triangles Triangles are made of up a series of vertices Vertices are transformed from 3D world space and projected into screen space Once projected onto the 2D framebuffer, the fragments contained within the triangle are shaded

GPU graphics pipeline

CPU vs GPU High end Intel i7 clock speed 3.60 Ghz High end Nvidia Titan clock speed 836 Mhz

CPU vs GPU High end Intel i7 cores 6 cores (12 threads) High end Nvidia GPU cores 2688 cores (stream processors)

OpenGL? Direct3D? Metal? Who Cares? Things are not what they seem with OpenGL Direct3D is Windows only Metal is OS X only Madness: They all do the same things, in basically the same way, on the same hardware but are totally incompatible! Most developers don't really care which API is used, as long as their triangles show up!

Desktop Platforms Linux (OpenGL), OSX (Metal), Windows (Direct3D) Nvidia (Nouveau, Proprietary), AMD (Open source, Proprietary), Intel (Gallium) Each generation of hw from the same vendor can be vastly different Even drivers for the same hardware are different from OS to OS

GPU graphics pipeline

Write once, Run on any GPU Java platform is an idealized computer that allows programmers to focus on solving problems Platform issues, quirks and oddities are encapsulated by the underlying runtime BGFX provides a similar idealized interface to the GPU

BGFX Supported Platforms Direct3D 9 Direct3D 11 Direct3D 12 (WIP) Metal (WIP) OpenGL 2.1 OpenGL 3.1+ OpenGL ES 2 OpenGL ES 3.1 WebGL 1.0 Android (14+, ARM, x86, MIPS) asm.js/emscripten (1.25.0) FreeBSD ios (iphone, ipad, AppleTV) Linux MIPS Creator CI20 Native Client (PPAPI 37+, ARM, x86, x64, PNaCl) OSX (10.9+) RaspberryPi SteamLink Windows (XP, Vista, 7, 8, 10) WinRT (WinPhone 8.0+)

bgfx.init(); bgfx.reset(width, height, reset); while(rendering) { bgfx.setviewrect(0, 0, 0, width, height); bgfx.touch(0); bgfx.setvertexbuffer(myvertexbuffer); bgfx.setindexbuffer(myindexbuffer); bgfx.submit(0, myshaderprogram); } bgfx.frame(); bgfx.shutdown();

BGFX Execution Model Render calls are encoded as data into a command buffer Multi-threaded or single threaded rendering Multi-threaded rendering allows you to generate calls for a frame while the last frame is rendering

BGFX Execution Model When a frame is finished being built, the calls are sorted and optimized according to state Calls are sorted according to state changes, drastically improving performance After call optimization, a platform specific renderer is executed Command optimization is roughly analagous to HotSpot's JIT optimization

Buffers, Buffers, and... Buffers Triangles are defined primarily by two kinds of buffers: Vertex and Index Think of Vertex and Index buffers are specialized types of data arrays (not java arrays) Buffers are generally created by CPU code and then used by shader programs to draw graphics Textures are a specialized kind of buffer that can be sampled at various 2D/3D locations

Buffer Updates Variants of each type of buffer exist depending on how you use them Static buffers are never updated, you define them once and they are immutable Dynamic buffers are used for buffers that are updated regularly (once a frame or more) Transient buffers are for buffers that are updated every frame

Vertex Buffers Define a set of vertices, which are a set of "Vertex Attributes" Attributes typically include position in local space, vertex color, texture coordinates and more Vertex Attributes are user definable are used by shaders during rendering Example vertex [ 5.0, 5.0, 5.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.5 ] pos color texcoord The above vertex has 3 attributes: 3 float position (XYZ), 4 float color (RGBA), 2 texture coodinates (UV) BGFX defines how a vertex is structured via VertexDecl

Index Buffers Define which vertices belong to a given rendering primitive (3 vertices -> Triangle) Usually defined as 16-bit or 32-bit integers, literally as offsets into an associated vertex buffer Example index buffer [ 0, 1, 2 ] Defines a trangles whose constituent vertices are at location 0, 1, 2 in the vertex buffer Note that these indices are not byte or data type offsets but for the entire vertex

Textures Contain raster data, similar to image formats Data is accessed in shaders via a sampler Can be updated dynamically and used for various purposes (colors, normals, etc.)

What are Shader Programs? Small procedural programs that execute on a GPU's numerous processing cores Each Shader Program is comprised of individual Shaders Each Shader is linked into the Shader Program and execute at various stages (Vertex, Fragment, etc.) Contain code for each step in the rendering pipeline

BGFX Shading Language Implements in a procedural C style similar to most shading languages Compiled with included shaderc shader compiler Language compiles down to plaform specific shaders for distribution Includes preprocesor for advanced compilation

Vertex Shaders Transforms a vertex from one space to another using matrices Attributes are the various values that comprise a given vertex (position, color, normal(direction), texture coordinates, etc. Passes Varying values to the fragment shaders (interpolation)

Vertex Shaders Doesn't actually do any shading (!?) Execute by taking processing one vertex at a time Uniforms are like fields in a Java class, they are read when the shader executes

$input a_position, a_color0, a_texcoord0 $output v_color0, v_texcoord0 #include "common.sh" void main() { vec4 pos = vec4(a_position, 1.0); gl_position = mul(u_modelviewproj, pos); v_color0 = a_color0; v_texcoord0 = a_texcoord0; }

Fragment Shaders Runs after the vertex shader has transformed the primitive Fragment shaders actually shade A Fragment is similar in concept to a pixel in a framebuffer Texture color can be sampled and written into a fragment

$input v_color0, v_texcoord0 SAMPLER2D(u_texColor, 0); void main() { gl_fragcolor = texture2d(u_texcolor, v_texcoord0); }

Compute Shaders Perform general purpose computation on the GPU GPU floating performance is often much higher than possible on even a fast CPU

2D Graphics? 3D Graphics? Whats the difference? 2D is contained in 3D space, with BGFX you can do both 2D is merely a different kind of projection, orthographic instead of perspective

Ultra fast 2D graphics with NanoVG NanoVG is a technology originally developed by Mikko Mononen Originally an OpenGL 2D vector graphics API but has since been ported to BGFX Provides 2D rendering functions like drawing lines, rectangles, text and other drawing primitives Similar in principle to SWT's GC operations, Swing's Graphics2D

BGFX Eclipse Integration SWT Integration (BGFXCanvas) BGFX Project Nature, Builder, Editor

Rendering into SWT and Eclipse with BGFXCanvas BGFXCanvas is a standard SWT widget, similar in principle to Canvas but for GPU graphics Provides callback functions for submitting and rendering calls Provides full access to BGFX and NanoVG APIs

Writing BGFX Shaders within Eclipse Uses an incremental project builder to build BGFX shaders on the fly Project builder uses shaderc to generate platform specific shaders Shader editor provides syntax highlighting

Demos

Future More platform support for Java bindings (mobile, web, etc) Tesselation and Geometry Shaders JavaFX BGFXNode Zero Overhead JNI Bindings Get legal/ip into shape for use with professional open source projects

JavaFX BGFXNode JavaFX does not expose shader functionality to end users, with no support planned JavaFX uses Direct3D on Windows, OpenGL on Linux and Mac, so you can't choose one to integrate BGFX could provide a way to create complex and high performance 2D/3D graphics within JavaFX BGFXNode would be a way to execute a BGFX renderer on top of your platform's JavaFX Prism implementation

Zero Overhead JNI Bindings BGFX's command buffer allows for (near) zero overhead JNI interop Generate command data buffer entirely on the Java side into a direct ByteBuffer Once a frame is finished, pass the pointer over to the waiting BGFX renderer for execution

Software Licenses BGFX, Twilight BGFX bindings are BSD licensed SDL, NanoVG are zlib SWT integration and Eclipse plugins are licensed under the EPL

Links Twilight BGFX Repo https://github.com/enleeten/twilight-bgfx BGFX C/C++ Repo https://github.com/bkaradzic/bgfx

Please Evaluate My Talk Sign-in: www.eclipsecon.org Select session from schedule