void runCuda(){ // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer dptr=NULL; vbo = mesh->getVBO(); vbosize = mesh->getVBOsize(); float newcbo[] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; cbo = newcbo; cbosize = 9; ibo = mesh->getIBO(); ibosize = mesh->getIBOsize(); nbo = mesh->getNBO(); nbosize = mesh->getNBOsize(); cudaGLMapBufferObject((void**)&dptr, pbo); // Invert camera to convert to view matrix cudaRasterizeCore(glm::inverse(cam), projection, light, draw_mode, dptr, glm::vec2(width, height), frame, vbo, vbosize, nbo, nbosize, cbo, cbosize, ibo, ibosize); cudaGLUnmapBufferObject(pbo); vbo = NULL; cbo = NULL; ibo = NULL; frame++; fpstracker++; }
void runCuda(){ // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer dptr=NULL; vbo = mesh->getVBO(); vbosize = mesh->getVBOsize(); float newcbo[] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; cbo = newcbo; cbosize = 9; ibo = mesh->getIBO(); ibosize = mesh->getIBOsize(); cudaGLMapBufferObject((void**)&dptr, pbo); cudaRasterizeCore(dptr, glm::vec2(width, height), frame, vbo, vbosize, cbo, cbosize, ibo, ibosize); cudaGLUnmapBufferObject(pbo); vbo = NULL; cbo = NULL; ibo = NULL; frame++; fpstracker++; }
void runCuda() { ////////////////////// // Timing cuda call // ////////////////////// float time; cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0); // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer dptr=NULL; vbo = mesh->getVBO(); vbosize = mesh->getVBOsize(); nbo = mesh->getNBO(); nbosize = mesh->getNBOsize(); #if RGBONLY == 1 float newcbo[] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; cbo = newcbo; cbosize = 9; #elif RGBONLY == 0 vec3 defaultColor(0.5f, 0.5f, 0.5f); mesh->changeColor(defaultColor); cbo = mesh->getCBO(); cbosize = mesh->getCBOsize(); #endif ibo = mesh->getIBO(); ibosize = mesh->getIBOsize(); cudaGLMapBufferObject((void**)&dptr, pbo); updateCamera(); cudaRasterizeCore(cam, dptr, glm::vec2(width, height), frame, vbo, vbosize, cbo, cbosize, ibo, ibosize, nbo, nbosize, lights, lightsize, alpha, beta, displayMode); cudaGLUnmapBufferObject(pbo); vbo = NULL; cbo = NULL; ibo = NULL; frame++; fpstracker++; ////////////////////// // Timing cuda call // ////////////////////// cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&time, start, stop); printf("runCuda runtime: %3.1f ms \n", time); }
void runCuda(){ // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer dptr=NULL; vbo = mesh->getVBO(); vbosize = mesh->getVBOsize(); float newcbo[] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; cbo = newcbo; cbosize = 9; ibo = mesh->getIBO(); ibosize = mesh->getIBOsize(); nbo = mesh->getNBO(); nbosize = mesh->getNBOsize(); // Update view and model to projection transform matrices in each step when interacting with keyboard or mouse *view = glm::lookAt(cam.position, glm::vec3(0.0f), cam.up); *transformModel2Projection = utilityCore::glmMat4ToCudaMat4(*projection * *view * *model); viewPort = glm::normalize(utilityCore::multiplyMat(utilityCore::glmMat4ToCudaMat4(*projection * *view), glm::vec4(cam.view, 1.0f))); // Transformation Feedback std::cout << "\n The model-view-projection transformation is:" << std::endl; utilityCore::printMat4(*projection * *view * *model); std::cout << "\n The view port in the clip space is:" << std::endl; utilityCore::printVec3(viewPort); cudaGLMapBufferObject((void**)&dptr, pbo); cudaRasterizeCore(dptr, glm::vec2(width, height), frame, vbo, vbosize, cbo, cbosize, ibo, ibosize, nbo, nbosize, transformModel2Projection, viewPort, antialiasing, depthFlag, flatcolorFlag, color, multicolorFlag); cudaGLUnmapBufferObject(pbo); vbo = NULL; cbo = NULL; ibo = NULL; nbo = NULL; frame++; fpstracker++; }
void runCuda(){ // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer vbo = mesh->getVBO(); vbosize = mesh->getVBOsize(); nbo = mesh->getNBO(); nbosize = mesh->getNBOsize(); float newcbo[] = {0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; cbo = newcbo; cbosize = 9; ibo = mesh->getIBO(); ibosize = mesh->getIBOsize(); calcuatetransformationMatrix( eye,glm::vec2(width, height), front, back); dptr=NULL; cudaGLMapBufferObject((void**)&dptr, pbo); if(ReadBlendType() == ADD) { drawTexture(dptr,width, height,texture); } //clearPBOpos(dptr,width,height); cudaRasterizeCore(dptr, glm::vec2(width, height), frame, vbo, vbosize, nbo, nbosize, cbo, cbosize, ibo, ibosize); cudaGLUnmapBufferObject(pbo); vbo = NULL; cbo = NULL; ibo = NULL; frame++; fpstracker++; }
void runCuda(){ // Map OpenGL buffer object for writing from CUDA on a single GPU // No data is moved (Win & Linux). When mapped to CUDA, OpenGL should not use this buffer //Time cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord( start, 0); rRotx += (1.f/180.f) * PI; rRoty = (50.f/180.f) * PI; cameraPosition.x = lookat.x + eyeDis * glm::cos(rRoty) * glm::cos(rRotx); cameraPosition.y = lookat.y + eyeDis * glm::sin(rRoty); cameraPosition.z = lookat.z + eyeDis * glm::cos(rRoty) * glm::sin(rRotx); modelView = glm::lookAt(cameraPosition, lookat, up); float newcbo[] = {1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, }; cbo = newcbo; cbosize = 24; resetStencil(); initalKernel(glm::vec2(width, height), stencilBuffer); for(int i = 0; i < meshVector.size(); i++) { dptr=NULL; vbo = meshVector[i]->getVBO(); vbosize = meshVector[i]->getVBOsize(); nbo = meshVector[i]->getNBO(); nbosize = meshVector[i]->getNBOsize(); ibo = meshVector[i]->getIBO(); ibosize = meshVector[i]->getIBOsize(); cudaRasterizeCore(glm::vec2(width, height), frame, vbo, vbosize, cbo, cbosize, ibo, ibosize, nbo, nbosize, projection*modelView, viewPort, lightPos, cameraPosition, lookat, isStencil, i+1, secondObj, keyValue, stencilBuffer); vbo = NULL; ibo = NULL; nbo = NULL; } cudaGLMapBufferObject((void**)&dptr, pbo); renderKernel(dptr, glm::vec2(width, height)); cudaGLUnmapBufferObject(pbo); cbo = NULL; cudaEventRecord( stop, 0); cudaEventSynchronize( stop ); float seconds = 0.0f; cudaEventElapsedTime( &seconds, start, stop); printf("time %f \n", seconds); frame++; fpstracker++; }