summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/common
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-18 08:24:24 +0200
commitfc61780b35af913801d72086456f493f63197da6 (patch)
treef85891288a7bd988da9f0f15ae64e5c63f00d493 /gfx/angle/src/common
parent69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff)
parent50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff)
downloadUXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.gz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.lz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.tar.xz
UXP-9ccb235f04529c1ec345d87dad6521cb567d20bb.zip
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts: # browser/app/profile/firefox.js # browser/components/preferences/jar.mn
Diffstat (limited to 'gfx/angle/src/common')
-rwxr-xr-xgfx/angle/src/common/BitSetIterator.h1
-rwxr-xr-xgfx/angle/src/common/angleutils.h8
-rwxr-xr-xgfx/angle/src/common/debug.cpp5
-rwxr-xr-xgfx/angle/src/common/debug.h90
-rwxr-xr-xgfx/angle/src/common/mathutil.cpp18
-rwxr-xr-xgfx/angle/src/common/mathutil.h43
-rwxr-xr-xgfx/angle/src/common/third_party/numerics/base/logging.h4
-rwxr-xr-xgfx/angle/src/common/third_party/numerics/base/numerics/safe_conversions_impl.h2
-rwxr-xr-xgfx/angle/src/common/utilities.cpp37
-rwxr-xr-xgfx/angle/src/common/utilities.h70
10 files changed, 51 insertions, 227 deletions
diff --git a/gfx/angle/src/common/BitSetIterator.h b/gfx/angle/src/common/BitSetIterator.h
index 7fecd3769..3248ce44c 100755
--- a/gfx/angle/src/common/BitSetIterator.h
+++ b/gfx/angle/src/common/BitSetIterator.h
@@ -104,6 +104,7 @@ inline unsigned long ScanForward(unsigned long bits)
unsigned long firstBitIndex = 0ul;
unsigned char ret = _BitScanForward(&firstBitIndex, bits);
ASSERT(ret != 0);
+ UNUSED_ASSERTION_VARIABLE(ret);
return firstBitIndex;
#elif defined(ANGLE_PLATFORM_POSIX)
return static_cast<unsigned long>(__builtin_ctzl(bits));
diff --git a/gfx/angle/src/common/angleutils.h b/gfx/angle/src/common/angleutils.h
index f5ef7bdc1..ea1a0cae3 100755
--- a/gfx/angle/src/common/angleutils.h
+++ b/gfx/angle/src/common/angleutils.h
@@ -156,14 +156,6 @@ size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector<char>
std::string FormatString(const char *fmt, va_list vararg);
std::string FormatString(const char *fmt, ...);
-template <typename T>
-std::string ToString(const T &value)
-{
- std::ostringstream o;
- o << value;
- return o.str();
-}
-
// snprintf is not defined with MSVC prior to to msvc14
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
diff --git a/gfx/angle/src/common/debug.cpp b/gfx/angle/src/common/debug.cpp
index f64d9322f..746da5e0d 100755
--- a/gfx/angle/src/common/debug.cpp
+++ b/gfx/angle/src/common/debug.cpp
@@ -171,9 +171,4 @@ ScopedPerfEventHelper::~ScopedPerfEventHelper()
}
}
-std::ostream &DummyStream()
-{
- return std::cout;
}
-
-} // namespace gl
diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h
index 9356090ae..ccc80e802 100755
--- a/gfx/angle/src/common/debug.h
+++ b/gfx/angle/src/common/debug.h
@@ -57,20 +57,7 @@ void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator);
void UninitializeDebugAnnotations();
bool DebugAnnotationsActive();
-// This class is used to explicitly ignore values in the conditional logging macros. This avoids
-// compiler warnings like "value computed is not used" and "statement has no effect".
-class LogMessageVoidify
-{
- public:
- LogMessageVoidify() {}
- // This has to be an operator with a precedence lower than << but higher than ?:
- void operator&(std::ostream &) {}
-};
-
-// This can be any ostream, it is unused, but needs to be a valid reference.
-std::ostream &DummyStream();
-
-} // namespace gl
+}
#if defined(ANGLE_ENABLE_DEBUG_TRACE) || defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
#define ANGLE_TRACE_ENABLED
@@ -117,58 +104,61 @@ std::ostream &DummyStream();
#undef ANGLE_TRACE_ENABLED
#endif
-#if defined(COMPILER_GCC) || defined(__clang__)
-#define ANGLE_CRASH() __builtin_trap()
-#else
-#define ANGLE_CRASH() ((void)(*(volatile char *)0 = 0))
-#endif
-
#if !defined(NDEBUG)
#define ANGLE_ASSERT_IMPL(expression) assert(expression)
#else
// TODO(jmadill): Detect if debugger is attached and break.
-#define ANGLE_ASSERT_IMPL(expression) ANGLE_CRASH()
+#define ANGLE_ASSERT_IMPL(expression) abort()
#endif // !defined(NDEBUG)
-// Helper macro which avoids evaluating the arguments to a stream if the condition doesn't hold.
-// Condition is evaluated once and only once.
-#define ANGLE_LAZY_STREAM(stream, condition) \
- !(condition) ? static_cast<void>(0) : ::gl::LogMessageVoidify() & (stream)
-
-#if defined(NDEBUG) && !defined(ANGLE_ENABLE_ASSERTS)
-#define ANGLE_ASSERTS_ON 0
-#else
-#define ANGLE_ASSERTS_ON 1
-#endif
-
// A macro asserting a condition and outputting failures to the debug log
-#if ANGLE_ASSERTS_ON
-#define ASSERT(expression) \
- (expression ? static_cast<void>(0) \
- : (ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression), \
- ANGLE_ASSERT_IMPL(expression)))
+#if defined(ANGLE_ENABLE_ASSERTS)
+#define ASSERT(expression) \
+ { \
+ if (!(expression)) \
+ { \
+ ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression); \
+ ANGLE_ASSERT_IMPL(expression); \
+ } \
+ } \
+ ANGLE_EMPTY_STATEMENT
+#define UNUSED_ASSERTION_VARIABLE(variable)
#else
-#define ASSERT(condition) \
- ANGLE_LAZY_STREAM(::gl::DummyStream(), ANGLE_ASSERTS_ON ? !(condition) : false) \
- << "Check failed: " #condition ". "
-#endif // ANGLE_ASSERTS_ON
+#define ASSERT(expression) (void(0))
+#define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable)
+#endif
#define UNUSED_VARIABLE(variable) ((void)variable)
// A macro to indicate unimplemented functionality
-#ifndef NOASSERT_UNIMPLEMENTED
+
+#if defined (ANGLE_TEST_CONFIG)
#define NOASSERT_UNIMPLEMENTED 1
#endif
-#define UNIMPLEMENTED() \
- { \
- ERR("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
- ASSERT(NOASSERT_UNIMPLEMENTED); \
- } \
- ANGLE_EMPTY_STATEMENT
+// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
+// This will allow us to test with some automated test suites (eg dEQP) without crashing
+#ifndef NOASSERT_UNIMPLEMENTED
+#define NOASSERT_UNIMPLEMENTED 0
+#endif
+
+#if !defined(NDEBUG)
+#define UNIMPLEMENTED() { \
+ FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(NOASSERT_UNIMPLEMENTED); \
+ } ANGLE_EMPTY_STATEMENT
+#else
+ #define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
+#endif
// A macro for code which is not expected to be reached under valid assumptions
-#define UNREACHABLE() \
- (ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__), ASSERT(false))
+#if !defined(NDEBUG)
+#define UNREACHABLE() { \
+ ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+ } ANGLE_EMPTY_STATEMENT
+#else
+ #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
+#endif
#endif // COMMON_DEBUG_H_
diff --git a/gfx/angle/src/common/mathutil.cpp b/gfx/angle/src/common/mathutil.cpp
index 5db997c66..acbcbdf0c 100755
--- a/gfx/angle/src/common/mathutil.cpp
+++ b/gfx/angle/src/common/mathutil.cpp
@@ -14,9 +14,6 @@
namespace gl
{
-namespace
-{
-
struct RGB9E5Data
{
unsigned int R : 9;
@@ -26,20 +23,17 @@ struct RGB9E5Data
};
// B is the exponent bias (15)
-constexpr int g_sharedexp_bias = 15;
+static const int g_sharedexp_bias = 15;
// N is the number of mantissa bits per component (9)
-constexpr int g_sharedexp_mantissabits = 9;
+static const int g_sharedexp_mantissabits = 9;
// Emax is the maximum allowed biased exponent value (31)
-constexpr int g_sharedexp_maxexponent = 31;
-
-constexpr float g_sharedexp_max =
- ((static_cast<float>(1 << g_sharedexp_mantissabits) - 1) /
- static_cast<float>(1 << g_sharedexp_mantissabits)) *
- static_cast<float>(1 << (g_sharedexp_maxexponent - g_sharedexp_bias));
+static const int g_sharedexp_maxexponent = 31;
-} // anonymous namespace
+static const float g_sharedexp_max = ((pow(2.0f, g_sharedexp_mantissabits) - 1) /
+ pow(2.0f, g_sharedexp_mantissabits)) *
+ pow(2.0f, g_sharedexp_maxexponent - g_sharedexp_bias);
unsigned int convertRGBFloatsTo999E5(float red, float green, float blue)
{
diff --git a/gfx/angle/src/common/mathutil.h b/gfx/angle/src/common/mathutil.h
index 630b6c088..a82f2ecef 100755
--- a/gfx/angle/src/common/mathutil.h
+++ b/gfx/angle/src/common/mathutil.h
@@ -44,15 +44,6 @@ struct Vector4
float w;
};
-struct Vector2
-{
- Vector2() {}
- Vector2(float x, float y) : x(x), y(y) {}
-
- float x;
- float y;
-};
-
inline bool isPow2(int x)
{
return (x & (x - 1)) == 0 && (x != 0);
@@ -765,40 +756,6 @@ constexpr unsigned int iSquareRoot()
return priv::iSquareRoot<N, 1>::value;
}
-// Sum, difference and multiplication operations for signed ints that wrap on 32-bit overflow.
-//
-// Unsigned types are defined to do arithmetic modulo 2^n in C++. For signed types, overflow
-// behavior is undefined.
-
-template <typename T>
-inline T WrappingSum(T lhs, T rhs)
-{
- uint32_t lhsUnsigned = static_cast<uint32_t>(lhs);
- uint32_t rhsUnsigned = static_cast<uint32_t>(rhs);
- return static_cast<T>(lhsUnsigned + rhsUnsigned);
-}
-
-template <typename T>
-inline T WrappingDiff(T lhs, T rhs)
-{
- uint32_t lhsUnsigned = static_cast<uint32_t>(lhs);
- uint32_t rhsUnsigned = static_cast<uint32_t>(rhs);
- return static_cast<T>(lhsUnsigned - rhsUnsigned);
-}
-
-inline int32_t WrappingMul(int32_t lhs, int32_t rhs)
-{
- int64_t lhsWide = static_cast<int64_t>(lhs);
- int64_t rhsWide = static_cast<int64_t>(rhs);
- // The multiplication is guaranteed not to overflow.
- int64_t resultWide = lhsWide * rhsWide;
- // Implement the desired wrapping behavior by masking out the high-order 32 bits.
- resultWide = resultWide & 0xffffffffll;
- // Casting to a narrower signed type is fine since the casted value is representable in the
- // narrower type.
- return static_cast<int32_t>(resultWide);
-}
-
} // namespace gl
namespace rx
diff --git a/gfx/angle/src/common/third_party/numerics/base/logging.h b/gfx/angle/src/common/third_party/numerics/base/logging.h
index 6cf05b4e6..d4e3e2402 100755
--- a/gfx/angle/src/common/third_party/numerics/base/logging.h
+++ b/gfx/angle/src/common/third_party/numerics/base/logging.h
@@ -16,7 +16,7 @@
// Unfortunately ANGLE relies on ASSERT being an empty statement, which these libs don't respect.
#ifndef NOTREACHED
-#define NOTREACHED() UNREACHABLE()
+#define NOTREACHED() 0
#endif
-#endif // BASE_LOGGING_H_
+#endif // BASE_LOGGING_H_ \ No newline at end of file
diff --git a/gfx/angle/src/common/third_party/numerics/base/numerics/safe_conversions_impl.h b/gfx/angle/src/common/third_party/numerics/base/numerics/safe_conversions_impl.h
index 1591b9c8c..798465f53 100755
--- a/gfx/angle/src/common/third_party/numerics/base/numerics/safe_conversions_impl.h
+++ b/gfx/angle/src/common/third_party/numerics/base/numerics/safe_conversions_impl.h
@@ -92,7 +92,7 @@ struct StaticDstRangeRelationToSrcRange<Dst,
static const NumericRangeRepresentation value = NUMERIC_RANGE_NOT_CONTAINED;
};
-enum RangeConstraint : unsigned char
+enum RangeConstraint
{
RANGE_VALID = 0x0, // Value can be represented by the destination type.
RANGE_UNDERFLOW = 0x1, // Value would overflow.
diff --git a/gfx/angle/src/common/utilities.cpp b/gfx/angle/src/common/utilities.cpp
index 89e383405..d9e8b660e 100755
--- a/gfx/angle/src/common/utilities.cpp
+++ b/gfx/angle/src/common/utilities.cpp
@@ -247,19 +247,7 @@ int VariableRowCount(GLenum type)
case GL_SAMPLER_2D_SHADOW:
case GL_SAMPLER_CUBE_SHADOW:
case GL_SAMPLER_2D_ARRAY_SHADOW:
- case GL_IMAGE_2D:
- case GL_INT_IMAGE_2D:
- case GL_UNSIGNED_INT_IMAGE_2D:
- case GL_IMAGE_2D_ARRAY:
- case GL_INT_IMAGE_2D_ARRAY:
- case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
- case GL_IMAGE_3D:
- case GL_INT_IMAGE_3D:
- case GL_UNSIGNED_INT_IMAGE_3D:
- case GL_IMAGE_CUBE:
- case GL_INT_IMAGE_CUBE:
- case GL_UNSIGNED_INT_IMAGE_CUBE:
- return 1;
+ return 1;
case GL_FLOAT_MAT2:
case GL_FLOAT_MAT3x2:
case GL_FLOAT_MAT4x2:
@@ -656,29 +644,6 @@ std::string ParseUniformName(const std::string &name, size_t *outSubscript)
return name.substr(0, open);
}
-template <>
-GLuint ConvertToGLuint(GLfloat param)
-{
- return uiround<GLuint>(param);
-}
-
-template <>
-GLint ConvertToGLint(GLfloat param)
-{
- return iround<GLint>(param);
-}
-
-template <>
-GLint ConvertFromGLfloat(GLfloat param)
-{
- return iround<GLint>(param);
-}
-template <>
-GLuint ConvertFromGLfloat(GLfloat param)
-{
- return uiround<GLuint>(param);
-}
-
unsigned int ParseAndStripArrayIndex(std::string *name)
{
unsigned int subscript = GL_INVALID_INDEX;
diff --git a/gfx/angle/src/common/utilities.h b/gfx/angle/src/common/utilities.h
index 16d6560a7..dc09011a2 100755
--- a/gfx/angle/src/common/utilities.h
+++ b/gfx/angle/src/common/utilities.h
@@ -68,76 +68,6 @@ bool IsTriangleMode(GLenum drawMode);
template <typename outT> outT iround(GLfloat value) { return static_cast<outT>(value > 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); }
template <typename outT> outT uiround(GLfloat value) { return static_cast<outT>(value + 0.5f); }
-// Helper for converting arbitrary GL types to other GL types used in queries and state setting
-template <typename ParamType>
-GLuint ConvertToGLuint(ParamType param)
-{
- return static_cast<GLuint>(param);
-}
-template <>
-GLuint ConvertToGLuint(GLfloat param);
-
-template <typename ParamType>
-GLint ConvertToGLint(ParamType param)
-{
- return static_cast<GLint>(param);
-}
-template <>
-GLint ConvertToGLint(GLfloat param);
-
-// Same conversion as uint
-template <typename ParamType>
-GLenum ConvertToGLenum(ParamType param)
-{
- return static_cast<GLenum>(ConvertToGLuint(param));
-}
-
-template <typename ParamType>
-GLfloat ConvertToGLfloat(ParamType param)
-{
- return static_cast<GLfloat>(param);
-}
-
-template <typename ParamType>
-ParamType ConvertFromGLfloat(GLfloat param)
-{
- return static_cast<ParamType>(param);
-}
-template <>
-GLint ConvertFromGLfloat(GLfloat param);
-template <>
-GLuint ConvertFromGLfloat(GLfloat param);
-
-template <typename ParamType>
-ParamType ConvertFromGLenum(GLenum param)
-{
- return static_cast<ParamType>(param);
-}
-
-template <typename ParamType>
-ParamType ConvertFromGLuint(GLuint param)
-{
- return static_cast<ParamType>(param);
-}
-
-template <typename ParamType>
-ParamType ConvertFromGLint(GLint param)
-{
- return static_cast<ParamType>(param);
-}
-
-template <typename ParamType>
-ParamType ConvertFromGLboolean(GLboolean param)
-{
- return static_cast<ParamType>(param ? GL_TRUE : GL_FALSE);
-}
-
-template <typename ParamType>
-ParamType ConvertFromGLint64(GLint64 param)
-{
- return clampCast<ParamType>(param);
-}
-
unsigned int ParseAndStripArrayIndex(std::string *name);
} // namespace gl