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

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hip/checkouts/docs-5.1.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.1.3/include/hip/texture_types.h Source File
texture_types.h
Go to the documentation of this file.
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>
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
74
79
84
88typedef 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
105
109typedef 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
136typedef textureReference* hipTexRef;
137
138template <class T, int texType = hipTextureType1D,
140struct __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