SDK White Paper. Occlusion Query Checking for Hidden Pixels

Similar documents
SDK White Paper. Vertex Lighting Achieving fast lighting results

SDK White Paper. Matrix Palette Skinning An Example

Technical Report. Anisotropic Lighting using HLSL

White Paper. Soft Shadows. February 2007 WP _v01

Application Note. NVIDIA Business Platform System Builder Certification Guide. September 2005 DA _v01

User Guide. Vertex Texture Fetch Water

White Paper. Solid Wireframe. February 2007 WP _v01

User Guide. TexturePerformancePBO Demo

Android PerfHUD ES quick start guide

Technical Brief. LinkBoost Technology Faster Clocks Out-of-the-Box. May 2006 TB _v01

SDK White Paper. HLSL Blood Shader Gravity Maps

Horizon-Based Ambient Occlusion using Compute Shaders. Louis Bavoil

Constant-Memory Order-Independent Transparency Techniques

NVIDIA nforce 790i SLI Chipsets

Technical Report. SLI Best Practices

Enthusiast System Architecture Certification Feature Requirements

White Paper. Texture Arrays Terrain Rendering. February 2007 WP _v01

Technical Brief. NVIDIA and Microsoft Windows Vista Getting the Most Out Of Microsoft Windows Vista

GPU LIBRARY ADVISOR. DA _v8.0 September Application Note

Technical Report. Mesh Instancing

Sparkling Effect. February 2007 WP _v01

GRID SOFTWARE FOR RED HAT ENTERPRISE LINUX WITH KVM VERSION /370.28

NVWMI VERSION 2.24 STANDALONE PACKAGE

SDK White Paper. Soft Shadows

Technical Brief. NVIDIA Quadro FX Rotated Grid Full-Scene Antialiasing (RG FSAA)

Multi-View Soft Shadows. Louis Bavoil

NVWMI VERSION 2.18 STANDALONE PACKAGE

NSIGHT ECLIPSE PLUGINS INSTALLATION GUIDE

Technical Report. SLI Best Practices

User Guide. GLExpert NVIDIA Performance Toolkit

Deinterleaved Texturing for Cache-Efficient Interleaved Sampling. Louis Bavoil

White Paper. Denoising. February 2007 WP _v01

GLExpert NVIDIA Performance Toolkit

Order Independent Transparency with Dual Depth Peeling. Louis Bavoil, Kevin Myers

Histogram calculation in CUDA. Victor Podlozhnyuk

NVIDIA SDK. NVMeshMender Code Sample User Guide

Soft Particles. Tristan Lorach

Technical Report. GLSL Pseudo-Instancing

GRID SOFTWARE FOR MICROSOFT WINDOWS SERVER VERSION /370.12

Histogram calculation in OpenCL. Victor Podlozhnyuk

User Guide. GPGPU Disease

Tuning CUDA Applications for Fermi. Version 1.2

Technical Brief. FirstPacket Technology Improved System Performance. May 2006 TB _v01

Technical Brief. AGP 8X Evolving the Graphics Interface

Cg Toolkit. Cg 1.2 Release Notes

Cg Toolkit. Cg 2.0 January 2008 Release Notes

NVIDIA CAPTURE SDK 6.1 (WINDOWS)

CUDA TOOLKIT 3.2 READINESS FOR CUDA APPLICATIONS

QUADRO SYNC II FIRMWARE VERSION 2.02

User Guide. DU _v01f January 2004

SDK White Paper. Video Filtering on the GPU. Eric Young NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050

NVIDIA CAPTURE SDK 7.1 (WINDOWS)

Cg Toolkit. Cg 1.4 rc 1 Release Notes

Cg Toolkit. Cg 2.1 beta August 2008 Release Notes

White Paper. Perlin Fire. February 2007 WP _v01

Cg Toolkit. Cg 2.0 May 2008 Release Notes

Cg Toolkit. Cg 2.2 April 2009 Release Notes

Cg Toolkit. Cg 2.1 October 2008 Release Notes

