render image using CUDA
| 159 | |
| 160 | // render image using CUDA |
| 161 | void render() |
| 162 | { |
| 163 | copyInvViewMatrix(invViewMatrix, sizeof(float4) * 3); |
| 164 | |
| 165 | // map PBO to get CUDA device pointer |
| 166 | uint *d_output; |
| 167 | // map PBO to get CUDA device pointer |
| 168 | checkCudaErrors(cudaGraphicsMapResources(1, &cuda_pbo_resource, 0)); |
| 169 | size_t num_bytes; |
| 170 | checkCudaErrors(cudaGraphicsResourceGetMappedPointer((void **)&d_output, &num_bytes, cuda_pbo_resource)); |
| 171 | // printf("CUDA mapped PBO: May access %ld bytes\n", num_bytes); |
| 172 | |
| 173 | // clear image |
| 174 | checkCudaErrors(cudaMemset(d_output, 0, width * height * 4)); |
| 175 | |
| 176 | // call CUDA kernel, writing results to PBO |
| 177 | render_kernel(gridSize, blockSize, d_output, width, height, density, brightness, transferOffset, transferScale); |
| 178 | |
| 179 | getLastCudaError("kernel failed"); |
| 180 | |
| 181 | checkCudaErrors(cudaGraphicsUnmapResources(1, &cuda_pbo_resource, 0)); |
| 182 | } |
| 183 | |
| 184 | // display results using OpenGL (called by GLUT) |
| 185 | void display() |
no outgoing calls
no test coverage detected