-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy pathGraphicsResourceManager.cpp
More file actions
47 lines (41 loc) · 1.53 KB
/
GraphicsResourceManager.cpp
File metadata and controls
47 lines (41 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*******************************************************
* Copyright (c) 2016, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <GraphicsResourceManager.hpp>
#include <common/graphics_common.hpp>
// cuda_gl_interop.h does not include OpenGL headers for ARM
// __gl_h_ should be defined by glad.h inclusion
#include <cuda_gl_interop.h>
#include <err_cuda.hpp>
#include <platform.hpp>
namespace arrayfire {
namespace cuda {
GraphicsResourceManager::ShrdResVector
GraphicsResourceManager::registerResources(
const std::vector<uint32_t>& resources) {
ShrdResVector output;
auto deleter = [](cudaGraphicsResource_t* handle) {
// FIXME Having a CUDA_CHECK around unregister
// call is causing invalid GL context.
// Moving ForgeManager class singleton as data
// member of DeviceManager with proper ordering
// of member destruction doesn't help either.
// Calling makeContextCurrent also doesn't help.
cudaGraphicsUnregisterResource(*handle);
delete handle;
};
for (auto id : resources) {
cudaGraphicsResource_t r;
CUDA_CHECK(cudaGraphicsGLRegisterBuffer(
&r, id, cudaGraphicsMapFlagsWriteDiscard));
output.emplace_back(new cudaGraphicsResource_t(r), deleter);
}
return output;
}
} // namespace cuda
} // namespace arrayfire