static void invert(MATRIX a) { MATRIX b; VECTOR col; int indx[N_DIM],i,j; ludcmp(a,indx); for (j=0;j<N_DIM;j++) { for (i=0;i<N_DIM;i++) col[i] = 0; col[j] = 1; lubksb(a,indx,col); for (i=0;i<N_DIM;i++) b[i][j] = col[i]; } COPY_MAT(b,a); }
void Context::runVertexShader( ocull::Mesh *pMesh, const ocull::Matrix4x4 &modelMatrix) { /// Map constants parameters (like GLSL's uniforms) FW::Constants& c = *(FW::Constants*) m_cudaModule->getGlobal("c_constants").getMutablePtrDiscard(); // Compute the ModelViewProjection matrix const Matrix4x4 &viewProj = m_pQuery->m_camera.getViewProjMatrix(); Matrix4x4 mvp = viewProj * modelMatrix; // Translate custom matrix as CudaRaster Framework matrix (yeah.. what ?) # define COPY_MAT(i,j) c.posToClip.m##i##j = mvp[j][i] COPY_MAT(0, 0); COPY_MAT(0, 1); COPY_MAT(0, 2); COPY_MAT(0, 3); COPY_MAT(1, 0); COPY_MAT(1, 1); COPY_MAT(1, 2); COPY_MAT(1, 3); COPY_MAT(2, 0); COPY_MAT(2, 1); COPY_MAT(2, 2); COPY_MAT(2, 3); COPY_MAT(3, 0); COPY_MAT(3, 1); COPY_MAT(3, 2); COPY_MAT(3, 3); # undef COPY_MAT //------- /// Set input parameters int ofs = 0; ofs += m_cudaModule->setParamPtr( m_vsKernel, ofs, pMesh->vertex.buffer.getCudaPtr()); ofs += m_cudaModule->setParamPtr( m_vsKernel, ofs, m_outVertices.getMutableCudaPtrDiscard()); ofs += m_cudaModule->setParami ( m_vsKernel, ofs, pMesh->vertex.count); // XXX TODO set vertex stride & offset XXX //------- /// Run the vertex shader kernel FW::Vec2i blockSize(32, 4); int numBlocks = (pMesh->vertex.count - 1u) / (blockSize.x * blockSize.y) + 1; m_cudaModule->launchKernel( m_vsKernel, blockSize, numBlocks); }