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/imaging/hgi/api.h"
29 #include <stdlib.h>
30 
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
42 enum HgiFormat
43 {
44  HgiFormatInvalid = -1,
45 
46  // UNorm8 - a 1-byte value representing a float between 0 and 1.
47  // float value = (unorm / 255.0f);
48  HgiFormatUNorm8 = 0,
49  HgiFormatUNorm8Vec2,
50  /* HgiFormatUNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
51  HgiFormatUNorm8Vec4,
52 
53  // SNorm8 - a 1-byte value representing a float between -1 and 1.
54  // float value = max(snorm / 127.0f, -1.0f);
55  HgiFormatSNorm8,
56  HgiFormatSNorm8Vec2,
57  /* HgiFormatSNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
58  HgiFormatSNorm8Vec4,
59 
60  // Float16 - a 2-byte IEEE half-precision float.
61  HgiFormatFloat16,
62  HgiFormatFloat16Vec2,
63  HgiFormatFloat16Vec3,
64  HgiFormatFloat16Vec4,
65 
66  // Float32 - a 4-byte IEEE float.
67  HgiFormatFloat32,
68  HgiFormatFloat32Vec2,
69  HgiFormatFloat32Vec3,
70  HgiFormatFloat32Vec4,
71 
72  // Int32 - a 4-byte signed integer
73  HgiFormatInt32,
74  HgiFormatInt32Vec2,
75  HgiFormatInt32Vec3,
76  HgiFormatInt32Vec4,
77 
78  // UNorm8 SRGB - a 1-byte value representing a float between 0 and 1.
79  // Gamma compression/decompression happens during read/write.
80  // Alpha component is linear.
81  /* HgiFormatUNorm8srgb */ // Unsupported by OpenGL
82  /* HgiFormatUNorm8Vec2srgb */ // Unsupported by OpenGL
83  /* HgiFormatUNorm8Vec3srgb */ // Unsupported Metal (MTLPixelFormat)
84  HgiFormatUNorm8Vec4srgb,
85 
86  // BPTC compressed. 3-component, 4x4 blocks, signed floating-point
87  HgiFormatBC6FloatVec3,
88 
89  // BPTC compressed. 3-component, 4x4 blocks, unsigned floating-point
90  HgiFormatBC6UFloatVec3,
91 
92  // Depth stencil format (Float32 can be used for just depth)
93  HgiFormatFloat32UInt8,
94 
95  HgiFormatCount
96 };
97 
99 HGI_API
100 size_t HgiGetComponentCount(HgiFormat f);
101 
107 HGI_API
108 size_t HgiDataSizeOfFormat(HgiFormat f);
109 
111 HGI_API
112 bool HgiIsCompressed(HgiFormat f);
113 
114 PXR_NAMESPACE_CLOSE_SCOPE
115 
116 #endif