Voxel
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Typedefs
Enumerations
Enumerator
Macros
Pages
opencl_state.h
Go to the documentation of this file.
1
#pragma once
2
3
#ifndef OPENCL_STATE_H
4
#define OPENCL_STATE_H
5
6
7
/**
8
\file
9
\brief Contains OpenCL::State class.
10
*/
11
12
13
14
15
#include "
settings.h
"
16
17
18
19
20
#if ( SETTING_OPENCL != 0 )
21
22
23
24
25
#include "
opencl_deleter.h
"
26
27
#include <CL/cl.h>
28
29
#include <memory>
30
31
32
33
34
namespace
OpenCL {
35
36
37
38
39
/*==============================================================================
40
State class
41
==============================================================================*/
42
43
44
/**
45
\brief OpenCL state class.
46
47
The constructor attempts to create the following three objects:
48
49
1. An OpenCL device identifier (for the first GPU found in the system).
50
2. An OpenCL context (for this device).
51
3. An OpenCL command queue (also for this device).
52
53
If any of the creation calls fail, than an OpenCL Exception will be thrown.
54
The three contained objects can be accessed via the \c DeviceID, \c Context
55
and \c Queue accessor functions, respectively.
56
57
\todo Check endian-ness.
58
\todo Check supported image formats (in particular, RGBA32 and RGB16, the two supported in color.h).
59
*/
60
struct
State
{
61
62
State
();
63
64
~
State
();
65
66
67
inline
cl_device_id
DeviceID
()
const
;
///< \brief Returns OpenCL device identifier of first GPU in the system.
68
inline
cl_context
Context
()
const
;
///< \brief Returns OpenCL context for the device returned by DeviceID().
69
inline
cl_command_queue
Queue
()
const
;
///< \brief Returns OpenCL command queue for the device returned by DeviceID().
70
71
72
private
:
73
74
cl_device_id m_deviceID;
75
std::unique_ptr< _cl_context, Deleter< _cl_context > > m_context;
76
std::unique_ptr< _cl_command_queue, Deleter< _cl_command_queue > > m_queue;
77
};
78
79
80
81
82
/*==============================================================================
83
State methods
84
==============================================================================*/
85
86
87
cl_device_id
State::DeviceID
()
const
{
88
89
return
m_deviceID;
90
}
91
92
93
cl_context
State::Context
()
const
{
94
95
return
m_context.get();
96
}
97
98
99
cl_command_queue
State::Queue
()
const
{
100
101
return
m_queue.get();
102
}
103
104
105
106
107
}
// namespace OpenCL
108
109
110
111
112
#endif // SETTING_OPENCL
113
114
115
116
117
#endif // OPENCL_STATE_H
Generated on Thu Jun 20 2013 11:05:27 for Voxel by
1.8.1.2