NVIDIA DEBUG MANAGER FOR ANDROID NDK - VERSION 8.0.1

Optical Flow Estimation with CUDA. Mikhail Smirnov

CUDA Particles. Simon Green

Technical Brief. NVIDIA Storage Technology Confidently Store Your Digital Assets

CUDA-GDB: The NVIDIA CUDA Debugger

Skinned Instancing. Bryan Dudash

NVIDIA CAPTURE SDK 6.0 (WINDOWS)

Cg Toolkit. Cg 1.3 Release Notes. December 2004

High Quality DXT Compression using OpenCL for CUDA. Ignacio Castaño

GRID VIRTUAL GPU FOR HUAWEI UVP Version ,

Cg Toolkit. Cg 1.2 User s Manual Addendum

Technical Report. Non-Power-of-Two Mipmap Creation

CUDA/OpenGL Fluid Simulation. Nolan Goodnight

MOSAIC CONTROL DISPLAYS

NVIDIA CUDA DEBUGGER CUDA-GDB. User Manual

GRID VIRTUAL GPU FOR HUAWEI UVP Version /

Cg Toolkit. Cg 2.2 February 2010 Release Notes

NVIDIA CUDA C GETTING STARTED GUIDE FOR MAC OS X

VIRTUAL GPU LICENSE SERVER VERSION

PASCAL COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

RMA PROCESS. vr384 October RMA Process

CUDA 2.2 Pinned Memory APIs

MAXWELL COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

NVIDIA CUDA TM Developer Guide for NVIDIA Optimus Platforms. Version 1.0

VIRTUAL GPU MANAGEMENT PACK FOR VMWARE VREALIZE OPERATIONS

GRID SOFTWARE MANAGEMENT SDK

Getting Started. NVIDIA CUDA C Installation and Verification on Mac OS X

KEPLER COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

Getting Started. NVIDIA CUDA Development Tools 2.3 Installation and Verification on Mac OS X

GRID VGPU FOR VMWARE VSPHERE Version /

VIRTUAL GPU SOFTWARE MANAGEMENT SDK

NVIDIA Tesla Compute Cluster Driver for Windows

NVIDIA CUDA VIDEO DECODER

GRID SOFTWARE FOR HUAWEI UVP VERSION /370.12

Getting Started. NVIDIA CUDA Development Tools 2.2 Installation and Verification on Mac OS X. May 2009 DU _v01

GRID LICENSING. DU _v4.6 January User Guide

NSIGHT ECLIPSE EDITION

NVJPEG. DA _v0.2.0 October nvjpeg Libary Guide

NVIDIA SLI Mosaic Mode

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

NVIDIA CUDA. Fermi Compatibility Guide for CUDA Applications. Version 1.1

Semantic and Annotation Remapping in FX Composer

Transcription:

SDK White Paper Occlusion Query Checking for Hidden Pixels WP-01402-001_v01 July 2004

Abstract Occlusion Queries Many graphics engines today waste time by attempting to draw pixels of objects that do not appear in a scene. These hidden objects are occluded from view, but often the engine rendering a scene does not know which pixels are occluded and which are visible. Tracking information about which pixels are occluded in a scene and which are visible is not a trivial design problem. Because metadata about the relation of objects in a scene is not available, most modern hardware supports the concept of an occlusion query. Occlusions queries ask the hardware to report on whether or not a selection of the frames rendered were occluded when the buffer is presented to the screen. Occlusion queries provide useful information that can be used in a variety of ways to reduce the load on the graphics card. Strategies for using the information include not drawing objects that are not visible and reducing other non-graphics related loads, such as scaling down physics and AI for objects that are not visible. The demonstration described in this document presents a technique for not drawing an extremely complex object once it becomes completely occluded. For more information, contact Bryan Dudash bdudash@nvidia.com NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050 WP-01402-001_v01 1

