SLI Zone
NVIDIA.com Developer Home

SDK 9.52 Code Samples - GPGPU

In each release of our SDK you will find hundreds of code samples, effects, whitepapers, and more to help you take advantage of the latest technology from NVIDIA. Check out our SDK Home Page to download the complete SDK, or browse through individual code samples below. You can also click on the video links for a quick preview, or the thumbnail images for a gallery of larger images.

This code is released free of charge for use in derivative works, whether academic, commercial, or personal. (Full License)

Select the category to view:

Simple Framebuffer ObjectFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This simple code example shows how to use the framebuffer object (FBO) extension to perform rendering to texture in OpenGL. The code renders a wireframe teapot to an off-screen frame buffer object, binds this as a texture and then displays it to the window on a textured quad.The FBO extension has the advantages that it is window system independent and does not require a separate OpenGL context for each render target. See the GL_EXT_framebuffer_object spec for more details.
  Minimum Required GPU

Graphics API Type





Download


Image HistogramFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This example implements an image histogram using occlusion queries. For a histogram with n entries this method takes n passes. It renders the scene to a texture, and then for each bucket in the histogram renders a quad with the scene texture, using a fragment program that discards pixels outside the range of interest. Occlusion query is used to count how many pixels remain, and were therefore inside the range.
  Minimum Required GPU

Graphics API Type





Download


GPU ClothFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This sample demonstrates how to use Shader Model 3.0 to simulate and render cloth on the GPU. The cloth vertex positions are computed through several pixel shaders and saved into a texture. A vertex shader then reads these positions using Vertex Texture Fetch (VTF) to render the cloth.
  Minimum Required GPU

Graphics API Type


User Guide  
Whitepaper  
Video  
Download


Discrete Cosine TransformFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This example shows how to implement the forward and inverse discrete cosine transform (DCT) using fragment programs. The DCT operates on 8x8 pixel blocks and is used as the basis for JPEG compression. The code can perform the forward DCT followed by the inverse DCT at around 160 frames per second for a 512 x 512 monochrome image on a GeForce 6800. This could be extended into a complete hardware accelerated JPEG viewer by performing the rest of the JPEG algorithm (entropy decompression etc.) on the CPU and adding resampling and color space conversion to the GPU code.
  Minimum Required GPU

Graphics API Type





Download


Get GPU And System InfoFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This sample querries Microsoft's IDXDiagContainer interface to retrieve graphics hardware and system information. Most notable is the retrieval of the amount of physical video memory on the primary graphics device. The IDXDiagContainer interface is wrapped in a convenient C++ class, and no IDirect3DDevice9 object is required to retrieve the information.
  Minimum Required GPU

Graphics API Type



Whitepaper  

Download


FFT on the GPUFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This sample presents an implementation of FFTs on the GPU, performing image reconstruction on magnetic resonance imaging (MRI) and ultrasonic imaging data. This implementation automatically balances the load between the vertex processor, the rasterizer, and the fragment processor; it also uses several other novel techniques to obtain high performance on the Quadro NV4x family of GPUs. This technique is described in GPU Gems 2: Programming Techniques for High-Performance Graphics and General-Purpose Computation.
  Minimum Required GPU

Graphics API Type


User Guide  
Whitepaper  

Download


Medical Image ReconstructionFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

Fast Fourier Transforms (FFT) are used to reconstruct images from medical scans. This sample presents an implementation of FFTs on the GPU. This implementation automatically balances the load between the vertex processor, the rasterizer, and the fragment processor; it also uses several other novel techniques to obtain high performance on the Quadro NV4x family of GPUs. This technique is described in GPU Gems 2: Programming Techniques for High-Performance Graphics and General-Purpose Computation.
  Minimum Required GPU

Graphics API Type


User Guide  
Whitepaper  

Download


GPGPU DiseaseFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This sample creates a disturbing dynamic disease effect. It simulates a phenomenon known as chemical reaction-diffusion, by solving the governing partial differential equations in a fragment program. The result is an endless variety of changing patterns that are then used to generate bump and texture maps which are applied to a mesh with various shaders.
  Minimum Required GPU

Graphics API Type


User Guide  


Download


GPGPU FluidFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This code sample demonstrates fast, realistic fluid dynamics simulation on the GPU. The sample solves the Navier-Stokes equations for incompressible fluid flow using a technique originally presented at SIGGRAPH 1999 by Jos Stam. The sample allows the user to draw arbitrary obstacles and flow viscous or inviscid fluid around them.
  Minimum Required GPU

Graphics API Type


User Guide  
Whitepaper  

Download


SuperflowFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

This example illustrates the use of OpenGL for flow visualization. The fluid simulation is based on Jos Stam's paper "A Simple Fluid Solver based on the FFT".

To visualize the flow, the velocity field from the simulation is converted into a 2D texture. This velocity texture is then used to offset the coordinates of another texture lookup into a 2D image. The displaced image is rendered back to the frame buffer, so that over time the image gets distorted in the direction of the fluid flow. A small amount of the original image is blended back on top of the original scene each frame so that it doesn't become too distorted.
  Minimum Required GPU

Graphics API Type





Download


NVIDIA Control Panel APIFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

The sample exercises functionality available through the NVIDIA Control Panel (NVCpl) API, in particular, what type of AGP or PCIExpress mode the GPU is in, how much physical video memory the GPU has, what the user's control panel settings for AA, number of buffered frames as well as other current display settings, and primary display and device information. In addition, it lets developers query if the system supports SLI and allows them to choose an SLI mode for their application. For declarations of externally accessible NVIDIA Control Panel API methods, please see NvPanelApi.h.
  Minimum Required GPU

Utility


User Guide  


Download


NVDeviceIDFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

A simple example to identify NVIDIA's product families through the use of Direct3D adapter identifier. Select the userguide link below to access an updated list of NVIDIA device ids.
  Minimum Required GPU

Graphics API Type


User Guide  


Download


Vendor/Device ID Sample ExampleFor a direct link to this sample, right-click and copy the URL (shortcut) of this link icon.

A simple sample to show how to retrieve vendor and device ID's for the primary display device. Select the userguide link below to access an updated list of NVIDIA device ids.
  Minimum Required GPU

Utility


User Guide  


Download

Last Update: Jan 17, 2007
NVPerfHUD 4