HIP: Heterogenous-computing Interface for Portability: /long_pathname_so_that_rpms_can_package_the_debug_info/src/external/hip-on-vdi/include/hip/texture_types.h Source File

HIP: Heterogenous-computing Interface for Portability

texture_types.h
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
68 enum hipTextureAddressMode {
69 hipAddressModeWrap = 0,
70 hipAddressModeClamp = 1,
71 hipAddressModeMirror = 2,
72 hipAddressModeBorder = 3
73 };
74
78 enum hipTextureFilterMode { hipFilterModePoint = 0, hipFilterModeLinear = 1 };
79
83 enum hipTextureReadMode { hipReadModeElementType = 0, hipReadModeNormalizedFloat = 1 };
84
88 typedef struct textureReference {
89 int normalized;
90 enum hipTextureReadMode readMode;// used only for driver API's
91 enum hipTextureFilterMode filterMode;
92 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
93 struct hipChannelFormatDesc channelDesc;
94 int sRGB; // Perform sRGB->linear conversion during texture read
95 unsigned int maxAnisotropy; // Limit to the anisotropy ratio
96 enum hipTextureFilterMode mipmapFilterMode;
97 float mipmapLevelBias;
98 float minMipmapLevelClamp;
99 float maxMipmapLevelClamp;
100
101 hipTextureObject_t textureObject;
102 int numChannels;
103 enum hipArray_Format format;
104 }textureReference;
105
109 typedef struct hipTextureDesc {
110 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
111 enum hipTextureFilterMode filterMode;
112 enum hipTextureReadMode readMode;
113 int sRGB; // Perform sRGB->linear conversion during texture read
114 float borderColor[4];
115 int normalizedCoords;
116 unsigned int maxAnisotropy;
117 enum hipTextureFilterMode mipmapFilterMode;
118 float mipmapLevelBias;
119 float minMipmapLevelClamp;
120 float maxMipmapLevelClamp;
121 }hipTextureDesc;
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,
139 enum hipTextureReadMode mode = hipReadModeElementType>
140 struct __HIP_TEXTURE_ATTRIB texture : public textureReference {
141 texture(int norm = 0, enum hipTextureFilterMode fMode = hipFilterModePoint,
142 enum hipTextureAddressMode aMode = hipAddressModeClamp) {
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
textureReference
Definition: texture_types.h:88
hipTextureDesc
Definition: texture_types.h:109
hipChannelFormatDesc
Definition: driver_types.h:47