The OpenGL Framebuffer Object Extension. Simon Green. NVIDIA Corporation



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

Advanced Visual Effects with Direct3D

OpenGL Performance Tuning

Optimizing AAA Games for Mobile Platforms

Image Synthesis. Transparency. computer graphics & visualization

The OpenGL R Graphics System: A Specification (Version 3.3 (Core Profile) - March 11, 2010)

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

OpenGL R Graphics with the X Window System R (Version 1.4)

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

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

Experiences with 2-D and 3-D Mathematical Plots on the Java Platform

GPU Christmas Tree Rendering. Evan Hart

Overview Motivation and applications Challenges. Dynamic Volume Computation and Visualization on the GPU. GPU feature requests Conclusions

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Dynamic Resolution Rendering

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

OpenGL & Delphi. Max Kleiner. 1/22

Developer Tools. Tim Purcell NVIDIA

Beyond 2D Monitor NVIDIA 3D Stereo

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

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

Computer Graphics Hardware An Overview

Intel 845G/GL Chipset Dynamic Video Memory Technology

Methodology for Lecture. Review of Last Demo

GPU Architecture. Michael Doggett ATI

WebCL for Hardware-Accelerated Web Applications. Won Jeon, Tasneem Brutch, and Simon Gibbs

3D Stereoscopic Game Development. How to Make Your Game Look

How To Use An Amd Ramfire R7 With A 4Gb Memory Card With A 2Gb Memory Chip With A 3D Graphics Card With An 8Gb Card With 2Gb Graphics Card (With 2D) And A 2D Video Card With

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

INTRODUCTION TO RENDERING TECHNIQUES

QCD as a Video Game?

Introduction to GPGPU. Tiziano Diamanti

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Affdex SDK for Windows!

SAPPHIRE TOXIC R9 270X 2GB GDDR5 WITH BOOST

Shadows. Shadows. Thanks to: Frédo Durand and Seth Teller MIT. Realism Depth cue

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

Aston University. School of Engineering & Applied Science

Lesson 10: Video-Out Interface

Workstation Applications for Windows. NVIDIA MAXtreme User s Guide

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

GPUs Under the Hood. Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology

QuickSpecs. NVIDIA Quadro K4200 4GB Graphics INTRODUCTION. NVIDIA Quadro K4200 4GB Graphics. Overview

NVPRO-PIPELINE A RESEARCH RENDERING PIPELINE MARKUS TAVENRATH MATAVENRATH@NVIDIA.COM SENIOR DEVELOPER TECHNOLOGY ENGINEER, NVIDIA

Quick Tutorial. Overview. The NVIDIA Software Improvement Program. Creating an Effect

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

NVFX : A NEW SCENE AND MATERIAL EFFECT FRAMEWORK FOR OPENGL AND DIRECTX. TRISTAN LORACH Senior Devtech Engineer SIGGRAPH 2013

L20: GPU Architecture and Models

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

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Color correction in 3D environments Nicholas Blackhawk

NVIDIA GeForce GTX 580 GPU Datasheet

OpenGL 4.3 and Beyond. Mark Kilgard

How To Write A Cg Toolkit Program

QuickSpecs. NVIDIA Quadro K5200 8GB Graphics INTRODUCTION. NVIDIA Quadro K5200 8GB Graphics. Overview. NVIDIA Quadro K5200 8GB Graphics J3G90AA

SAPPHIRE VAPOR-X R9 270X 2GB GDDR5 OC WITH BOOST

Universal Serial Bus (USB)

Performance Optimization and Debug Tools for mobile games with PlayCanvas

QuickSpecs. NVIDIA Quadro K5200 8GB Graphics INTRODUCTION. NVIDIA Quadro K5200 8GB Graphics. Technical Specifications

CORBA Programming with TAOX11. The C++11 CORBA Implementation

Computer Graphics. Computer graphics deals with all aspects of creating images with a computer

Rapid Android Development

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

QuickSpecs. NVIDIA Quadro K2200 4GB Graphics INTRODUCTION. NVIDIA Quadro K2200 4GB Graphics. Technical Specifications

Intel 810 and 815 Chipset Family Dynamic Video Memory Technology

OpenGL 4.4 API Reference Card Page 1

GPGPU Computing. Yong Cao

3D Application and Game Development With OpenGL

Awards News. GDDR5 memory provides twice the bandwidth per pin of GDDR3 memory, delivering more speed and higher bandwidth.

Introduction to graphics and LCD technologies. NXP Product Line Microcontrollers Business Line Standard ICs

NVIDIA workstation 3D graphics card upgrade options deliver productivity improvements and superior image quality

Intel 865G Chipset Dynamic Video Memory Technology

Deferred Shading & Screen Space Effects

Learning Modern 3D Graphics Programming. Jason L. McKesson

