void RTSpheres::pickingRender(magnet::GL::FBO& fbo, const magnet::GL::Camera& cam, uint32_t& offset) { //Run color kernels cl_uint renderedSpheres = 0; cl_uint renderedVertexData = 0; cl::Buffer clcolbuf = _colBuff.acquireCLObject(); cl_uint cl_offset = offset; for (std::vector<SphereDetails>::iterator iPtr = _renderDetailLevels.begin(); iPtr != _renderDetailLevels.end(); ++iPtr) { cl_int vertexOffset = renderedVertexData - renderedSpheres * iPtr->_type.getVertexCount(); _pickingKernelFunc(clcolbuf, iPtr->_type.getVertexCount(), renderedSpheres, renderedSpheres + iPtr->_nSpheres, vertexOffset, _sortData, cl_offset, _N); renderedSpheres += iPtr->_nSpheres; renderedVertexData += iPtr->_nSpheres * iPtr->_type.getVertexCount(); } //Release resources _colBuff.releaseCLObject(); _colBuff.getContext().getCLCommandQueue().finish(); offset += _N; glRender(fbo, cam, PICKING_PASS); }
void MonteCarloRayTracer::render(float *pixels, Octree *tree, Camera *cam) { const int NUM_THREADS = std::thread::hardware_concurrency(); _rgen = Rng(); std::cout << "Starting carlo tracer with " << NUM_THREADS << " threads.\n"; std::vector<std::thread> threads; // Start threads Timer::getInstance()->start("Carlo"); for (int row = 0; row < _H; ++row) { for (int i = 0; i < NUM_THREADS; ++i) { threads.push_back(std::thread(&MonteCarloRayTracer::threadRender, this, i, pixels, *tree, *cam, row, NUM_THREADS)); threadDone.push_back(false); } for (auto &thread : threads) { thread.join(); } threads.clear(); threadDone.clear(); glRender(pixels); } // Join threads std::cout << std::endl; Timer::getInstance()->stop("Carlo"); Timer::getInstance()->printRealTime("Carlo"); std::cout << "Mean depth: " << float(_meanRayDepth) / float(_W * _H * _raysPerPixel) << std::endl; }
virtual void glRender(magnet::GL::FBO& fbo) { glRender(); }