| 19 | namespace arrayfire { |
| 20 | namespace cuda { |
| 21 | GraphicsResourceManager::ShrdResVector |
| 22 | GraphicsResourceManager::registerResources( |
| 23 | const std::vector<uint32_t>& resources) { |
| 24 | ShrdResVector output; |
| 25 | |
| 26 | auto deleter = [](cudaGraphicsResource_t* handle) { |
| 27 | // FIXME Having a CUDA_CHECK around unregister |
| 28 | // call is causing invalid GL context. |
| 29 | // Moving ForgeManager class singleton as data |
| 30 | // member of DeviceManager with proper ordering |
| 31 | // of member destruction doesn't help either. |
| 32 | // Calling makeContextCurrent also doesn't help. |
| 33 | cudaGraphicsUnregisterResource(*handle); |
| 34 | delete handle; |
| 35 | }; |
| 36 | |
| 37 | for (auto id : resources) { |
| 38 | cudaGraphicsResource_t r; |
| 39 | CUDA_CHECK(cudaGraphicsGLRegisterBuffer( |
| 40 | &r, id, cudaGraphicsMapFlagsWriteDiscard)); |
| 41 | output.emplace_back(new cudaGraphicsResource_t(r), deleter); |
| 42 | } |
| 43 | |
| 44 | return output; |
| 45 | } |
| 46 | } // namespace cuda |
| 47 | } // namespace arrayfire |
no outgoing calls
no test coverage detected