/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hip/checkouts/docs-5.4.3/include/hip/texture_types.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hip/checkouts/docs-5.4.3/include/hip/texture_types.h Source File#

HIP Runtime API Reference: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hip/checkouts/docs-5.4.3/include/hip/texture_types.h Source File
texture_types.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2015 - 2021 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 
23 #ifndef HIP_INCLUDE_HIP_TEXTURE_TYPES_H
24 #define HIP_INCLUDE_HIP_TEXTURE_TYPES_H
25 
26 #include <hip/hip_common.h>
27 
28 #if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
29 #include "texture_types.h"
30 #elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
31 /*******************************************************************************
32  * *
33  * *
34  * *
35  *******************************************************************************/
36 #if !defined(__HIPCC_RTC__)
37 #include <limits.h>
38 #include <hip/channel_descriptor.h>
39 #endif // !defined(__HIPCC_RTC__)
40 
41 #include <hip/driver_types.h>
42 
43 #define hipTextureType1D 0x01
44 #define hipTextureType2D 0x02
45 #define hipTextureType3D 0x03
46 #define hipTextureTypeCubemap 0x0C
47 #define hipTextureType1DLayered 0xF1
48 #define hipTextureType2DLayered 0xF2
49 #define hipTextureTypeCubemapLayered 0xFC
50 
54 #define HIP_IMAGE_OBJECT_SIZE_DWORD 12
55 #define HIP_SAMPLER_OBJECT_SIZE_DWORD 8
56 #define HIP_SAMPLER_OBJECT_OFFSET_DWORD HIP_IMAGE_OBJECT_SIZE_DWORD
57 #define HIP_TEXTURE_OBJECT_SIZE_DWORD (HIP_IMAGE_OBJECT_SIZE_DWORD + HIP_SAMPLER_OBJECT_SIZE_DWORD)
58 
62 struct __hip_texture;
63 typedef struct __hip_texture* hipTextureObject_t;
64 
73 };
74 
79 
84 
88 typedef struct textureReference {
90  enum hipTextureReadMode readMode;// used only for driver API's
92  enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
94  int sRGB; // Perform sRGB->linear conversion during texture read
95  unsigned int maxAnisotropy; // Limit to the anisotropy ratio
100 
103  enum hipArray_Format format;
105 
109 typedef struct hipTextureDesc {
110  enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
113  int sRGB; // Perform sRGB->linear conversion during texture read
114  float borderColor[4];
116  unsigned int maxAnisotropy;
122 
123 #if __cplusplus
124 
125 /*******************************************************************************
126  * *
127  * *
128  * *
129  *******************************************************************************/
130 #if __HIP__
131 #define __HIP_TEXTURE_ATTRIB __attribute__((device_builtin_texture_type))
132 #else
133 #define __HIP_TEXTURE_ATTRIB
134 #endif
135 
136 typedef textureReference* hipTexRef;
137 
138 template <class T, int texType = hipTextureType1D,
140 struct __HIP_TEXTURE_ATTRIB texture : public textureReference {
141  texture(int norm = 0, enum hipTextureFilterMode fMode = hipFilterModePoint,
143  normalized = norm;
144  readMode = mode;
145  filterMode = fMode;
146  addressMode[0] = aMode;
147  addressMode[1] = aMode;
148  addressMode[2] = aMode;
149  channelDesc = hipCreateChannelDesc<T>();
150  sRGB = 0;
151  textureObject = nullptr;
152  maxAnisotropy = 0;
153  mipmapLevelBias = 0;
154  minMipmapLevelClamp = 0;
155  maxMipmapLevelClamp = 0;
156  }
157 
158  texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode,
159  struct hipChannelFormatDesc desc) {
160  normalized = norm;
161  readMode = mode;
162  filterMode = fMode;
163  addressMode[0] = aMode;
164  addressMode[1] = aMode;
165  addressMode[2] = aMode;
166  channelDesc = desc;
167  sRGB = 0;
168  textureObject = nullptr;
169  maxAnisotropy = 0;
170  mipmapLevelBias = 0;
171  minMipmapLevelClamp = 0;
172  maxMipmapLevelClamp = 0;
173  }
174 };
175 
176 #endif /* __cplusplus */
177 
178 #else
179 #error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
180 #endif
181 
182 #endif
hipArray_Format
Definition: driver_types.h:58
Definition: driver_types.h:47
Definition: texture_types.h:109
float minMipmapLevelClamp
Definition: texture_types.h:119
float mipmapLevelBias
Definition: texture_types.h:118
float maxMipmapLevelClamp
Definition: texture_types.h:120
enum hipTextureFilterMode filterMode
Definition: texture_types.h:111
enum hipTextureReadMode readMode
Definition: texture_types.h:112
float borderColor[4]
Definition: texture_types.h:114
enum hipTextureFilterMode mipmapFilterMode
Definition: texture_types.h:117
int sRGB
Definition: texture_types.h:113
int normalizedCoords
Definition: texture_types.h:115
unsigned int maxAnisotropy
Definition: texture_types.h:116
enum hipTextureAddressMode addressMode[3]
Definition: texture_types.h:110
Definition: texture_types.h:88
int sRGB
Definition: texture_types.h:94
hipTextureObject_t textureObject
Definition: texture_types.h:101
float minMipmapLevelClamp
Definition: texture_types.h:98
enum hipTextureFilterMode mipmapFilterMode
Definition: texture_types.h:96
enum hipTextureReadMode readMode
Definition: texture_types.h:90
enum hipTextureAddressMode addressMode[3]
Definition: texture_types.h:92
enum hipTextureFilterMode filterMode
Definition: texture_types.h:91
int normalized
Definition: texture_types.h:89
unsigned int maxAnisotropy
Definition: texture_types.h:95
int numChannels
Definition: texture_types.h:102
float maxMipmapLevelClamp
Definition: texture_types.h:99
enum hipArray_Format format
Definition: texture_types.h:103
float mipmapLevelBias
Definition: texture_types.h:97
struct hipChannelFormatDesc channelDesc
Definition: texture_types.h:93
struct __hip_texture * hipTextureObject_t
Definition: texture_types.h:63
hipTextureReadMode
Definition: texture_types.h:83
@ hipReadModeElementType
Definition: texture_types.h:83
@ hipReadModeNormalizedFloat
Definition: texture_types.h:83
#define hipTextureType1D
Definition: texture_types.h:43
hipTextureAddressMode
Definition: texture_types.h:68
@ hipAddressModeMirror
Definition: texture_types.h:71
@ hipAddressModeBorder
Definition: texture_types.h:72
@ hipAddressModeWrap
Definition: texture_types.h:69
@ hipAddressModeClamp
Definition: texture_types.h:70
hipTextureFilterMode
Definition: texture_types.h:78
@ hipFilterModePoint
Definition: texture_types.h:78
@ hipFilterModeLinear
Definition: texture_types.h:78