13.07.2015 Views

Paper - IDAV: Institute for Data Analysis and Visualization

Paper - IDAV: Institute for Data Analysis and Visualization

Paper - IDAV: Institute for Data Analysis and Visualization

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Glift: Generic, Efficient, R<strong>and</strong>om-Access GPU <strong>Data</strong> Structures · 33structures, neither previously demonstrated on GPUs: adaptive shadow maps <strong>and</strong> octree 3D paint. The implementation<strong>and</strong> description of these applications is greatly simplified by the Glift abstraction <strong>and</strong> the separation of algorithm fromdata structures.We believe that the use of sophisticated <strong>and</strong> high-per<strong>for</strong>mance data structures on graphics hardware will only increasein importance in the coming years. In the same way that efficient implementations of data structure librarieslike the St<strong>and</strong>ard Template Library (STL) <strong>and</strong> Boost have become integral in CPU program development, an efficientGPU data structure abstraction makes it possible <strong>for</strong> vendors to offer implementations optimized <strong>for</strong> their architecture<strong>and</strong> application developers to more easily create complex applications.APPENDIXThis appendix presents the complete C++ source code <strong>for</strong> the 4D array example in Section 6.1. The purpose of thisappendix is to show the source code be<strong>for</strong>e <strong>and</strong> after trans<strong>for</strong>ming it with Glift.The C++ source <strong>for</strong> the non-Glift example is:✞// ... Initialize OpenGL rendering context ...vec4i virtArraySize(10, 10, 10, 10); // Compute sizes☎int numElts = 0;<strong>for</strong> (int i = 0; i < virtArraySize.size(); ++i) {numElts += virtArraySize[i];}vec2i physArraySize = int( ceilf( sqrtf( numElts ) ) );vec4f sizeConst(1, 1, 1, 1);sizeConst[1] = virtArraySize[0];sizeConst[2] = virtArraySize[0] * virtArraySize[1];sizeConst[3] = virtArraySize[0] * virtArraySize[1] * virtArraySize[2];// Allocate 2 arrays that hold vec4f valuesGLuint array1_texId;glGenTextures(1, &array1_texId);glBindTexture(GL_TEXTURE_2D, array1_texId);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,physArraySize.x(), physArraySize.y(),GL_RGBA, GL_FLOAT, NULL);GLuint array2_texId; glGenTextures(1, &array2_texId);glBindTexture(GL_TEXTURE_2D, array1_texId);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB,physArraySize.x(), physArraySize.y(),GL_RGBA, GL_FLOAT, NULL);// Create Cg shaderCGprogram prog = cgCreateProgramFromFile( cgCreateContext(), CG_SOURCE, "laplacian.cg",CG_PROFILE_FP40, "main", NULL );// Bind shader <strong>and</strong> enable programmable fragment pipelinecgEnableProfile(CG_PROFILE_FP40);cgGLBindProgram(prog);// Bind parameters to shaderCGparameter array1Param = cgGetNamedParameter(prog, "array1");cgGLSetTextureParameter(array1Param, array1_texId);cgGLEnableTextureParameter(array1Param);ACM Transactions on Graphics, Vol. 25, No. 1, January 2006.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!