#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_
#include "common/platform.h"
#if defined(ANGLE_WITH_LSAN)
# include <sanitizer/lsan_interface.h>
#endif
#if defined(ANGLE_WITH_MSAN)
# include <sanitizer/msan_interface.h>
#endif
#include <climits>
#include <cstdarg>
#include <cstddef>
#include <mutex>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
namespace angle
{
#if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
using Microsoft::WRL::ComPtr;
#endif
#if defined(ANGLE_PLATFORM_LINUX) || defined(ANGLE_PLATFORM_WINDOWS)
ThreadId;
#else
using ThreadId = std::thread::id;
#endif
class NonCopyable
{ … };
extern const uintptr_t DirtyPointer;
constexpr char kPerfMonitorExtensionName[] = …;
struct PerfMonitorCounter
{ … };
PerfMonitorCounters;
struct PerfMonitorCounterGroup
{ … };
PerfMonitorCounterGroups;
uint32_t GetPerfMonitorCounterIndex(const PerfMonitorCounters &counters, const std::string &name);
const PerfMonitorCounter &GetPerfMonitorCounter(const PerfMonitorCounters &counters,
const std::string &name);
PerfMonitorCounter &GetPerfMonitorCounter(PerfMonitorCounters &counters, const std::string &name);
uint32_t GetPerfMonitorCounterGroupIndex(const PerfMonitorCounterGroups &groups,
const std::string &name);
const PerfMonitorCounterGroup &GetPerfMonitorCounterGroup(const PerfMonitorCounterGroups &groups,
const std::string &name);
PerfMonitorCounterGroup &GetPerfMonitorCounterGroup(PerfMonitorCounterGroups &groups,
const std::string &name);
struct PerfMonitorTriplet
{ … };
#define ANGLE_VK_PERF_COUNTERS_X(FN) …
#define ANGLE_DECLARE_PERF_COUNTER …
struct VulkanPerfCounters
{ … };
#undef ANGLE_DECLARE_PERF_COUNTER
}
template <typename T, size_t N>
constexpr inline size_t ArraySize(T (&)[N])
{ … }
template <typename T>
class WrappedArray final : angle::NonCopyable
{ … };
template <typename T, unsigned int N>
void SafeRelease(T (&resourceBlock)[N])
{ … }
template <typename T>
void SafeRelease(T &resource)
{ … }
template <typename T>
void SafeDelete(T *&resource)
{ … }
template <typename T>
void SafeDeleteContainer(T &resource)
{ … }
template <typename T>
void SafeDeleteArray(T *&resource)
{ … }
template <typename T>
inline bool StructLessThan(const T &a, const T &b)
{ … }
template <typename T>
inline bool StructEquals(const T &a, const T &b)
{ … }
template <typename T>
inline void StructZero(T *obj)
{ … }
template <typename T>
inline bool IsMaskFlagSet(T mask, T flag)
{ … }
inline const char *MakeStaticString(const std::string &str)
{ … }
std::string ArrayString(unsigned int i);
std::string ArrayIndexString(const std::vector<unsigned int> &indices);
inline std::string Str(int i)
{ … }
template <typename T>
std::string ToString(const T &value)
{ … }
inline bool IsLittleEndian()
{ … }
#define SetBitField(lhs, rhs) …
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf …
#endif
#define GL_A1RGB5_ANGLEX …
#define GL_BGRX8_ANGLEX …
#define GL_BGR565_ANGLEX …
#define GL_BGRA4_ANGLEX …
#define GL_BGR5_A1_ANGLEX …
#define GL_INT_64_ANGLEX …
#define GL_UINT_64_ANGLEX …
#define GL_BGRA8_SRGB_ANGLEX …
#define GL_BGR10_A2_ANGLEX …
#define GL_BGRX8_SRGB_ANGLEX …
#define GL_RGBX8_SRGB_ANGLEX …
#define GL_RGBA8_TYPELESS_ANGLEX …
#define GL_RGBA8_TYPELESS_SRGB_ANGLEX …
#define GL_BGRA8_TYPELESS_ANGLEX …
#define GL_BGRA8_TYPELESS_SRGB_ANGLEX …
#define GL_R8_SSCALED_ANGLEX …
#define GL_RG8_SSCALED_ANGLEX …
#define GL_RGB8_SSCALED_ANGLEX …
#define GL_RGBA8_SSCALED_ANGLEX …
#define GL_R8_USCALED_ANGLEX …
#define GL_RG8_USCALED_ANGLEX …
#define GL_RGB8_USCALED_ANGLEX …
#define GL_RGBA8_USCALED_ANGLEX …
#define GL_R16_SSCALED_ANGLEX …
#define GL_RG16_SSCALED_ANGLEX …
#define GL_RGB16_SSCALED_ANGLEX …
#define GL_RGBA16_SSCALED_ANGLEX …
#define GL_R16_USCALED_ANGLEX …
#define GL_RG16_USCALED_ANGLEX …
#define GL_RGB16_USCALED_ANGLEX …
#define GL_RGBA16_USCALED_ANGLEX …
#define GL_R32_SSCALED_ANGLEX …
#define GL_RG32_SSCALED_ANGLEX …
#define GL_RGB32_SSCALED_ANGLEX …
#define GL_RGBA32_SSCALED_ANGLEX …
#define GL_R32_USCALED_ANGLEX …
#define GL_RG32_USCALED_ANGLEX …
#define GL_RGB32_USCALED_ANGLEX …
#define GL_RGBA32_USCALED_ANGLEX …
#define GL_R32_SNORM_ANGLEX …
#define GL_RG32_SNORM_ANGLEX …
#define GL_RGB32_SNORM_ANGLEX …
#define GL_RGBA32_SNORM_ANGLEX …
#define GL_R32_UNORM_ANGLEX …
#define GL_RG32_UNORM_ANGLEX …
#define GL_RGB32_UNORM_ANGLEX …
#define GL_RGBA32_UNORM_ANGLEX …
#define GL_R32_FIXED_ANGLEX …
#define GL_RG32_FIXED_ANGLEX …
#define GL_RGB32_FIXED_ANGLEX …
#define GL_RGBA32_FIXED_ANGLEX …
#define GL_RGB10_A2_SINT_ANGLEX …
#define GL_RGB10_A2_SNORM_ANGLEX …
#define GL_RGB10_A2_SSCALED_ANGLEX …
#define GL_RGB10_A2_USCALED_ANGLEX …
#define GL_RGB10_UNORM_ANGLEX …
#define GL_A2_RGB10_UNORM_ANGLEX …
#define GL_A2_RGB10_SNORM_ANGLEX …
#define GL_A2_RGB10_USCALED_ANGLEX …
#define GL_A2_RGB10_SSCALED_ANGLEX …
#define GL_X2_RGB10_UINT_ANGLEX …
#define GL_X2_RGB10_SINT_ANGLEX …
#define GL_X2_RGB10_USCALED_ANGLEX …
#define GL_X2_RGB10_SSCALED_ANGLEX …
#define GL_X2_RGB10_UNORM_ANGLEX …
#define GL_X2_RGB10_SNORM_ANGLEX …
#define ANGLE_CHECK_GL_ALLOC(context, result) …
#define ANGLE_CHECK_GL_MATH(context, result) …
#define ANGLE_GL_UNREACHABLE(context) …
#if defined(ANGLE_WITH_LSAN)
#define ANGLE_SCOPED_DISABLE_LSAN …
#else
#define ANGLE_SCOPED_DISABLE_LSAN() …
#endif
#if defined(ANGLE_WITH_MSAN)
class MsanScopedDisableInterceptorChecks final : angle::NonCopyable
{
public:
MsanScopedDisableInterceptorChecks() { __msan_scoped_disable_interceptor_checks(); }
~MsanScopedDisableInterceptorChecks() { __msan_scoped_enable_interceptor_checks(); }
};
#define ANGLE_SCOPED_DISABLE_MSAN …
#else
#define ANGLE_SCOPED_DISABLE_MSAN() …
#endif
#ifdef __clang__
#define ANGLE_NO_SANITIZE_MEMORY …
#else
#define ANGLE_NO_SANITIZE_MEMORY
#endif
#ifdef __clang__
#define ANGLE_NO_SANITIZE_THREAD …
#else
#define ANGLE_NO_SANITIZE_THREAD
#endif
#ifdef __clang__
#define ANGLE_NO_SANITIZE_CFI_ICALL …
#else
#define ANGLE_NO_SANITIZE_CFI_ICALL
#endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
#define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE …
#define ANGLE_HAS___FORCEINLINE …
#elif defined(_MSC_VER)
#define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE …
#define ANGLE_HAS___FORCEINLINE …
#else
#define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE …
#define ANGLE_HAS___FORCEINLINE …
#endif
#if defined(NDEBUG) && ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE
#define ANGLE_INLINE …
#elif defined(NDEBUG) && ANGLE_HAS___FORCEINLINE
#define ANGLE_INLINE …
#else
#define ANGLE_INLINE …
#endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
# if __has_attribute(noinline)
#define ANGLE_NOINLINE …
# else
#define ANGLE_NOINLINE
# endif
#elif defined(_MSC_VER)
#define ANGLE_NOINLINE …
#else
#define ANGLE_NOINLINE
#endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
# if __has_attribute(format)
#define ANGLE_FORMAT_PRINTF(fmt, args) …
# else
#define ANGLE_FORMAT_PRINTF …
# endif
#else
#define ANGLE_FORMAT_PRINTF …
#endif
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
#define ANGLE_HAS_ATTRIBUTE_CONSTRUCTOR …
#define ANGLE_HAS_ATTRIBUTE_DESTRUCTOR …
#else
#define ANGLE_HAS_ATTRIBUTE_CONSTRUCTOR …
#define ANGLE_HAS_ATTRIBUTE_DESTRUCTOR …
#endif
#if ANGLE_HAS_ATTRIBUTE_CONSTRUCTOR
#define ANGLE_CONSTRUCTOR …
#endif
#if ANGLE_HAS_ATTRIBUTE_DESTRUCTOR
#define ANGLE_DESTRUCTOR …
#endif
ANGLE_FORMAT_PRINTF(1, 0)
size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector<char> &buffer);
#ifndef ANGLE_STRINGIFY
#define ANGLE_STRINGIFY(x) …
#endif
#ifndef ANGLE_MACRO_STRINGIFY
#define ANGLE_MACRO_STRINGIFY(x) …
#endif
#if defined(__clang__) || defined(_MSC_VER)
#define ANGLE_MAYBE_UNUSED_PRIVATE_FIELD …
#else
#define ANGLE_MAYBE_UNUSED_PRIVATE_FIELD
#endif
#if __has_cpp_attribute(clang::require_constant_initialization)
#define ANGLE_REQUIRE_CONSTANT_INIT …
#else
#define ANGLE_REQUIRE_CONSTANT_INIT
#endif
inline bool IsASan()
{ … }
inline bool IsMSan()
{ … }
inline bool IsTSan()
{ … }
inline bool IsUBSan()
{ … }
#endif