include/hip/texture_types.h Source File

include/hip/texture_types.h Source File#

HIP Runtime API Reference: 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__)
47#include <hip/driver_types.h>
48#endif // !defined(__HIPCC_RTC__)
49
50#define hipTextureType1D 0x01
51#define hipTextureType2D 0x02
52#define hipTextureType3D 0x03
53#define hipTextureTypeCubemap 0x0C
54#define hipTextureType1DLayered 0xF1
55#define hipTextureType2DLayered 0xF2
56#define hipTextureTypeCubemapLayered 0xFC
57
61#define HIP_IMAGE_OBJECT_SIZE_DWORD 12
62#define HIP_SAMPLER_OBJECT_SIZE_DWORD 8
63#define HIP_SAMPLER_OBJECT_OFFSET_DWORD HIP_IMAGE_OBJECT_SIZE_DWORD
64#define HIP_TEXTURE_OBJECT_SIZE_DWORD (HIP_IMAGE_OBJECT_SIZE_DWORD + HIP_SAMPLER_OBJECT_SIZE_DWORD)
65
69struct __hip_texture;
70typedef struct __hip_texture* hipTextureObject_t;
71
81
86
91
95typedef struct textureReference {
97 enum hipTextureReadMode readMode; // used only for driver API's
99 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
101 int sRGB; // Perform sRGB->linear conversion during texture read
102 unsigned int maxAnisotropy; // Limit to the anisotropy ratio
107
112
116typedef struct hipTextureDesc {
117 enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions
120 int sRGB; // Perform sRGB->linear conversion during texture read
121 float borderColor[4];
123 unsigned int maxAnisotropy;
129
130#if __cplusplus
131
132/*******************************************************************************
133 * *
134 * *
135 * *
136 *******************************************************************************/
137#if __HIP__
138#define __HIP_TEXTURE_ATTRIB __attribute__((device_builtin_texture_type))
139#else
140#define __HIP_TEXTURE_ATTRIB
141#endif
142
144
145template <class T, int texType = hipTextureType1D,
150 normalized = norm;
151 readMode = mode;
152 filterMode = fMode;
153 addressMode[0] = aMode;
154 addressMode[1] = aMode;
155 addressMode[2] = aMode;
156 channelDesc = hipCreateChannelDesc<T>();
157 sRGB = 0;
158 textureObject = nullptr;
159 maxAnisotropy = 0;
160 mipmapLevelBias = 0;
161 minMipmapLevelClamp = 0;
162 maxMipmapLevelClamp = 0;
163 }
164
165 texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode,
166 struct hipChannelFormatDesc desc) {
167 normalized = norm;
168 readMode = mode;
169 filterMode = fMode;
170 addressMode[0] = aMode;
171 addressMode[1] = aMode;
172 addressMode[2] = aMode;
173 channelDesc = desc;
174 sRGB = 0;
175 textureObject = nullptr;
176 maxAnisotropy = 0;
177 mipmapLevelBias = 0;
178 minMipmapLevelClamp = 0;
179 maxMipmapLevelClamp = 0;
180 }
181};
182
183#endif /* __cplusplus */
184
185#else
186#error ("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
187#endif
188
189#if defined(__clang__)
190#pragma clang diagnostic pop
191#endif
192
193#endif
const struct texture< T, dim, readMode > const void size_t int enum hipTextureReadMode readMode const struct texture< T, dim, readMode > const void const struct hipChannelFormatDesc & desc
Definition hip_runtime_api.h:10032
hipArray_Format
Definition driver_types.h:80
Definition driver_types.h:59
Definition texture_types.h:116
float minMipmapLevelClamp
Definition texture_types.h:126
float mipmapLevelBias
Definition texture_types.h:125
float maxMipmapLevelClamp
Definition texture_types.h:127
enum hipTextureFilterMode filterMode
Definition texture_types.h:118
enum hipTextureReadMode readMode
Definition texture_types.h:119
float borderColor[4]
Definition texture_types.h:121
enum hipTextureFilterMode mipmapFilterMode
Definition texture_types.h:124
int sRGB
Definition texture_types.h:120
int normalizedCoords
Definition texture_types.h:122
unsigned int maxAnisotropy
Definition texture_types.h:123
enum hipTextureAddressMode addressMode[3]
Definition texture_types.h:117
Definition texture_types.h:147
texture(int norm=0, enum hipTextureFilterMode fMode=hipFilterModePoint, enum hipTextureAddressMode aMode=hipAddressModeClamp)
Definition texture_types.h:148
texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode, struct hipChannelFormatDesc desc)
Definition texture_types.h:165
Definition texture_types.h:95
int sRGB
Definition texture_types.h:101
hipTextureObject_t textureObject
Definition texture_types.h:108
float minMipmapLevelClamp
Definition texture_types.h:105
enum hipTextureFilterMode mipmapFilterMode
Definition texture_types.h:103
enum hipTextureReadMode readMode
Definition texture_types.h:97
enum hipTextureAddressMode addressMode[3]
Definition texture_types.h:99
enum hipTextureFilterMode filterMode
Definition texture_types.h:98
int normalized
Definition texture_types.h:96
unsigned int maxAnisotropy
Definition texture_types.h:102
int numChannels
Definition texture_types.h:109
float maxMipmapLevelClamp
Definition texture_types.h:106
enum hipArray_Format format
Definition texture_types.h:110
float mipmapLevelBias
Definition texture_types.h:104
struct hipChannelFormatDesc channelDesc
Definition texture_types.h:100
struct __hip_texture * hipTextureObject_t
Definition texture_types.h:70
hipTextureReadMode
Definition texture_types.h:90
@ hipReadModeElementType
Definition texture_types.h:90
@ hipReadModeNormalizedFloat
Definition texture_types.h:90
#define hipTextureType1D
Definition texture_types.h:50
textureReference * hipTexRef
Definition texture_types.h:143
#define __HIP_TEXTURE_ATTRIB
Definition texture_types.h:140
hipTextureAddressMode
Definition texture_types.h:75
@ hipAddressModeMirror
Definition texture_types.h:78
@ hipAddressModeBorder
Definition texture_types.h:79
@ hipAddressModeWrap
Definition texture_types.h:76
@ hipAddressModeClamp
Definition texture_types.h:77
hipTextureFilterMode
Definition texture_types.h:85
@ hipFilterModePoint
Definition texture_types.h:85
@ hipFilterModeLinear
Definition texture_types.h:85