GteDataFormat.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <GTEngineDEF.h>
11 #include <string>
12 
13 namespace gte
14 {
15 
16 // Data format types; these map directly to DX11 DXGI_FORMAT.
17 enum GTE_IMPEXP DFType
18 {
19  // DX11.0 formats listed below
82  DF_R8_UINT,
84  DF_R8_SINT,
100  DF_BC4_UNORM,
101  DF_BC4_SNORM,
103  DF_BC5_UNORM,
104  DF_BC5_SNORM,
115  DF_BC6H_UF16,
116  DF_BC6H_SF16,
118  DF_BC7_UNORM,
120  // DX11.1 formats listed below
121  DF_AYUV,
122  DF_Y410,
123  DF_Y416,
124  DF_NV12,
125  DF_P010,
126  DF_P016,
128  DF_YUY2,
129  DF_Y210,
130  DF_Y216,
131  DF_NV11,
132  DF_AI44,
133  DF_IA44,
134  DF_P8,
135  DF_A8P8,
137  DF_NUM_FORMATS
138 };
139 
140 // Enumerations for GL4.
141 enum GTE_IMPEXP DFChannelType
142 {
144  DF_BYTE,
145  DF_UBYTE,
146  DF_SHORT,
147  DF_USHORT,
148  DF_INT,
149  DF_UINT,
151  DF_FLOAT,
152  DF_DOUBLE,
156  DF_NUM_CHANNEL_TYPES
157 };
158 
160 {
161 public:
162  // All data formats are known at compile time. This class provides
163  // queries for format information given the type.
164 
165  // A string version of the DF_* enumeration.
166  inline static std::string const& GetName(DFType type);
167 
168  // The number of bytes per struct.
169  inline static unsigned int GetNumBytesPerStruct(DFType type);
170 
171  // The number of channels per struct.
172  inline static unsigned int GetNumChannels(DFType type);
173 
174  // The type of the channel.
175  inline static DFChannelType GetChannelType(DFType type);
176 
177  // The conversion semantics for the channel. When true, signed integers
178  // are converted to floats in [-1,1] and unsigned integers are converted
179  // to floats in [0,1]. When false, integer data is converted directly to
180  // floats.
181  inline static bool ConvertChannel(DFType type);
182 
183  // Not all DX11 formats are currently supported.
184  inline static bool IsSupported(DFType type);
185 
186  // The struct has a depth format.
187  static bool IsDepth(DFType type);
188 
189 private:
190  // Texel information.
191  static std::string const msName[DF_NUM_FORMATS];
192  static unsigned int const msNumBytesPerStruct[DF_NUM_FORMATS];
193  static unsigned int const msNumChannels[DF_NUM_FORMATS];
194  static DFChannelType const msChannelType[DF_NUM_FORMATS];
195  static bool const msConvertChannel[DF_NUM_FORMATS];
196  static bool const msSupported[DF_NUM_FORMATS];
197 };
198 
199 
200 inline std::string const& DataFormat::GetName(DFType type)
201 {
202  return msName[type];
203 }
204 
205 inline unsigned int DataFormat::GetNumBytesPerStruct(DFType type)
206 {
207  return msNumBytesPerStruct[type];
208 }
209 
210 inline unsigned int DataFormat::GetNumChannels(DFType type)
211 {
212  return msNumChannels[type];
213 }
214 
215 inline DFChannelType DataFormat::GetChannelType(DFType type)
216 {
217  return msChannelType[type];
218 }
219 
220 inline bool DataFormat::ConvertChannel(DFType type)
221 {
222  return msConvertChannel[type];
223 }
224 
225 inline bool DataFormat::IsSupported(DFType type)
226 {
227  return msSupported[type];
228 }
229 
230 inline bool DataFormat::IsDepth(DFType type)
231 {
232  return type == DF_D32_FLOAT_S8X24_UINT
233  || type == DF_D32_FLOAT
234  || type == DF_D24_UNORM_S8_UINT
235  || type == DF_D16_UNORM;
236 }
237 
238 
239 }
DF_R32G32_SINT
Definition: GteDataFormat.h:20
DF_BC4_TYPELESS
Definition: GteDataFormat.h:20
DF_R8G8_TYPELESS
Definition: GteDataFormat.h:20
DF_BC1_TYPELESS
Definition: GteDataFormat.h:20
DF_BC2_UNORM
Definition: GteDataFormat.h:20
DF_R32_FLOAT
Definition: GteDataFormat.h:20
DF_R32G32B32_SINT
Definition: GteDataFormat.h:20
DF_R8G8B8A8_TYPELESS
Definition: GteDataFormat.h:20
DF_X32_TYPELESS_G8X24_UINT
Definition: GteDataFormat.h:20
DF_420_OPAQUE
Definition: GteDataFormat.h:20
DF_USHORT
DF_BC5_TYPELESS
Definition: GteDataFormat.h:20
DF_BC4_UNORM
Definition: GteDataFormat.h:20
static unsigned int GetNumChannels(DFType type)
DF_R16_TYPELESS
Definition: GteDataFormat.h:20
DF_R16_FLOAT
Definition: GteDataFormat.h:20
DF_R8_TYPELESS
Definition: GteDataFormat.h:20
DF_D16_UNORM
Definition: GteDataFormat.h:20
DF_UINT
DF_R10G10B10_XR_BIAS_A2_UNORM
Definition: GteDataFormat.h:20
DF_R32_FLOAT_X8X24_TYPELESS
Definition: GteDataFormat.h:20
DF_NV12
Definition: GteDataFormat.h:20
DF_R16_UINT
Definition: GteDataFormat.h:20
DF_R32_UINT
Definition: GteDataFormat.h:20
DF_BC3_UNORM
Definition: GteDataFormat.h:20
DF_R32G32B32A32_TYPELESS
Definition: GteDataFormat.h:20
DF_R16G16_FLOAT
Definition: GteDataFormat.h:20
DF_R8_SNORM
Definition: GteDataFormat.h:20
static std::string const & GetName(DFType type)
DF_R10G10B10A2_UINT
Definition: GteDataFormat.h:20
DF_R1_UNORM
Definition: GteDataFormat.h:20
DF_UBYTE
DF_R8G8_SNORM
Definition: GteDataFormat.h:20
DF_Y416
Definition: GteDataFormat.h:20
DF_D32_FLOAT_S8X24_UINT
Definition: GteDataFormat.h:20
DF_B5G6R5_UNORM
Definition: GteDataFormat.h:20
DF_BC5_UNORM
Definition: GteDataFormat.h:20
DF_R8G8_B8G8_UNORM
Definition: GteDataFormat.h:20
DF_R16G16B16A16_UINT
Definition: GteDataFormat.h:20
DF_R8G8B8A8_SINT
Definition: GteDataFormat.h:20
DF_R16_SNORM
Definition: GteDataFormat.h:20
DF_R32G32B32_UINT
Definition: GteDataFormat.h:20
DF_BC6H_SF16
Definition: GteDataFormat.h:20
DF_B8G8R8X8_TYPELESS
Definition: GteDataFormat.h:20
DF_DOUBLE
DF_UINT_10_10_2
DF_D32_FLOAT
Definition: GteDataFormat.h:20
DF_R16G16B16A16_FLOAT
Definition: GteDataFormat.h:20
DF_BC1_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_BC7_UNORM
Definition: GteDataFormat.h:20
DF_R8G8_SINT
Definition: GteDataFormat.h:20
static bool ConvertChannel(DFType type)
DF_R8_UNORM
Definition: GteDataFormat.h:20
DF_A8P8
Definition: GteDataFormat.h:20
DF_G8R8_G8B8_UNORM
Definition: GteDataFormat.h:20
DF_R10G10B10A2_TYPELESS
Definition: GteDataFormat.h:20
DF_B8G8R8A8_TYPELESS
Definition: GteDataFormat.h:20
DF_R8G8B8A8_SNORM
Definition: GteDataFormat.h:20
static DFChannelType GetChannelType(DFType type)
DF_HALF_FLOAT
DF_R10G10B10A2_UNORM
Definition: GteDataFormat.h:20
DF_YUY2
Definition: GteDataFormat.h:20
DF_BC4_SNORM
Definition: GteDataFormat.h:20
DF_A8_UNORM
Definition: GteDataFormat.h:20
static bool IsDepth(DFType type)
DF_INT
DF_INT_10_10_2
DF_R32_TYPELESS
Definition: GteDataFormat.h:20
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
DF_B8G8R8X8_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_R8_UINT
Definition: GteDataFormat.h:20
DF_R32G32B32A32_SINT
Definition: GteDataFormat.h:20
DF_R32G32B32A32_FLOAT
Definition: GteDataFormat.h:20
DF_BC3_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_BC6H_TYPELESS
Definition: GteDataFormat.h:20
DF_R16G16B16A16_UNORM
Definition: GteDataFormat.h:20
DF_BC1_UNORM
Definition: GteDataFormat.h:20
DF_B4G4R4A4_UNORM
Definition: GteDataFormat.h:20
static unsigned int GetNumBytesPerStruct(DFType type)
DF_R32G32_TYPELESS
Definition: GteDataFormat.h:20
DF_B8G8R8X8_UNORM
Definition: GteDataFormat.h:20
DF_R16G16B16A16_SNORM
Definition: GteDataFormat.h:20
DF_FLOAT_11_11_10
DF_R32G8X24_TYPELESS
Definition: GteDataFormat.h:20
DF_Y210
Definition: GteDataFormat.h:20
DF_BYTE
DF_B8G8R8A8_UNORM
Definition: GteDataFormat.h:20
DF_P8
Definition: GteDataFormat.h:20
DF_R32G32_FLOAT
Definition: GteDataFormat.h:20
DF_AI44
Definition: GteDataFormat.h:20
DF_BC6H_UF16
Definition: GteDataFormat.h:20
DF_R8G8B8A8_UNORM
Definition: GteDataFormat.h:20
DF_BC2_TYPELESS
Definition: GteDataFormat.h:20
DF_R16G16_SINT
Definition: GteDataFormat.h:20
static bool IsSupported(DFType type)
DF_R32G32_UINT
Definition: GteDataFormat.h:20
DF_D24_UNORM_S8_UINT
Definition: GteDataFormat.h:20
DF_BC5_SNORM
Definition: GteDataFormat.h:20
DF_P016
Definition: GteDataFormat.h:20
DF_BC3_TYPELESS
Definition: GteDataFormat.h:20
DF_R16G16_UNORM
Definition: GteDataFormat.h:20
DF_R8G8B8A8_UINT
Definition: GteDataFormat.h:20
DF_B5G5R5A1_UNORM
Definition: GteDataFormat.h:20
DF_R24G8_TYPELESS
Definition: GteDataFormat.h:20
DF_BC7_TYPELESS
Definition: GteDataFormat.h:20
DF_Y410
Definition: GteDataFormat.h:20
DF_R24_UNORM_X8_TYPELESS
Definition: GteDataFormat.h:20
DF_AYUV
Definition: GteDataFormat.h:20
DF_R32G32B32_TYPELESS
Definition: GteDataFormat.h:20
DF_R9G9B9E5_SHAREDEXP
Definition: GteDataFormat.h:20
DF_R8_SINT
Definition: GteDataFormat.h:20
DF_BC7_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_SHORT
DF_R16G16_TYPELESS
Definition: GteDataFormat.h:20
DF_P010
Definition: GteDataFormat.h:20
DF_R16G16B16A16_TYPELESS
Definition: GteDataFormat.h:20
DF_R16_UNORM
Definition: GteDataFormat.h:20
DF_R32G32B32_FLOAT
Definition: GteDataFormat.h:20
DF_R8G8B8A8_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_B8G8R8A8_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_FLOAT
DF_R8G8_UINT
Definition: GteDataFormat.h:20
DF_BC2_UNORM_SRGB
Definition: GteDataFormat.h:20
DF_UNSUPPORTED
DF_R16_SINT
Definition: GteDataFormat.h:20
DF_R16G16_SNORM
Definition: GteDataFormat.h:20
DF_Y216
Definition: GteDataFormat.h:20
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
DF_R16G16B16A16_SINT
Definition: GteDataFormat.h:20
DF_NV11
Definition: GteDataFormat.h:20
DF_R8G8_UNORM
Definition: GteDataFormat.h:20
DF_IA44
Definition: GteDataFormat.h:20
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:103
DF_R32G32B32A32_UINT
Definition: GteDataFormat.h:20
DF_R11G11B10_FLOAT
Definition: GteDataFormat.h:20
DF_X24_TYPELESS_G8_UINT
Definition: GteDataFormat.h:20
DF_R32_SINT
Definition: GteDataFormat.h:20
DF_R16G16_UINT
Definition: GteDataFormat.h:20
DF_UNKNOWN
Definition: GteDataFormat.h:20


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59