All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
types.h
1 //
2 // Copyright 2020 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HGI_TYPES_H
25 #define PXR_IMAGING_HGI_TYPES_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/gf/vec3i.h"
29 #include "pxr/imaging/hgi/api.h"
30 #include <vector>
31 #include <limits>
32 #include <stdlib.h>
33 
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
45 enum HgiFormat : int
46 {
47  HgiFormatInvalid = -1,
48 
49  // UNorm8 - a 1-byte value representing a float between 0 and 1.
50  // float value = (unorm / 255.0f);
51  HgiFormatUNorm8 = 0,
52  HgiFormatUNorm8Vec2,
53  /* HgiFormatUNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
54  HgiFormatUNorm8Vec4,
55 
56  // SNorm8 - a 1-byte value representing a float between -1 and 1.
57  // float value = max(snorm / 127.0f, -1.0f);
58  HgiFormatSNorm8,
59  HgiFormatSNorm8Vec2,
60  /* HgiFormatSNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
61  HgiFormatSNorm8Vec4,
62 
63  // Float16 - a 2-byte IEEE half-precision float.
64  HgiFormatFloat16,
65  HgiFormatFloat16Vec2,
66  HgiFormatFloat16Vec3,
67  HgiFormatFloat16Vec4,
68 
69  // Float32 - a 4-byte IEEE float.
70  HgiFormatFloat32,
71  HgiFormatFloat32Vec2,
72  HgiFormatFloat32Vec3,
73  HgiFormatFloat32Vec4,
74 
75  // Int16 - a 2-byte signed integer
76  HgiFormatInt16,
77  HgiFormatInt16Vec2,
78  HgiFormatInt16Vec3,
79  HgiFormatInt16Vec4,
80 
81  // UInt16 - a 2-byte unsigned integer
82  HgiFormatUInt16,
83  HgiFormatUInt16Vec2,
84  HgiFormatUInt16Vec3,
85  HgiFormatUInt16Vec4,
86 
87  // Int32 - a 4-byte signed integer
88  HgiFormatInt32,
89  HgiFormatInt32Vec2,
90  HgiFormatInt32Vec3,
91  HgiFormatInt32Vec4,
92 
93  // UNorm8 SRGB - a 1-byte value representing a float between 0 and 1.
94  // Gamma compression/decompression happens during read/write.
95  // Alpha component is linear.
96  /* HgiFormatUNorm8srgb */ // Unsupported by OpenGL
97  /* HgiFormatUNorm8Vec2srgb */ // Unsupported by OpenGL
98  /* HgiFormatUNorm8Vec3srgb */ // Unsupported Metal (MTLPixelFormat)
99  HgiFormatUNorm8Vec4srgb,
100 
101  // BPTC compressed. 3-component, 4x4 blocks, signed floating-point
102  HgiFormatBC6FloatVec3,
103 
104  // BPTC compressed. 3-component, 4x4 blocks, unsigned floating-point
105  HgiFormatBC6UFloatVec3,
106 
107  // BPTC compressed. 4-component, 4x4 blocks, unsigned byte.
108  // Representing a float between 0 and 1.
109  HgiFormatBC7UNorm8Vec4,
110 
111  // BPTC compressed. 4-component, 4x4 blocks, unsigned byte, sRGB.
112  // Representing a float between 0 and 1.
113  HgiFormatBC7UNorm8Vec4srgb,
114 
115  // S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
116  // Representing a float between 0 and 1.
117  HgiFormatBC1UNorm8Vec4,
118 
119  // S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
120  // Representing a float between 0 and 1.
121  HgiFormatBC3UNorm8Vec4,
122 
123  // Depth stencil format (Float32 can be used for just depth)
124  HgiFormatFloat32UInt8,
125 
126  HgiFormatCount
127 };
128 
133 {
135  size_t byteOffset;
140 };
141 
143 HGI_API
144 size_t HgiGetComponentCount(HgiFormat f);
145 
154 HGI_API
155 size_t HgiGetDataSizeOfFormat(
156  HgiFormat f,
157  size_t *blockWidth = nullptr,
158  size_t *blockHeight = nullptr);
159 
161 HGI_API
162 bool HgiIsCompressed(HgiFormat f);
163 
167 HGI_API
168 size_t HgiGetDataSize(
169  HgiFormat f,
170  const GfVec3i &dimensions);
171 
185 HGI_API
186 std::vector<HgiMipInfo>
187 HgiGetMipInfos(
188  HgiFormat format,
189  const GfVec3i& dimensions,
190  size_t layerCount,
191  size_t dataByteSize = std::numeric_limits<size_t>::max());
192 
193 PXR_NAMESPACE_CLOSE_SCOPE
194 
195 #endif
size_t byteOffset
Offset in bytes from start of texture data to start of mip map.
Definition: types.h:135
HgiMipInfo describes size and other info for a mip level.
Definition: types.h:132
Basic type for a vector of 3 int components.
Definition: vec3i.h:61
GfVec3i dimensions
Dimension of mip GfVec3i.
Definition: types.h:137
size_t byteSizePerLayer
size of (one layer if array of) mip map in bytes.
Definition: types.h:139