VA (Video Acceleration) API. Jonathan Bian 2009 Linux Plumbers Conference

RADEON 9700 SERIES. User s Guide. Copyright 2002, ATI Technologies Inc. All rights reserved.

Enabling OpenCL Acceleration of Web Applications

Java (12 Weeks) Introduction to Java Programming Language

Filtered Views for Microsoft Dynamics CRM

Advanced Graphics and Animations for ios Apps

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

QuickSpecs. NVIDIA Quadro K1200 4GB Graphics INTRODUCTION PERFORMANCE AND FEATURES. Overview

Release Notes. Please refer to the Intel RealSense 3D Camera Software License.rtf for license terms and conditions.

BCC Multi Stripe Wipe

Several tips on how to choose a suitable computer

C++ INTERVIEW QUESTIONS

Input and Interaction

iz3d Stereo Driver Description (DirectX Realization)

How To Teach Computer Graphics

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

ntier Verde: Simply Affordable File Storage No previous storage experience required

3D Computer Games History and Technology

Transcription:

The OpenGL Framebuffer Object Extension Simon Green NVIDIA Corporation

Overview Why render to texture? P-buffer / ARB render texture review Framebuffer object extension Examples Future directions

Why Render To Texture? Allows results of rendering to framebuffer to be directly read as texture Better performance avoids copy from framebuffer to texture (glcopytexsubimage2d) uses less memory only one copy of image but driver may sometimes have to do copy internally some hardware has separate texture and FB memory different internal representations Applications dynamic textures procedurals, reflections multi-pass techniques anti-aliasing, aliasing, motion blur, depth of field image processing effects (blurs etc.) GPGPU provides feedback loop

WGL_ARB_pbuffer Pixel buffers Designed for off-screen rendering Similar to windows, but non-visible Window system specific extension Select from an enumerated list of available pixel formats using ChoosePixelFormat() DescribePixelFormat()

Problems with PBuffers Each pbuffer usually has its own OpenGL context (Assuming they have different pixel formats) Can share texture objects, display lists between pbuffers using wglsharelists() Painful to manage, causes lots of bugs Switching between pbuffers is expensive wglmakecurrent() causes context switch Each pbuffer has its own depth, stencil, aux buffers Cannot share depth buffers between pbuffers

