-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCCUDAExportableMemory.h
More file actions
65 lines (47 loc) · 1.64 KB
/
CCUDAExportableMemory.h
File metadata and controls
65 lines (47 loc) · 1.64 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_VIDEO_C_CUDA_EXPORTABLE_MEMORY_H_
#define _NBL_VIDEO_C_CUDA_EXPORTABLE_MEMORY_H_
#ifdef _NBL_COMPILE_WITH_CUDA_
#include "cuda.h"
#include "nvrtc.h"
#if CUDA_VERSION < 9000
#error "Need CUDA 9.0 SDK or higher."
#endif
// useful includes in the future
//#include "cudaEGL.h"
//#include "cudaVDPAU.h"
namespace nbl::video
{
class CCUDADevice;
class NBL_API2 CCUDAExportableMemory : public core::IReferenceCounted
{
public:
struct SCreationParams
{
size_t size;
uint32_t alignment;
CUmemLocationType location;
};
struct SCachedCreationParams : SCreationParams
{
size_t granularSize;
CUdeviceptr ptr;
external_handle_t externalHandle;
};
CCUDAExportableMemory(core::smart_refctd_ptr<CCUDADevice> device, SCachedCreationParams&& params)
: m_device(std::move(device))
, m_params(std::move(params))
{}
~CCUDAExportableMemory() override;
CUdeviceptr getDeviceptr() const { return m_params.ptr; }
const SCreationParams& getCreationParams() const { return m_params; }
core::smart_refctd_ptr<IDeviceMemoryAllocation> exportAsMemory(ILogicalDevice* device, IDeviceMemoryBacked* dedication = nullptr) const;
private:
core::smart_refctd_ptr<CCUDADevice> m_device;
SCachedCreationParams m_params;
};
}
#endif // _NBL_COMPILE_WITH_CUDA_
#endif