HIP: Heterogenous-computing Interface for Portability
Loading...
Searching...
No Matches
texture_types.h
1/*
2Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE 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
62struct __hip_texture;
63typedef struct __hip_texture* hipTextureObject_t;
64
68enum hipTextureAddressMode {
69 hipAddressModeWrap = 0,
70 hipAddressModeClamp = 1,
71 hipAddressModeMirror = 2,
72 hipAddressModeBorder = 3
73};
74
78enum hipTextureFilterMode { hipFilterModePoint = 0, hipFilterModeLinear = 1 };
79
83enum hipTextureReadMode { hipReadModeElementType = 0, hipReadModeNormalizedFloat = 1 };
84
88typedef 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;
105
109typedef 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;
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
136typedef textureReference* hipTexRef;
137
138template <class T, int texType = hipTextureType1D,
139 enum hipTextureReadMode mode = hipReadModeElementType>
140struct __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
Definition driver_types.h:47
Definition texture_types.h:109
Definition texture_types.h:88