Loading...
Searching...
No Matches
types.h
1//
2// Copyright 2020 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HGI_TYPES_H
8#define PXR_IMAGING_HGI_TYPES_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/gf/vec3i.h"
12#include "pxr/imaging/hgi/api.h"
13#include <vector>
14#include <limits>
15#include <stdlib.h>
16
17
18PXR_NAMESPACE_OPEN_SCOPE
19
28enum HgiFormat : int
29{
30 HgiFormatInvalid = -1,
31
32 // UNorm8 - a 1-byte value representing a float between 0 and 1.
33 // float value = (unorm / 255.0f);
34 HgiFormatUNorm8 = 0,
35 HgiFormatUNorm8Vec2,
36 /* HgiFormatUNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
37 HgiFormatUNorm8Vec4,
38
39 // SNorm8 - a 1-byte value representing a float between -1 and 1.
40 // float value = max(snorm / 127.0f, -1.0f);
41 HgiFormatSNorm8,
42 HgiFormatSNorm8Vec2,
43 /* HgiFormatSNorm8Vec3 */ // Unsupported Metal (MTLPixelFormat)
44 HgiFormatSNorm8Vec4,
45
46 // Float16 - a 2-byte IEEE half-precision float.
47 HgiFormatFloat16,
48 HgiFormatFloat16Vec2,
49 HgiFormatFloat16Vec3,
50 HgiFormatFloat16Vec4,
51
52 // Float32 - a 4-byte IEEE float.
53 HgiFormatFloat32,
54 HgiFormatFloat32Vec2,
55 HgiFormatFloat32Vec3,
56 HgiFormatFloat32Vec4,
57
58 // Int16 - a 2-byte signed integer
59 HgiFormatInt16,
60 HgiFormatInt16Vec2,
61 HgiFormatInt16Vec3,
62 HgiFormatInt16Vec4,
63
64 // UInt16 - a 2-byte unsigned integer
65 HgiFormatUInt16,
66 HgiFormatUInt16Vec2,
67 HgiFormatUInt16Vec3,
68 HgiFormatUInt16Vec4,
69
70 // Int32 - a 4-byte signed integer
71 HgiFormatInt32,
72 HgiFormatInt32Vec2,
73 HgiFormatInt32Vec3,
74 HgiFormatInt32Vec4,
75
76 // UNorm8 SRGB - a 1-byte value representing a float between 0 and 1.
77 // Gamma compression/decompression happens during read/write.
78 // Alpha component is linear.
79 /* HgiFormatUNorm8srgb */ // Unsupported by OpenGL
80 /* HgiFormatUNorm8Vec2srgb */ // Unsupported by OpenGL
81 /* HgiFormatUNorm8Vec3srgb */ // Unsupported Metal (MTLPixelFormat)
82 HgiFormatUNorm8Vec4srgb,
83
84 // BPTC compressed. 3-component, 4x4 blocks, signed floating-point
85 HgiFormatBC6FloatVec3,
86
87 // BPTC compressed. 3-component, 4x4 blocks, unsigned floating-point
88 HgiFormatBC6UFloatVec3,
89
90 // BPTC compressed. 4-component, 4x4 blocks, unsigned byte.
91 // Representing a float between 0 and 1.
92 HgiFormatBC7UNorm8Vec4,
93
94 // BPTC compressed. 4-component, 4x4 blocks, unsigned byte, sRGB.
95 // Representing a float between 0 and 1.
96 HgiFormatBC7UNorm8Vec4srgb,
97
98 // S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
99 // Representing a float between 0 and 1.
100 HgiFormatBC1UNorm8Vec4,
101
102 // S3TC/DXT compressed. 4-component, 4x4 blocks, unsigned byte
103 // Representing a float between 0 and 1.
104 HgiFormatBC3UNorm8Vec4,
105
106 // Depth stencil format (Float32 can be used for just depth)
107 HgiFormatFloat32UInt8,
108
109 // Packed 32-bit value with four normalized signed two's complement
110 // integer values arranged as 10 bits, 10 bits, 10 bits, and 2 bits.
111 HgiFormatPackedInt1010102,
112
113 HgiFormatCount
114};
115
120{
127};
128
130HGI_API
131size_t HgiGetComponentCount(HgiFormat f);
132
141HGI_API
142size_t HgiGetDataSizeOfFormat(
143 HgiFormat f,
144 size_t *blockWidth = nullptr,
145 size_t *blockHeight = nullptr);
146
148HGI_API
149bool HgiIsCompressed(HgiFormat f);
150
154HGI_API
155size_t HgiGetDataSize(
156 HgiFormat f,
157 const GfVec3i &dimensions);
158
161HGI_API
162HgiFormat HgiGetComponentBaseFormat(
163 HgiFormat f);
164
166HGI_API
167bool HgiIsFloatFormat(
168 HgiFormat f);
169
183HGI_API
184std::vector<HgiMipInfo>
185HgiGetMipInfos(
186 HgiFormat format,
187 const GfVec3i& dimensions,
188 size_t layerCount,
189 size_t dataByteSize = std::numeric_limits<size_t>::max());
190
191PXR_NAMESPACE_CLOSE_SCOPE
192
193#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
HgiMipInfo describes size and other info for a mip level.
Definition: types.h:120
size_t byteOffset
Offset in bytes from start of texture data to start of mip map.
Definition: types.h:122
GfVec3i dimensions
Dimension of mip GfVec3i.
Definition: types.h:124
size_t byteSizePerLayer
size of (one layer if array of) mip map in bytes.
Definition: types.h:126