summaryrefslogtreecommitdiffstats
path: root/Primitives/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-24 15:35:16 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-24 15:35:16 +0000
commit5525449fd1d987fb957ba2c10a308d975fa98133 (patch)
tree8416e0a552fc2436485a843949ce1ec876dada20 /Primitives/interface
parentclang-formatted Common project (diff)
downloadDiligentCore-5525449fd1d987fb957ba2c10a308d975fa98133.tar.gz
DiligentCore-5525449fd1d987fb957ba2c10a308d975fa98133.zip
clang-formatted Primitives project
Diffstat (limited to 'Primitives/interface')
-rw-r--r--Primitives/interface/BasicTypes.h36
-rw-r--r--Primitives/interface/DataBlob.h9
-rw-r--r--Primitives/interface/DebugOutput.h8
-rw-r--r--Primitives/interface/Errors.h161
-rw-r--r--Primitives/interface/FileStream.h14
-rw-r--r--Primitives/interface/FlagEnum.h24
-rw-r--r--Primitives/interface/FormatString.h114
-rw-r--r--Primitives/interface/InterfaceID.h38
-rw-r--r--Primitives/interface/MemoryAllocator.h6
-rw-r--r--Primitives/interface/Object.h14
-rw-r--r--Primitives/interface/ReferenceCounters.h26
11 files changed, 233 insertions, 217 deletions
diff --git a/Primitives/interface/BasicTypes.h b/Primitives/interface/BasicTypes.h
index c72bcf71..958c6790 100644
--- a/Primitives/interface/BasicTypes.h
+++ b/Primitives/interface/BasicTypes.h
@@ -28,25 +28,27 @@
namespace Diligent
{
- typedef float Float32; ///< 32-bit float
- typedef int64_t Int64; ///< 64-bit signed integer
- typedef int32_t Int32; ///< 32-bit signed integer
- typedef int16_t Int16; ///< 16-bit signed integer
- typedef int8_t Int8; ///< 8-bit signed integer
+using Float32 = float; ///< 32-bit float
- typedef uint64_t Uint64; ///< 64-bit unsigned integer
- typedef uint32_t Uint32; ///< 32-bit unsigned integer
- typedef uint16_t Uint16; ///< 16-bit unsigned integer
- typedef uint8_t Uint8; ///< 8-bit unsigned integer
+using Int64 = int64_t; ///< 64-bit signed integer
+using Int32 = int32_t; ///< 32-bit signed integer
+using Int16 = int16_t; ///< 16-bit signed integer
+using Int8 = int8_t; ///< 8-bit signed integer
- typedef size_t SizeType;
- typedef void* PVoid;
+using Uint64 = uint64_t; ///< 64-bit unsigned integer
+using Uint32 = uint32_t; ///< 32-bit unsigned integer
+using Uint16 = uint16_t; ///< 16-bit unsigned integer
+using Uint8 = uint8_t; ///< 8-bit unsigned integer
- typedef bool Bool; ///< Boolean
- static constexpr Bool False = false;
- static constexpr Bool True = true;
+using SizeType = size_t;
+using PVoid = void*;
- typedef char Char;
- typedef std::basic_string<Char> String; ///< String variable
-}
+using Bool = bool; ///< Boolean
+static constexpr Bool False = false;
+static constexpr Bool True = true;
+
+using Char = char;
+using String = std::basic_string<Char>; ///< String variable
+
+} // namespace Diligent
diff --git a/Primitives/interface/DataBlob.h b/Primitives/interface/DataBlob.h
index 1379ce67..11192270 100644
--- a/Primitives/interface/DataBlob.h
+++ b/Primitives/interface/DataBlob.h
@@ -32,16 +32,15 @@ namespace Diligent
{
// {F578FF0D-ABD2-4514-9D32-7CB454D4A73B}
-static constexpr INTERFACE_ID IID_DataBlob =
-{ 0xf578ff0d, 0xabd2, 0x4514, { 0x9d, 0x32, 0x7c, 0xb4, 0x54, 0xd4, 0xa7, 0x3b } };
+static constexpr INTERFACE_ID IID_DataBlob =
+ {0xf578ff0d, 0xabd2, 0x4514, {0x9d, 0x32, 0x7c, 0xb4, 0x54, 0xd4, 0xa7, 0x3b}};
/// Base interface for a file stream
class IDataBlob : public IObject
{
public:
-
/// Sets the size of the internal data buffer
- virtual void Resize( size_t NewSize ) = 0;
+ virtual void Resize(size_t NewSize) = 0;
/// Returns the size of the internal data buffer
virtual size_t GetSize() = 0;
@@ -50,4 +49,4 @@ public:
virtual void* GetDataPtr() = 0;
};
-}
+} // namespace Diligent
diff --git a/Primitives/interface/DebugOutput.h b/Primitives/interface/DebugOutput.h
index 2fdac40e..0295a356 100644
--- a/Primitives/interface/DebugOutput.h
+++ b/Primitives/interface/DebugOutput.h
@@ -52,7 +52,11 @@ enum class DebugMessageSeverity : Int32
/// \param [in] Function - Name of the function or nullptr
/// \param [in] Function - File name or nullptr
/// \param [in] Line - Line number
-using DebugMessageCallbackType = void(*)(DebugMessageSeverity Severity, const Char* Message, const char* Function, const char* File, int Line);
+using DebugMessageCallbackType = void (*)(DebugMessageSeverity Severity,
+ const Char* Message,
+ const char* Function,
+ const char* File,
+ int Line);
extern DebugMessageCallbackType DebugMessageCallback;
@@ -62,4 +66,4 @@ extern DebugMessageCallbackType DebugMessageCallback;
/// wants to use the callback.
void SetDebugMessageCallback(DebugMessageCallbackType DbgMessageCallback);
-}
+} // namespace Diligent
diff --git a/Primitives/interface/Errors.h b/Primitives/interface/Errors.h
index 5c830cae..1370259b 100644
--- a/Primitives/interface/Errors.h
+++ b/Primitives/interface/Errors.h
@@ -33,28 +33,29 @@
namespace Diligent
{
-template<bool>
-void ThrowIf(std::string &&)
+template <bool>
+void ThrowIf(std::string&&)
{
}
-template<>
-inline void ThrowIf<true>(std::string &&msg)
+template <>
+inline void ThrowIf<true>(std::string&& msg)
{
- throw std::runtime_error( std::move(msg) );
+ throw std::runtime_error(std::move(msg));
}
-template<bool bThrowException, typename... ArgsType>
-void LogError( const char *Function, const char *FullFilePath, int Line, const ArgsType&... Args )
+template <bool bThrowException, typename... ArgsType>
+void LogError(const char* Function, const char* FullFilePath, int Line, const ArgsType&... Args)
{
std::string FileName(FullFilePath);
+
auto LastSlashPos = FileName.find_last_of("/\\");
- if(LastSlashPos != std::string::npos)
- FileName.erase(0, LastSlashPos+1);
+ if (LastSlashPos != std::string::npos)
+ FileName.erase(0, LastSlashPos + 1);
auto Msg = FormatString(Args...);
- if(DebugMessageCallback != nullptr)
+ if (DebugMessageCallback != nullptr)
{
- DebugMessageCallback( bThrowException ? DebugMessageSeverity::FatalError : DebugMessageSeverity::Error, Msg.c_str(), Function, FileName.c_str(), Line);
+ DebugMessageCallback(bThrowException ? DebugMessageSeverity::FatalError : DebugMessageSeverity::Error, Msg.c_str(), Function, FileName.c_str(), Line);
}
else
{
@@ -64,76 +65,82 @@ void LogError( const char *Function, const char *FullFilePath, int Line, const A
ThrowIf<bThrowException>(std::move(Msg));
}
-}
+} // namespace Diligent
-#define LOG_ERROR(...)\
-do{ \
- Diligent::LogError<false>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
-}while(false)
+#define LOG_ERROR(...) \
+ do \
+ { \
+ Diligent::LogError<false>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
+ } while (false)
-#define LOG_ERROR_ONCE(...)\
-do{ \
- static bool IsFirstTime = true; \
- if(IsFirstTime) \
+#define LOG_ERROR_ONCE(...) \
+ do \
{ \
- LOG_ERROR(##__VA_ARGS__); \
- IsFirstTime = false; \
- } \
-}while(false)
-
-
-#define LOG_ERROR_AND_THROW(...)\
-do{ \
- Diligent::LogError<true>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__);\
-}while(false)
-
-
-#define LOG_DEBUG_MESSAGE(Severity, ...)\
-do{ \
- auto _msg = Diligent::FormatString( __VA_ARGS__ );\
- if(Diligent::DebugMessageCallback != nullptr) Diligent::DebugMessageCallback( Severity, _msg.c_str(), nullptr, nullptr, 0 );\
-}while(false)
-
-#define LOG_ERROR_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
-#define LOG_WARNING_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
-#define LOG_INFO_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
-
-
-#define LOG_DEBUG_MESSAGE_ONCE(Severity, ...)\
-do{ \
- static bool IsFirstTime = true; \
- if(IsFirstTime) \
- { \
- LOG_DEBUG_MESSAGE(Severity, ##__VA_ARGS__);\
- IsFirstTime = false; \
- } \
-}while(false)
-
-#define LOG_ERROR_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
-#define LOG_WARNING_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
-#define LOG_INFO_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
-
-
-#define CHECK(Expr, Severity, ...)\
-do{ \
- if( !(Expr) ) \
- { \
- LOG_DEBUG_MESSAGE(Severity, ##__VA_ARGS__);\
- } \
-}while(false)
-
-#define CHECK_ERR(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
+ static bool IsFirstTime = true; \
+ if (IsFirstTime) \
+ { \
+ LOG_ERROR(##__VA_ARGS__); \
+ IsFirstTime = false; \
+ } \
+ } while (false)
+
+
+#define LOG_ERROR_AND_THROW(...) \
+ do \
+ { \
+ Diligent::LogError<true>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
+ } while (false)
+
+
+#define LOG_DEBUG_MESSAGE(Severity, ...) \
+ do \
+ { \
+ auto _msg = Diligent::FormatString(__VA_ARGS__); \
+ if (Diligent::DebugMessageCallback != nullptr) Diligent::DebugMessageCallback(Severity, _msg.c_str(), nullptr, nullptr, 0); \
+ } while (false)
+
+#define LOG_ERROR_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
+#define LOG_WARNING_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
+#define LOG_INFO_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
+
+
+#define LOG_DEBUG_MESSAGE_ONCE(Severity, ...) \
+ do \
+ { \
+ static bool IsFirstTime = true; \
+ if (IsFirstTime) \
+ { \
+ LOG_DEBUG_MESSAGE(Severity, ##__VA_ARGS__); \
+ IsFirstTime = false; \
+ } \
+ } while (false)
+
+#define LOG_ERROR_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
+#define LOG_WARNING_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
+#define LOG_INFO_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
+
+
+#define CHECK(Expr, Severity, ...) \
+ do \
+ { \
+ if (!(Expr)) \
+ { \
+ LOG_DEBUG_MESSAGE(Severity, ##__VA_ARGS__); \
+ } \
+ } while (false)
+
+#define CHECK_ERR(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
#define CHECK_WARN(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
-#define CHECK_INFO(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
-
-#define CHECK_THROW(Expr, ...)\
-do{ \
- if( !(Expr) ) \
- { \
- LOG_ERROR_AND_THROW(##__VA_ARGS__);\
- } \
-}while(false)
-
+#define CHECK_INFO(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
+
+#define CHECK_THROW(Expr, ...) \
+ do \
+ { \
+ if (!(Expr)) \
+ { \
+ LOG_ERROR_AND_THROW(##__VA_ARGS__); \
+ } \
+ } while (false)
diff --git a/Primitives/interface/FileStream.h b/Primitives/interface/FileStream.h
index 2215ba66..23ee1d3c 100644
--- a/Primitives/interface/FileStream.h
+++ b/Primitives/interface/FileStream.h
@@ -34,24 +34,24 @@ namespace Diligent
/// IFileStream interface unique identifier
// {E67F386C-6A5A-4A24-A0CE-C66435465D41}
-static constexpr INTERFACE_ID IID_FileStream =
-{ 0xe67f386c, 0x6a5a, 0x4a24, { 0xa0, 0xce, 0xc6, 0x64, 0x35, 0x46, 0x5d, 0x41 } };
+static constexpr INTERFACE_ID IID_FileStream =
+ {0xe67f386c, 0x6a5a, 0x4a24, {0xa0, 0xce, 0xc6, 0x64, 0x35, 0x46, 0x5d, 0x41}};
/// Base interface for a file stream
class IFileStream : public IObject
{
public:
/// Reads data from the stream
- virtual bool Read( void *Data, size_t BufferSize ) = 0;
+ virtual bool Read(void* Data, size_t BufferSize) = 0;
- virtual void Read( IDataBlob *pData ) = 0;
+ virtual void Read(IDataBlob* pData) = 0;
/// Writes data to the stream
- virtual bool Write( const void *Data, size_t Size ) = 0;
-
+ virtual bool Write(const void* Data, size_t Size) = 0;
+
virtual size_t GetSize() = 0;
virtual bool IsValid() = 0;
};
-}
+} // namespace Diligent
diff --git a/Primitives/interface/FlagEnum.h b/Primitives/interface/FlagEnum.h
index fb145a0c..526ba590 100644
--- a/Primitives/interface/FlagEnum.h
+++ b/Primitives/interface/FlagEnum.h
@@ -25,17 +25,17 @@
#include "BasicTypes.h"
-template<typename EnumType>
+template <typename EnumType>
using _UNDERLYING_ENUM_T = typename std::underlying_type<EnumType>::type;
-#define DEFINE_FLAG_ENUM_OPERATORS(ENUMTYPE)\
-extern "C++"\
-{\
-inline ENUMTYPE& operator |= (ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) |= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline ENUMTYPE& operator &= (ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) &= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline ENUMTYPE& operator ^= (ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) ^= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline constexpr ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE> (static_cast<_UNDERLYING_ENUM_T<ENUMTYPE> >(a) | static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline constexpr ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE> (static_cast<_UNDERLYING_ENUM_T<ENUMTYPE> >(a) & static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline constexpr ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE> (static_cast<_UNDERLYING_ENUM_T<ENUMTYPE> >(a) ^ static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
-inline constexpr ENUMTYPE operator ~ (ENUMTYPE a) throw() { return static_cast<ENUMTYPE> (~static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(a)); } \
-}
+#define DEFINE_FLAG_ENUM_OPERATORS(ENUMTYPE) \
+ extern "C++" \
+ { \
+ inline ENUMTYPE& operator|=(ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) |= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline ENUMTYPE& operator&=(ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) &= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline ENUMTYPE& operator^=(ENUMTYPE& a, ENUMTYPE b) throw() { return reinterpret_cast<ENUMTYPE&>(reinterpret_cast<_UNDERLYING_ENUM_T<ENUMTYPE>&>(a) ^= static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline constexpr ENUMTYPE operator|(ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE>(static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(a) | static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline constexpr ENUMTYPE operator&(ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE>(static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(a) & static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline constexpr ENUMTYPE operator^(ENUMTYPE a, ENUMTYPE b) throw() { return static_cast<ENUMTYPE>(static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(a) ^ static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(b)); } \
+ inline constexpr ENUMTYPE operator~(ENUMTYPE a) throw() { return static_cast<ENUMTYPE>(~static_cast<_UNDERLYING_ENUM_T<ENUMTYPE>>(a)); } \
+ }
diff --git a/Primitives/interface/FormatString.h b/Primitives/interface/FormatString.h
index 4de64c5b..a8bc9549 100644
--- a/Primitives/interface/FormatString.h
+++ b/Primitives/interface/FormatString.h
@@ -28,70 +28,72 @@
namespace Diligent
{
- template<typename SSType>
- void FormatStrSS(SSType &ss)
- {
- }
- template<typename SSType, typename ArgType>
- void FormatStrSS(SSType &ss, const ArgType& Arg)
- {
- ss << Arg;
- }
+template <typename SSType>
+void FormatStrSS(SSType& ss)
+{
+}
- template<typename SSType, typename FirstArgType, typename... RestArgsType>
- void FormatStrSS(SSType &ss, const FirstArgType& FirstArg, const RestArgsType&... RestArgs)
- {
- FormatStrSS( ss, FirstArg );
- FormatStrSS( ss, RestArgs... ); // recursive call using pack expansion syntax
- }
+template <typename SSType, typename ArgType>
+void FormatStrSS(SSType& ss, const ArgType& Arg)
+{
+ ss << Arg;
+}
- template<typename... RestArgsType>
- std::string FormatString(const RestArgsType&... Args)
+template <typename SSType, typename FirstArgType, typename... RestArgsType>
+void FormatStrSS(SSType& ss, const FirstArgType& FirstArg, const RestArgsType&... RestArgs)
+{
+ FormatStrSS(ss, FirstArg);
+ FormatStrSS(ss, RestArgs...); // recursive call using pack expansion syntax
+}
+
+template <typename... RestArgsType>
+std::string FormatString(const RestArgsType&... Args)
+{
+ std::stringstream ss;
+ FormatStrSS(ss, Args...);
+ return ss.str();
+}
+
+template <typename Type>
+struct MemorySizeFormatter
+{
+ MemorySizeFormatter(Type _size, int _precision, Type _ref_size) :
+ size{_size},
+ precision{_precision},
+ ref_size{_ref_size}
+ {}
+ Type size = 0;
+ int precision = 0;
+ Type ref_size = 0;
+};
+
+template <typename Type>
+MemorySizeFormatter<Type> FormatMemorySize(Type _size, int _precision = 0, Type _ref_size = 0)
+{
+ return MemorySizeFormatter<Type>{_size, _precision, _ref_size};
+}
+
+template <typename SSType, typename Type>
+void FormatStrSS(SSType& ss, const MemorySizeFormatter<Type>& Arg)
+{
+ auto ref_size = Arg.ref_size != 0 ? Arg.ref_size : Arg.size;
+ if (ref_size >= (1 << 30))
{
- std::stringstream ss;
- FormatStrSS(ss, Args...);
- return ss.str();
+ ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{1 << 30} << " GB";
}
-
- template<typename Type>
- struct MemorySizeFormatter
+ else if (ref_size >= (1 << 20))
{
- MemorySizeFormatter(Type _size, int _precision, Type _ref_size) :
- size (_size),
- precision(_precision),
- ref_size (_ref_size)
- {}
- Type size = 0;
- int precision = 0;
- Type ref_size = 0;
- };
-
- template<typename Type>
- MemorySizeFormatter<Type> FormatMemorySize(Type _size, int _precision = 0, Type _ref_size = 0)
+ ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{1 << 20} << " MB";
+ }
+ else if (ref_size >= (1 << 10))
{
- return MemorySizeFormatter<Type>{_size, _precision, _ref_size};
+ ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{1 << 10} << " KB";
}
-
- template<typename SSType, typename Type>
- void FormatStrSS(SSType& ss, const MemorySizeFormatter<Type>& Arg)
+ else
{
- auto ref_size = Arg.ref_size != 0 ? Arg.ref_size : Arg.size;
- if (ref_size >= (1 << 30))
- {
- ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{ 1 << 30 } << " GB";
- }
- else if(ref_size >= (1 << 20))
- {
- ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{ 1 << 20 } << " MB";
- }
- else if (ref_size >= (1 << 10))
- {
- ss << std::fixed << std::setprecision(Arg.precision) << static_cast<double>(Arg.size) / double{ 1 << 10 } << " KB";
- }
- else
- {
- ss << Arg.size << ( ((Arg.size & 0x01) == 0x01) ? " Byte" : " Bytes" );
- }
+ ss << Arg.size << (((Arg.size & 0x01) == 0x01) ? " Byte" : " Bytes");
}
}
+
+} // namespace Diligent
diff --git a/Primitives/interface/InterfaceID.h b/Primitives/interface/InterfaceID.h
index 7b384c1c..6000dbee 100644
--- a/Primitives/interface/InterfaceID.h
+++ b/Primitives/interface/InterfaceID.h
@@ -29,23 +29,25 @@
/// Unique identification structures
namespace Diligent
{
- /// Describes unique identifier
- struct INTERFACE_ID
+
+/// Unique interface identifier
+struct INTERFACE_ID
+{
+ Uint32 Data1;
+ Uint16 Data2;
+ Uint16 Data3;
+ Uint8 Data4[8];
+
+ bool operator==(const INTERFACE_ID& rhs) const
{
- Uint32 Data1;
- Uint16 Data2;
- Uint16 Data3;
- Uint8 Data4[8];
-
- bool operator == (const INTERFACE_ID& rhs)const
- {
- return Data1 == rhs.Data1 &&
- Data2 == rhs.Data2 &&
- Data3 == rhs.Data3 &&
- std::memcmp(Data4, rhs.Data4, sizeof(Data4)) == 0;
- }
- };
+ return Data1 == rhs.Data1 &&
+ Data2 == rhs.Data2 &&
+ Data3 == rhs.Data3 &&
+ std::memcmp(Data4, rhs.Data4, sizeof(Data4)) == 0;
+ }
+};
+
+/// Unknown interface
+static constexpr INTERFACE_ID IID_Unknown = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
- /// Unknown interface
- static constexpr INTERFACE_ID IID_Unknown = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
-}
+} // namespace Diligent
diff --git a/Primitives/interface/MemoryAllocator.h b/Primitives/interface/MemoryAllocator.h
index 2324ed02..44a0227c 100644
--- a/Primitives/interface/MemoryAllocator.h
+++ b/Primitives/interface/MemoryAllocator.h
@@ -36,10 +36,10 @@ class IMemoryAllocator
{
public:
/// Allocates block of memory
- virtual void* Allocate( size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) = 0;
+ virtual void* Allocate(size_t Size, const Char* dbgDescription, const char* dbgFileName, const Int32 dbgLineNumber) = 0;
/// Releases memory
- virtual void Free(void *Ptr) = 0;
+ virtual void Free(void* Ptr) = 0;
};
-}
+} // namespace Diligent
diff --git a/Primitives/interface/Object.h b/Primitives/interface/Object.h
index 91333ba2..ea6336ad 100644
--- a/Primitives/interface/Object.h
+++ b/Primitives/interface/Object.h
@@ -38,12 +38,12 @@ class IObject
public:
using CounterValueType = IReferenceCounters::CounterValueType;
- /// Queries the specific interface.
+ /// Queries the specific interface.
/// \param [in] IID - Unique identifier of the requested interface.
/// \param [out] ppInterface - Memory address where the pointer to the requested interface will be written.
/// If the interface is not supported, null pointer will be returned.
- /// \remark The method increments the number of strong references by 1. The interface must be
+ /// \remark The method increments the number of strong references by 1. The interface must be
/// released by a call to Release() method when it is no longer needed.
virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) = 0;
@@ -58,7 +58,7 @@ public:
virtual CounterValueType AddRef() = 0;
- /// Decrements the number of strong references by 1 and destroys the object when the
+ /// Decrements the number of strong references by 1 and destroys the object when the
/// counter reaches zero.
/// \remark This method is equivalent to GetReferenceCounters()->ReleaseStrongRef().\n
@@ -66,15 +66,15 @@ public:
/// \return The number of strong references after decrementing the counter.
/// \note In a multithreaded environment, the returned number may not be reliable
/// as other threads may simultaneously change the actual value of the counter.
- /// The only reliable value is 0 as the object is destroyed when the last
+ /// The only reliable value is 0 as the object is destroyed when the last
/// strong reference is released.
virtual CounterValueType Release() = 0;
- /// Returns the pointer to IReferenceCounters interface of the associated
+ /// Returns the pointer to IReferenceCounters interface of the associated
/// reference counters object. The method does *NOT* increment
/// the number of strong references to the returned object.
- virtual IReferenceCounters* GetReferenceCounters()const = 0;
+ virtual IReferenceCounters* GetReferenceCounters() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Primitives/interface/ReferenceCounters.h b/Primitives/interface/ReferenceCounters.h
index e2678649..b63fd071 100644
--- a/Primitives/interface/ReferenceCounters.h
+++ b/Primitives/interface/ReferenceCounters.h
@@ -31,8 +31,8 @@
namespace Diligent
{
-/// Base interface for a reference counter object that stores the number of strong and
-/// weak references and the pointer to the object. It is necessary to separate reference
+/// Base interface for a reference counter object that stores the number of strong and
+/// weak references and the pointer to the object. It is necessary to separate reference
/// counters from the object to support weak pointers.
class IReferenceCounters
{
@@ -48,7 +48,7 @@ public:
virtual CounterValueType AddStrongRef() = 0;
- /// Decrements the number of strong references by 1 and destroys the referenced object
+ /// Decrements the number of strong references by 1 and destroys the referenced object
/// when the counter reaches zero. If there are no more weak references, destroys the
/// reference counters object itself.
@@ -59,7 +59,7 @@ public:
/// The method is thread-safe and does not require explicit synchronization.
/// \note In a multithreaded environment, the returned number may not be reliable
/// as other threads may simultaneously change the actual value of the counter.
- /// The only reliable value is 0 as the object is destroyed when the last
+ /// The only reliable value is 0 as the object is destroyed when the last
/// strong reference is released.
virtual CounterValueType ReleaseStrongRef() = 0;
@@ -85,14 +85,14 @@ public:
/// Gets the pointer to the IUnknown interface of the referenced object.
- /// \param [out] ppObject - Memory address where the pointer to the object
+ /// \param [out] ppObject - Memory address where the pointer to the object
/// will be stored.
- /// \remark If the object was destroyed, nullptr will be written to *ppObject.
- /// If the object was not released, the pointer to the object's IUnknown interface
- /// will be stored. In this case, the number of strong references to the object
+ /// \remark If the object was destroyed, nullptr will be written to *ppObject.
+ /// If the object was not released, the pointer to the object's IUnknown interface
+ /// will be stored. In this case, the number of strong references to the object
/// will be incremented by 1.\n
/// The method is thread-safe and does not require explicit synchronization.
- virtual void GetObject(class IObject **ppObject) = 0;
+ virtual void GetObject(class IObject** ppObject) = 0;
/// Returns the number of outstanding strong references.
@@ -100,9 +100,9 @@ public:
/// \return The number of strong references.
/// \note In a multithreaded environment, the returned number may not be reliable
/// as other threads may simultaneously change the actual value of the counter.
- /// The only reliable value is 0 as the object is destroyed when the last
+ /// The only reliable value is 0 as the object is destroyed when the last
/// strong reference is released.
- virtual CounterValueType GetNumStrongRefs()const = 0;
+ virtual CounterValueType GetNumStrongRefs() const = 0;
/// Returns the number of outstanding weak references.
@@ -110,7 +110,7 @@ public:
/// \return The number of weak references.
/// \note In a multithreaded environment, the returned number may not be reliable
/// as other threads may simultaneously change the actual value of the counter.
- virtual CounterValueType GetNumWeakRefs()const = 0;
+ virtual CounterValueType GetNumWeakRefs() const = 0;
};
-}
+} // namespace Diligent