D3D IDirect3DQuery9 The D3D API provides an interface, called IDirect3DQuery9, which gives access to an occlusion query. Each call to IDirect3DQuery9 represents a single outstanding query. This section briefly describes the IDirect3DQuery9 API. However, please consult the DirectX9 documentation for more information. IDirect3DQuery9 API for Occlusion Queries HRESULT IDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type, IDirect3DQuery9** ppquery); To make an occlusion query, pass in D3DQUERYTYPE_OCCLUSION as the type, and a pointer to a query interface object. From then on, the query object interface is all you ll use. HRESULT IDirect3DQuery9::Issue(DWORD dwissueflags); Wrap the render calls that you are interested in monitoring with calls to Issue(D3DISSUE_BEGIN) and Issue(D3DISSUE_END). HRESULT IDirect3DQuery9::GetData(void* pdata, DWORD dwsize, DWORD dwgetdataflags); When calling GetData() on an occlusion query. The pdata pointer should point to a DWORD. dwsize should be sizeof(dword). When called with no flags, the function will return immediately. It will return S_OK if the query results have returned. If not, then the query is still outstanding. Note: You can also call with D3DGETDATA_FLUSH in dwgetdataflags. This blocks the return of the GetData call until the occlusion query result has been returned. However, this approach slows your application noticeably. ULONG IDirect3DQuery9::Release(void); Be sure to free all objects that you create. WP-01402-001_v01 2

General Occlusion Query Usage In general, most graphics cards buffer a few frames to allow some efficiency in the parallel work between the driver and the card. In order to use a single occlusion query, you are must frame lock your application to buffer only one frame ahead (for example, flush). Forcing the driver into lockstep with the card will lower performance. Because each occlusion query only represents one test, use multiple queries if you want to test multiple objects in a scene. If your simple occlusion hull does not fully cover your complex object, the object will blink in and out of the complex object. Steps to Use an Occlusion Query The steps to use an occlusion query are as follows: 1. Render the scene 2. Turn off color and z writes 3. Begin the query 4. Render an invisible simple hull object that covers complex object 5. End the query 6. Test the results of the occlusion query 7. Turn color and z writes back on 8. If coarse hull is completely occluded, then the query is done 9. If coarse hull is not occluded, then render the complex object Note: These steps show what needs to happen for a single occlusion query. If you are testing multiple objects, maintain a queue of queries to avoid putting the hardware and driver into lock-step. WP-01402-001_v01 3

LatentOcclusionQueryBank Included with this demo is a class called LatentOcclusionQueryBank. This class wraps up a queue of occlusion queries to handle the standard frame queuing that occurs on most modern graphics hardware API HRESULT GetLatestResults(DWORD *count); Returns S_OK if new results are returned since the last time GetLatestResults was called. The occlusion query fragment count is passed back in the count parameter. HRESULT BeginNextQuery(); Issues the beginning of a new query. Returns S_FALSE if it has run out of queries. HRESULT EndNextQuery(); Issues the end of a previously begun query. Returns S_FALSE if it has run out of queries or if it cannot find a previous query. unsigned int GetNumActiveQueries(); Returns the number of queries that have not yet had results delivered. This number is updated when GetLatestResults is called. void Free(); Frees all occlusion queries that have been allocated. Always call free when you are done. WP-01402-001_v01 4

Occlusion Query API Mapping LPDIRECT3DQUERY9 LatentOcclusionQueryBank GetData() GetLatestResults() Issue(D3DISSUE_BEGIN) BeginNextQuery() Issue(D3DISSUE_BEGIN) EndNextQuery() Release() Free() Note: Replacing all calls to a single IDirect3DQuery9 object with the equivalent calls into LatentOcclusionQueryBank should work smoothly. WP-01400-001_v01 5

Notice ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, MATERIALS ) ARE BEING PROVIDED AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication or otherwise under any patent or patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. NVIDIA Corporation products are not authorized for use as critical components in life support devices or systems without express written approval of NVIDIA Corporation. Trademarks NVIDIA and the NVIDIA logo are trademarks or registered trademarks of NVIDIA Corporation in the United States and other countries. Other company and product names may be trademarks of the respective companies with which they are associated. Copyright 2004 NVIDIA Corporation. All rights reserved NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050 www.nvidia.com