WGL_ARB_render_texture Allows the color or depth buffer of a pbuffer to be bound as a texture BOOL wglbindteximagearb(hpbufferarb hpbuffer, int ibuffer BOOL wglreleaseteximagearb(hpbufferarb hpbuffer, int ibuffer) Window system specific GLX version of specification was never defined MacOS X - APPLE_pixel_buffer Texture format is determined by pixel format of pbuffer Portable applications need to create a separate pbuffer for each renderable texture

Pbuffer Tricks The front and back buffers of a double- buffered pbuffer can be bound as separate textures gldrawbuffer(gl_front); // draw to front gldrawbuffer(gl_back); // draw to back // bind front and back buffers as textures wglbindteximagearb(pbuffer,, WGL_FRONT_LEFT_ARB); wglbindteximagearb(pbuffer,, WGL_BACK_LEFT_ARB); This gives you two buffers that you can switch between without incurring context switching cost On systems that support multiple render targets (ARB_draw_buffers) you can also use AUX buffers

Render To Texture And Anti-Aliasing Aliasing Render to texture doesn t t work with multi- sample anti-aliasing aliasing current texture hardware isn t t capable of reading from a multi-sampled buffer could be implemented in driver using copy Common problem with post-processing processing effects in games Solution: create a normal multi-sampled pbuffer,, and use glcopyteximage2d to copy from this to a texture the copy performs the down-sampling automatically Also possible to do your own super-sample sample anti-aliasing aliasing in the application much more expensive than multi-sampling

Anti-Aliasing Aliasing with Post Processing Without AA With AA

The Framebuffer Object Extension Specification finally published! Available in beta drivers from NVIDIA http://developer.nvidia.com

Framebuffer Object Advantages Only requires a single OpenGL context switching between framebuffers is faster than switching between pbuffers (wglmakecurrent) No need for complicated pixel format selection format of framebuffer is determined by texture or renderbuffer format puts burden of finding compatible formats on developer More similar to Direct3D render target model makes porting code easier Renderbuffer images and texture images can be shared among framebuffers e.g. share depth buffers between color targets saves memory

EXT_framebuffer_object OpenGL framebuffer is a collection of logical buffers color, depth, stencil, accumulation Framebuffer object extension provides a new mechanism for rendering to destinations other than those provided by the window system window system independent Destinations known as framebuffer- attachable images.. Can be: off-screen buffers (Renderbuffers( Renderbuffers) textures

Framebuffer Object Architecture Framebuffer object Texture objects Color attachment 0... Color attachment n Texture image Depth attachment Stencil attachment Other state Renderbuffer objects Renderbuffer image

Terminology Renderbuffer image 2D array of pixels. Part of a renderbuffer object. Framebuffer-attachable attachable image 2D array of pixels that can be attached to a framebuffer. Texture images and renderbuffer images are examples. Attachment point State that references a framebuffer-attachable attachable image. One each for color, depth and stencil buffer of a framebuffer. Attach the act of connecting one object to another. Similar to bind. Framebuffer attachment completeness Framebuffer completeness

Framebuffers and Renderbuffers Introduces two new OpenGL objects: Framebuffer (FBO) collection of framebuffer-attachable attachable images (e.g. color, depth, stencil) plus state defining where output of GL rendering is directed equivalent to window system drawable Renderbuffer (RB) contains a simple 2D image no mipmaps, cubemap faces etc. stores pixel data resulting from rendering cannot be used as textures

Framebuffer Objects When a framebuffer object is bound its attached images are the source and destination for fragment operations Color and depth textures Supports multiple color attachments for MRT Color, depth or stencil renderbuffers

Framebuffer Object API void GenFramebuffersEXT(sizei n, uint *framebuffers); void DeleteFramebuffersEXT(sizei n, const uint *framebuffers); boolean IsFramebufferEXT(uint framebuffer); void BindFramebufferEXT(enum target, uint framebuffer); enum CheckFramebufferStatusEXT(enum target);

Framebuffer Object API void FramebufferTexture1DEXT(enum target, enum attachment, enum textarget, uint texture, int level); void FramebufferTexture2DEXT(enum target, enum attachment, enum textarget, uint texture, int level); void FramebufferTexture3DEXT(enum target, enum attachment, enum textarget, uint texture, int level, int zoffset); void FramebufferRenderbufferEXT(enum target, enum attachment, enum renderbuffertarget, uint renderbuffer); void GetFramebufferAttachmentParameterivEXT(enum target, enum attachment, enum pname, int *params); void GenerateMipmapEXT(enum target);

Managing FBOs and Renderbuffers Creating and destroying FBOs (and Renderbuffers) ) is easy - similar to texture objects void GenFramebuffersEXT(sizei sizei n, uint *framebuffers); void DeleteFramebuffersEXT(sizei sizei n, const uint *framebuffers); void BindFramebufferEXT(enum enum target, uint framebuffer); Can also check if a given identifier is a framebuffer object (rarely used) boolean IsFramebufferEXT(uint uint framebuffer);

Binding an FBO void BindFramebufferEXT(enum enum target, uint framebuffer); Makes given FBO current all GL operations occur on attached images target must be FRAMEBUFFER_EXT framebuffer is FBO identifier if framebuffer==0, GL operations operate on window- system provided framebuffer (i.e. the window). This is the default state. Set of state that can change on a framebuffer bind: AUX_BUFFERS, MAX_DRAW_BUFFERS, STEREO, SAMPLES, X_BITS, DOUBLE_BUFFER and a few more

Attaching Textures to a Framebuffer void FramebufferTexture2DEXT(enum target, enum attachment, enum textarget, uint texture, int level); Attaches image from a texture object to one of the logical buffers of the currently bound framebuffer target must be FRAMEBUFFER_EXT attachment is one of: COLOR_ATTACHMENT0_EXT... COLOR_ATTACHMENTn_EXT, DEPTH_ATTACHMENT_EXT, STENCIL_ATTACHMENT_EXT textarget must be one of: TEXTURE_2D, TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP_POSITIVE_X etc. level is the mipmap level of the texture to attach texture is the texture object to attach if texture==0, the image is detached from the framebuffer Other texture dimensions are similar for 3D textures, z-offset specifies slice

Renderbuffer API void GenRenderbuffersEXT(sizei n, uint *renderbuffers); void DeleteRenderbuffersEXT(sizei n, const uint *renderbuffers); boolean IsRenderbufferEXT(uint renderbuffer); void BindRenderbufferEXT(enum target, uint renderbuffer); void RenderbufferStorageEXT(enum target, enum internalformat, sizei width, sizei height); void GetRenderbufferParameterivEXT(enum target, enum pname, int* params);

Defining RenderBuffer Storage void RenderbufferStorageEXT(enum enum target, enum internalformat, sizei width, sizei height); Defines format and dimensions of a Renderbuffer similar to TexImage call, but without image data can read and write data using Read/DrawPixels etc. target must be RENDERBUFFER_EXT internalformat can be normal texture format (e.g. GL_RGBA8, GL_DEPTH_COMPONENT24) or: STENCIL_INDEX1_EXT STENCIL_INDEX4_EXT STENCIL_INDEX8_EXT STENCIL_INDEX16_EXT

Attaching Renderbuffers to a Framebuffer void FramebufferRenderbufferEXT(enum target, enum attachment, enum renderbuffertarget, uint renderbuffer); Attaches given renderbuffer as one of the logical buffers of the currently bound framebuffer target must be FRAMEBUFFER_EXT attachment is one of: COLOR_ATTACHMENT0_EXT... COLOR_ATTACHMENTn_EXT Maximum number of color attachments implementation dependent - query MAX_COLOR_ATTACHMENTS_EXT DEPTH_ATTACHMENT_EXT STENCIL_ATTACHMENT_EXT renderbuffertarget must be RENDERBUFFER_EXT renderbuffer is a renderbuffer id

Generating Mipmaps void GenerateMipmapEXT(enum enum target); Automatically generates mipmaps for texture image attached to target Generates same images as GL_SGIS_generate_mipmap extension filtering is undefined, most likely simple 2x2 box filter Implemented as new entry point for complicated reasons (see spec).

Framebuffer Completeness Framebuffer is complete if all attachments are consistent texture formats make sense for attachment points i.e. don t t try and attach a depth texture to a color attachment all attached images must have the same width and height all images attached to COLOR_ATTACHMENT0_EXT - COLOR_ATTACHMENTn_EXT must have same format If not complete, glbegin will generate error INVALID_FRAMEBUFFER_OPERATION

Checking Framebuffer Status enum CheckFramebufferStatusEXT(enum enum target); Should always be called after setting up FBOs Returns enum indicating why framebuffer is incomplete: FRAMEBUFFER_COMPLETE FRAMEBUFFER_INCOMPLETE_ATTACHMENT FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT FRAMEBUFFER_INCOMPLETE_FORMATS_EXT FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT FRAMEBUFFER_UNSUPPORTED FRAMEBUFFER_STATUS_ERROR Completeness is implementation-dependent if result is FRAMEBUFFER_UNSUPPORTED,, application should try different format combinations until one succeeds

FBO Performance Tips Don t t create and destroy FBOs every frame Try to avoid modifying textures used as rendering destinations using TexImage, CopyTexImage etc.

FBO Usage Scenarios FBO allows several ways of switching between rendering destinations In order of increasing performance: Multiple FBOs create a separate FBO for each texture you want to render to switch using BindFramebuffer() can be 2x faster than wglmakecurrent() in beta NVIDIA drivers Single FBO, multiple texture attachments textures should have same format and dimensions use FramebufferTexture() to switch between textures Single FBO, multiple texture attachments attach textures to different color attachments use gldrawbuffer() to switch rendering to different color attachments

Simple FBO Example #define CHECK_FRAMEBUFFER_STATUS() \ { \ GLenum status; \ status = glcheckframebufferstatusext(gl_framebuffer_ext); \ switch(status) { \ case GL_FRAMEBUFFER_COMPLETE_EXT: \ break; \ case GL_FRAMEBUFFER_UNSUPPORTED_EXT: \ /* choose different formats */ \ break; \ default: \ /* programming error; will fail on all hardware */ \ assert(0); \ } \ }

Simple FBO Example GLuint fb, depth_rb, tex; // create objects glgenframebuffersext(1, &fb); // frame buffer glgenrenderbuffersext(1, &depth_rb); // render buffer glgentextures(1, &tex); // texture glbindframebufferext(gl_framebuffer_ext, fb); // initialize texture glbindtexture(gl_texture_2d, tex); glteximage2d(gl_texture_2d, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); // (set texture parameters here) // attach texture to framebuffer color buffer glframebuffertexture2dext(gl_framebuffer_ext, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);

Simple FBO Example // initialize depth renderbuffer glbindrenderbufferext(gl_renderbuffer_ext, depth_rb); glrenderbufferstorageext(gl_renderbuffer_ext, GL_DEPTH_COMPONENT24, width, height); // attach renderbuffer to framebuffer depth buffer glframebufferrenderbufferext(gl_framebuffer_ext, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb); CHECK_FRAMEBUFFER_STATUS();... // render to the FBO glbindframebufferext(gl_framebuffer_ext, fb); // (draw something here, rendering to texture) // render to the window, using the texture glbindframebufferext(gl_framebuffer_ext, 0); glbindtexture(gl_texture_2d, tex);

Future Directions Currently an EXT extension will be promoted to an ARB extension once the design is proven Got feedback? Give it to the OpenGL ARB! Future extensions Render to vertex attribute likely built on top of Renderbuffers Format groups like pixel formats, defines groups of formats that work together for a given implementation Multisampling, accumulation buffer support

Thanks Jeff Juliano, Mike Strauss and the rest of the NVIDIA OpenGL driver team Jeremy Sandmel,, Jeff Juliano and the rest of the ARB Superbuffers working group