Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsAccessories/interface/GraphicsAccessories.h Source File

Diligent Engine API Reference

GraphicsAccessories.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include "GraphicsTypes.h"
30 #include "Shader.h"
31 #include "Texture.h"
32 #include "Buffer.h"
33 #include "RenderDevice.h"
34 #include "DebugUtilities.h"
35
36 namespace Diligent
37 {
38
40 template<VALUE_TYPE ValType>
41 struct VALUE_TYPE2CType
42 {};
43
45
49 template<>struct VALUE_TYPE2CType<VT_INT8> { typedef Int8 CType; };
50
52
56 template<>struct VALUE_TYPE2CType<VT_INT16> { typedef Int16 CType; };
57
59
63 template<>struct VALUE_TYPE2CType<VT_INT32> { typedef Int32 CType; };
64
66
70 template<>struct VALUE_TYPE2CType<VT_UINT8> { typedef Uint8 CType; };
71
73
77 template<>struct VALUE_TYPE2CType<VT_UINT16>{ typedef Uint16 CType; };
78
80
84 template<>struct VALUE_TYPE2CType<VT_UINT32>{ typedef Uint32 CType; };
85
87
93 template<>struct VALUE_TYPE2CType<VT_FLOAT16>{ typedef Uint16 CType; };
94
96
100 template<>struct VALUE_TYPE2CType<VT_FLOAT32>{ typedef Float32 CType; };
101
102
103 static const Uint32 ValueTypeToSizeMap[] =
104 {
105 0,
106 sizeof(VALUE_TYPE2CType<VT_INT8> :: CType),
107 sizeof(VALUE_TYPE2CType<VT_INT16> :: CType),
108 sizeof(VALUE_TYPE2CType<VT_INT32> :: CType),
109 sizeof(VALUE_TYPE2CType<VT_UINT8> :: CType),
110 sizeof(VALUE_TYPE2CType<VT_UINT16> :: CType),
111 sizeof(VALUE_TYPE2CType<VT_UINT32> :: CType),
112 sizeof(VALUE_TYPE2CType<VT_FLOAT16> :: CType),
113 sizeof(VALUE_TYPE2CType<VT_FLOAT32> :: CType)
114 };
115 static_assert(VT_NUM_TYPES == VT_FLOAT32 + 1, "Not all value type sizes initialized.");
116
118 inline Uint32 GetValueSize(VALUE_TYPE Val)
119 {
120 VERIFY_EXPR(Val < _countof(ValueTypeToSizeMap));
121 return ValueTypeToSizeMap[Val];
122 }
123
125 const Char* GetValueTypeString( VALUE_TYPE Val );
126
128
132 const TextureFormatAttribs& GetTextureFormatAttribs(TEXTURE_FORMAT Format);
133
135
153 TEXTURE_FORMAT GetDefaultTextureViewFormat(TEXTURE_FORMAT TextureFormat, TEXTURE_VIEW_TYPE ViewType, Uint32 BindFlags);
154
156
160 inline TEXTURE_FORMAT GetDefaultTextureViewFormat(const TextureDesc &TexDesc, TEXTURE_VIEW_TYPE ViewType)
161 {
162 return GetDefaultTextureViewFormat(TexDesc.Format, ViewType, TexDesc.BindFlags);
163 }
164
167
170 const Char *GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType);
171
174
177 const Char *GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType);
178
181
184 const Char *GetShaderTypeLiteralName(SHADER_TYPE ShaderType);
185
186
190
194 const Char *GetShaderVariableTypeLiteralName(SHADER_VARIABLE_TYPE VarType, bool bGetFullName = false);
195
198 inline const Char* GetViewTypeLiteralName(TEXTURE_VIEW_TYPE TexViewType)
199 {
200 return GetTexViewTypeLiteralName( TexViewType );
201 }
202
205 inline const Char* GetViewTypeLiteralName(BUFFER_VIEW_TYPE BuffViewType)
206 {
207 return GetBufferViewTypeLiteralName( BuffViewType );
208 }
209
211 const Char* GetUsageString(USAGE Usage);
212
214 const Char* GetResourceDimString( RESOURCE_DIMENSION TexType );
215
217 String GetBindFlagsString( Uint32 BindFlags );
218
220 String GetCPUAccessFlagsString( Uint32 CpuAccessFlags );
221
223 String GetTextureDescString(const TextureDesc &Desc);
224
226 String GetBufferDescString(const BufferDesc &Desc);
227
228
230 template<typename TObjectDescType>
231 String GetObjectDescString( const TObjectDescType& )
232 {
233 return "";
234 }
235
237 template<>
238 inline String GetObjectDescString( const TextureDesc& TexDesc )
239 {
240 String Str( "Tex desc: " );
241 Str += GetTextureDescString( TexDesc );
242 return Str;
243 }
244
246 template<>
247 inline String GetObjectDescString( const BufferDesc& BuffDesc )
248 {
249 String Str( "Buff desc: " );
250 Str += GetBufferDescString( BuffDesc );
251 return Str;
252 }
253
254 Uint32 ComputeMipLevelsCount( Uint32 Width );
255 Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height );
256 Uint32 ComputeMipLevelsCount( Uint32 Width, Uint32 Height, Uint32 Depth );
257 }
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:244
Diligent::VT_UINT8
Unsigned 8-bit integer.
Definition: GraphicsTypes.h:45
Diligent::VT_INT8
Signed 8-bit integer.
Definition: GraphicsTypes.h:42
Diligent::TextureDesc
Texture description.
Definition: Texture.h:82
Diligent::Int8
int8_t Int8
8-bit signed integer
Definition: BasicTypes.h:36
Diligent::TEXTURE_VIEW_TYPE
TEXTURE_VIEW_TYPE
Texture view type.
Definition: GraphicsTypes.h:190
Diligent::GetUsageString
const Char * GetUsageString(USAGE Usage)
Returns the string containing the usage.
Definition: GraphicsAccessories.cpp:506
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: Shader.h:46
Diligent::VT_UINT16
Unsigned 16-bit integer.
Definition: GraphicsTypes.h:46
Diligent
Graphics engine namespace.
Definition: AdaptiveFixedBlockAllocator.h:30
Diligent::VALUE_TYPE2CType< VT_INT8 >
VALUE_TYPE2CType<> template specialization for 8-bit integer value type.
Definition: GraphicsAccessories.h:49
Diligent::GetShaderTypeLiteralName
const Char * GetShaderTypeLiteralName(SHADER_TYPE ShaderType)
Returns the literal name of a shader type. For instance, for a pixel shader, "SHADER_TYPE_PIXEL" will...
Definition: GraphicsAccessories.cpp:458
Diligent::TextureDesc::Format
TEXTURE_FORMAT Format
Texture format, see Diligent::TEXTURE_FORMAT.
Definition: Texture.h:102
Diligent::VALUE_TYPE2CType< VT_UINT16 >
VALUE_TYPE2CType<> template specialization for 16-bit unsigned-integer value type.
Definition: GraphicsAccessories.h:77
Diligent::GetViewTypeLiteralName
const Char * GetViewTypeLiteralName(TEXTURE_VIEW_TYPE TexViewType)
Overloaded function that returns the literal name of a texture view type. see GetTexViewTypeLiteralNa...
Definition: GraphicsAccessories.h:198
Diligent::VALUE_TYPE2CType< VT_INT32 >
VALUE_TYPE2CType<> template specialization for 32-bit integer value type.
Definition: GraphicsAccessories.h:63
Diligent::GetCPUAccessFlagsString
String GetCPUAccessFlagsString(Uint32 CpuAccessFlags)
Returns the string containing the CPU access flags.
Definition: GraphicsAccessories.cpp:610
Diligent::VT_INT32
Signed 32-bit integer.
Definition: GraphicsTypes.h:44
Diligent::GetTextureFormatAttribs
const TextureFormatAttribs & GetTextureFormatAttribs(TEXTURE_FORMAT Format)
Returns invariant texture format attributes, see TextureFormatAttribs for details.
Definition: GraphicsAccessories.cpp:238
Diligent::GetBindFlagsString
String GetBindFlagsString(Uint32 BindFlags)
Returns the string containing the bind flags.
Definition: GraphicsAccessories.cpp:577
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:41
Diligent::GetResourceDimString
const Char * GetResourceDimString(RESOURCE_DIMENSION TexType)
Returns the string containing the texture type.
Definition: GraphicsAccessories.cpp:529
Diligent::GetValueTypeString
const Char * GetValueTypeString(VALUE_TYPE Val)
Returns the string representing the specified value type.
Definition: GraphicsAccessories.cpp:31
Diligent::SHADER_VARIABLE_TYPE
SHADER_VARIABLE_TYPE
Describes shader variable type that is used by ShaderVariableDesc.
Definition: Shader.h:100
Diligent::String
std::basic_string< Char > String
String variable.
Definition: BasicTypes.h:51
Diligent::VT_INT16
Signed 16-bit integer.
Definition: GraphicsTypes.h:43
Diligent::BufferDesc
Buffer description.
Definition: Buffer.h:57
Diligent::Float32
float Float32
32-bit float
Definition: BasicTypes.h:31
Diligent::VALUE_TYPE
VALUE_TYPE
Value type.
Definition: GraphicsTypes.h:39
Diligent::Int16
int16_t Int16
16-bit signed integer
Definition: BasicTypes.h:35
Diligent::VALUE_TYPE2CType
Template structure to convert VALUE_TYPE enumeration into C-type.
Definition: GraphicsAccessories.h:41
Diligent::VT_FLOAT16
Half-precision 16-bit floating point.
Definition: GraphicsTypes.h:48
Diligent::USAGE
USAGE
Resource usage.
Definition: GraphicsTypes.h:84
Diligent::Uint16
uint16_t Uint16
16-bit unsigned integer
Definition: BasicTypes.h:40
Diligent::VT_NUM_TYPES
Helper value storing total number of types in the enumeration.
Definition: GraphicsTypes.h:50
Diligent::GetBufferDescString
String GetBufferDescString(const BufferDesc &Desc)
Returns the string containing the buffer description.
Definition: GraphicsAccessories.cpp:708
Diligent::RESOURCE_DIMENSION
RESOURCE_DIMENSION
Describes resource dimension.
Definition: GraphicsTypes.h:172
Diligent::VT_FLOAT32
Full-precision 32-bit floating point.
Definition: GraphicsTypes.h:49
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:39
Diligent::GetValueSize
Uint32 GetValueSize(VALUE_TYPE Val)
Returns the size of the specified value type.
Definition: GraphicsAccessories.h:118
Diligent::VT_UINT32
Unsigned 32-bit integer.
Definition: GraphicsTypes.h:47
Diligent::GetBufferViewTypeLiteralName
const Char * GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType)
Returns the literal name of a buffer view type. For instance, for an unordered access view...
Definition: GraphicsAccessories.cpp:427
Diligent::GetShaderVariableTypeLiteralName
const Char * GetShaderVariableTypeLiteralName(SHADER_VARIABLE_TYPE VarType, bool bGetFullName=false)
Returns the literal name of a shader variable type. For instance, for SHADER_VARIABLE_TYPE_STATIC, if bGetFullName == true, "SHADER_VARIABLE_TYPE_STATIC" will be returned; if bGetFullName == false, "static" will be returned.
Definition: GraphicsAccessories.cpp:478
Diligent::Int32
int32_t Int32
32-bit signed integer
Definition: BasicTypes.h:34
Diligent::GetTexViewTypeLiteralName
const Char * GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType)
Returns the literal name of a texture view type. For instance, for a shader resource view...
Definition: GraphicsAccessories.cpp:394
Diligent::VALUE_TYPE2CType< VT_FLOAT16 >
VALUE_TYPE2CType<> template specialization for half-precision 16-bit floating-point value type...
Definition: GraphicsAccessories.h:93
Diligent::TextureDesc::BindFlags
Uint32 BindFlags
Bind flags, see Diligent::BIND_FLAGS for details. The following bind flags are allowed: Diligent::BI...
Definition: Texture.h:120
Diligent::BUFFER_VIEW_TYPE
BUFFER_VIEW_TYPE
Buffer view type.
Definition: GraphicsTypes.h:219
Diligent::GetTextureDescString
String GetTextureDescString(const TextureDesc &Desc)
Returns the string containing the texture description.
Definition: GraphicsAccessories.cpp:639
Diligent::GetDefaultTextureViewFormat
TEXTURE_FORMAT GetDefaultTextureViewFormat(TEXTURE_FORMAT TextureFormat, TEXTURE_VIEW_TYPE ViewType, Uint32 BindFlags)
Returns the default format for a specified texture view type.
Definition: GraphicsAccessories.cpp:232
Diligent::GetObjectDescString
String GetObjectDescString(const TObjectDescType &)
Helper template function that converts object description into a string.
Definition: GraphicsAccessories.h:231