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

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

HIP Runtime API Reference: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hip/checkouts/docs-6.2.1/include/hip/texture_types.h Source File
texture_types.h
Go to the documentation of this file.
1/*
2Copyright (c) 2015 - 2023 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#if defined(__clang__)
27#pragma clang diagnostic push
28#pragma clang diagnostic ignored "-Wreserved-identifier"
29#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
30#pragma clang diagnostic ignored "-Wc++98-compat"
31#endif
32
33#if !defined(__HIPCC_RTC__)
34#include <hip/hip_common.h>
35#endif
36
37#if !defined(__HIP_PLATFORM_AMD__) && defined(__HIP_PLATFORM_NVIDIA__)
38#include "texture_types.h"
39#elif defined(__HIP_PLATFORM_AMD__) && !defined(__HIP_PLATFORM_NVIDIA__)
40/*******************************************************************************
41 * *
42 * *
43 * *
44 *******************************************************************************/
45#if !defined(__HIPCC_RTC__)
46#include <limits.h>
48#include <hip/driver_types.h>
49#endif // !defined(__HIPCC_RTC__)
50
51#define hipTextureType1D 0x01
52#define hipTextureType2D 0x02
53#define hipTextureType3D 0x03
54#define hipTextureTypeCubemap 0x0C
55#define hipTextureType1DLayered 0xF1
56#define hipTextureType2DLayered 0xF2
57#define hipTextureTypeCubemapLayered 0xFC
58
62#define HIP_IMAGE_OBJECT_SIZE_DWORD 12
63#define HIP_SAMPLER_OBJECT_SIZE_DWORD 8
64#define HIP_SAMPLER_OBJECT_OFFSET_DWORD HIP_IMAGE_OBJECT_SIZE_DWORD
65#define HIP_TEXTURE_OBJECT_SIZE_DWORD (HIP_IMAGE_OBJECT_SIZE_DWORD + HIP_SAMPLER_OBJECT_SIZE_DWORD)
66
70struct __hip_texture;
71typedef struct __hip_texture* hipTextureObject_t;
72
82
87
92
96typedef struct textureReference {
98 enum hipTextureReadMode readMode;// used only for driver API's
100 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
102 int sRGB; // Perform sRGB->linear conversion during texture read
103 unsigned int maxAnisotropy; // Limit to the anisotropy ratio
108
113
117typedef struct hipTextureDesc {
118 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
121 int sRGB; // Perform sRGB->linear conversion during texture read
122 float borderColor[4];
124 unsigned int maxAnisotropy;
130
131#if __cplusplus
132
133/*******************************************************************************
134 * *
135 * *
136 * *
137 *******************************************************************************/
138#if __HIP__
139#define __HIP_TEXTURE_ATTRIB __attribute__((device_builtin_texture_type))
140#else
141#define __HIP_TEXTURE_ATTRIB
142#endif
143
145
146template <class T, int texType = hipTextureType1D,
151 normalized = norm;
152 readMode = mode;
153 filterMode = fMode;
154 addressMode[0] = aMode;
155 addressMode[1] = aMode;
156 addressMode[2] = aMode;
157 channelDesc = hipCreateChannelDesc<T>();
158 sRGB = 0;
159 textureObject = nullptr;
160 maxAnisotropy = 0;
161 mipmapLevelBias = 0;
162 minMipmapLevelClamp = 0;
163 maxMipmapLevelClamp = 0;
164 }
165
166 texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode,
167 struct hipChannelFormatDesc desc) {
168 normalized = norm;
169 readMode = mode;
170 filterMode = fMode;
171 addressMode[0] = aMode;
172 addressMode[1] = aMode;
173 addressMode[2] = aMode;
174 channelDesc = desc;
175 sRGB = 0;
176 textureObject = nullptr;
177 maxAnisotropy = 0;
178 mipmapLevelBias = 0;
179 minMipmapLevelClamp = 0;
180 maxMipmapLevelClamp = 0;
181 }
182};
183
184#endif /* __cplusplus */
185
186#else
187#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
188#endif
189
190#if defined(__clang__)
191#pragma clang diagnostic pop
192#endif
193
194#endif
hipArray_Format
Definition driver_types.h:81
Definition driver_types.h:60
Definition texture_types.h:117
float minMipmapLevelClamp
Definition texture_types.h:127
float mipmapLevelBias
Definition texture_types.h:126
float maxMipmapLevelClamp
Definition texture_types.h:128
enum hipTextureFilterMode filterMode
Definition texture_types.h:119
enum hipTextureReadMode readMode
Definition texture_types.h:120
float borderColor[4]
Definition texture_types.h:122
enum hipTextureFilterMode mipmapFilterMode
Definition texture_types.h:125
int sRGB
Definition texture_types.h:121
int normalizedCoords
Definition texture_types.h:123
unsigned int maxAnisotropy
Definition texture_types.h:124
enum hipTextureAddressMode addressMode[3]
Definition texture_types.h:118
Definition texture_types.h:148
texture(int norm=0, enum hipTextureFilterMode fMode=hipFilterModePoint, enum hipTextureAddressMode aMode=hipAddressModeClamp)
Definition texture_types.h:149
texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode, struct hipChannelFormatDesc desc)
Definition texture_types.h:166
Definition texture_types.h:96
int sRGB
Definition texture_types.h:102
hipTextureObject_t textureObject
Definition texture_types.h:109
float minMipmapLevelClamp
Definition texture_types.h:106
enum hipTextureFilterMode mipmapFilterMode
Definition texture_types.h:104
enum hipTextureReadMode readMode
Definition texture_types.h:98
enum hipTextureAddressMode addressMode[3]
Definition texture_types.h:100
enum hipTextureFilterMode filterMode
Definition texture_types.h:99
int normalized
Definition texture_types.h:97
unsigned int maxAnisotropy
Definition texture_types.h:103
int numChannels
Definition texture_types.h:110
float maxMipmapLevelClamp
Definition texture_types.h:107
enum hipArray_Format format
Definition texture_types.h:111
float mipmapLevelBias
Definition texture_types.h:105
struct hipChannelFormatDesc channelDesc
Definition texture_types.h:101
struct __hip_texture * hipTextureObject_t
Definition texture_types.h:71
hipTextureReadMode
Definition texture_types.h:91
@ hipReadModeElementType
Definition texture_types.h:91
@ hipReadModeNormalizedFloat
Definition texture_types.h:91
#define hipTextureType1D
Definition texture_types.h:51
textureReference * hipTexRef
Definition texture_types.h:144
#define __HIP_TEXTURE_ATTRIB
Definition texture_types.h:141
hipTextureAddressMode
Definition texture_types.h:76
@ hipAddressModeMirror
Definition texture_types.h:79
@ hipAddressModeBorder
Definition texture_types.h:80
@ hipAddressModeWrap
Definition texture_types.h:77
@ hipAddressModeClamp
Definition texture_types.h:78
hipTextureFilterMode
Definition texture_types.h:86
@ hipFilterModePoint
Definition texture_types.h:86
@ hipFilterModeLinear
Definition texture_types.h:86