HIP: Heterogenous-computing Interface for Portability
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
hcc_detail
hip_texture.h
1
/*
2
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
21
*/
22
#pragma once
23
28
#include <limits.h>
29
30
#include <
hip_runtime.h
>
31
32
//----
33
//Texture - TODO - likely need to move this to a separate file only included with kernel compilation.
34
#define hipTextureType1D 1
35
36
typedef
struct
hipChannelFormatDesc
{
37
// TODO - this has 4-5 well-defined fields, we could just copy...
38
int
_dummy;
39
}
hipChannelFormatDesc
;
40
41
typedef
enum
hipTextureReadMode
42
{
43
hipReadModeElementType,
44
} hipTextureReadMode;
46
47
typedef
enum
hipTextureFilterMode
48
{
49
hipFilterModePoint,
50
} hipTextureFilterMode;
52
53
struct
textureReference
{
54
hipTextureFilterMode filterMode;
55
bool
normalized;
56
hipChannelFormatDesc
channelDesc;
57
};
58
59
template
<
class
T,
int
texType=hipTextureType1D, enum hipTextureReadMode=hipReadModeElementType>
60
struct
texture
:
public
textureReference
{
61
62
const
T * _dataPtr;
// pointer to underlying data.
63
64
//texture() : filterMode(hipFilterModePoint), normalized(false), _dataPtr(NULL) {};
65
};
66
67
68
69
70
#define tex1Dfetch(_tex, _addr) (_tex._dataPtr[_addr])
71
72
73
74
82
// These are C++ APIs - maybe belong in separate file.
106
// C API:
107
#if 0
108
hipChannelFormatDesc
hipBindTexture(
size_t
*offset,
struct
textureReference
*tex,
const
void
*devPtr,
const
struct
hipChannelFormatDesc
*desc,
size_t
size=UINT_MAX)
109
{
110
tex->_dataPtr = devPtr;
111
}
112
#endif
113
114
/*
115
* @brief hipChannelFormatDesc
116
**/
117
// TODO
118
template
<
class
T>
119
hipChannelFormatDesc
hipCreateChannelDesc()
120
{
121
hipChannelFormatDesc
desc;
122
return
desc;
123
}
124
125
/*
126
* @brief hipBindTexture
127
**/
128
// TODO-doc
129
template
<
class
T,
int
dim, enum hipTextureReadMode readMode>
130
hipError_t
hipBindTexture(
size_t
*offset,
131
struct
texture<T, dim, readMode>
&tex,
132
const
void
*devPtr,
133
const
struct
hipChannelFormatDesc
*desc,
134
size_t
size=UINT_MAX)
135
{
136
tex._dataPtr =
static_cast<
const
T*
>
(devPtr);
137
138
return
hipSuccess
;
139
}
140
141
142
/*
143
* @brief hipBindTexture
144
**/
145
// TODO-doc
146
template
<
class
T,
int
dim, enum hipTextureReadMode readMode>
147
hipError_t
hipBindTexture(
size_t
*offset,
148
struct
texture<T, dim, readMode>
&tex,
149
const
void
*devPtr,
150
size_t
size=UINT_MAX)
151
{
152
return
hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size);
153
}
154
155
156
/*
157
* @brief hipUnbindTexture
158
**/
159
// TODO-doc
160
template
<
class
T,
int
dim, enum hipTextureReadMode readMode>
161
hipError_t
hipUnbindTexture(
struct
texture<T, dim, readMode>
*tex)
162
{
163
tex->_dataPtr = NULL;
164
165
return
hipSuccess
;
166
}
167
168
169
170
// doxygen end Texture
176
// End doxygen API:
hipSuccess
Successful completion.
Definition:
hip_runtime_api.h:113
textureReference
Definition:
hip_texture.h:53
hip_runtime.h
hipError_t
hipError_t
Definition:
hip_runtime_api.h:112
hipChannelFormatDesc
Definition:
hip_texture.h:36
texture
Definition:
hip_texture.h:60
Generated on Mon Jan 25 2016 16:05:53 for HIP: Heterogenous-computing Interface for Portability by
1.8.6