summaryrefslogtreecommitdiffstats
path: root/Source/ThirdParty/ANGLE/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/common')
-rw-r--r--Source/ThirdParty/ANGLE/src/common/RefCountObject.cpp47
-rw-r--r--Source/ThirdParty/ANGLE/src/common/RefCountObject.h65
-rw-r--r--Source/ThirdParty/ANGLE/src/common/debug.cpp147
-rw-r--r--Source/ThirdParty/ANGLE/src/common/debug.h78
-rw-r--r--Source/ThirdParty/ANGLE/src/common/version.h10
5 files changed, 283 insertions, 64 deletions
diff --git a/Source/ThirdParty/ANGLE/src/common/RefCountObject.cpp b/Source/ThirdParty/ANGLE/src/common/RefCountObject.cpp
new file mode 100644
index 0000000..c1ef90c
--- /dev/null
+++ b/Source/ThirdParty/ANGLE/src/common/RefCountObject.cpp
@@ -0,0 +1,47 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// RefCountObject.cpp: Defines the gl::RefCountObject base class that provides
+// lifecycle support for GL objects using the traditional BindObject scheme, but
+// that need to be reference counted for correct cross-context deletion.
+// (Concretely, textures, buffers and renderbuffers.)
+
+#include "RefCountObject.h"
+
+RefCountObject::RefCountObject(GLuint id)
+{
+ mId = id;
+ mRefCount = 0;
+}
+
+RefCountObject::~RefCountObject()
+{
+ ASSERT(mRefCount == 0);
+}
+
+void RefCountObject::addRef() const
+{
+ mRefCount++;
+}
+
+void RefCountObject::release() const
+{
+ ASSERT(mRefCount > 0);
+
+ if (--mRefCount == 0)
+ {
+ delete this;
+ }
+}
+
+void RefCountObjectBindingPointer::set(RefCountObject *newObject)
+{
+ // addRef first in case newObject == mObject and this is the last reference to it.
+ if (newObject != NULL) newObject->addRef();
+ if (mObject != NULL) mObject->release();
+
+ mObject = newObject;
+}
diff --git a/Source/ThirdParty/ANGLE/src/common/RefCountObject.h b/Source/ThirdParty/ANGLE/src/common/RefCountObject.h
new file mode 100644
index 0000000..727c71c
--- /dev/null
+++ b/Source/ThirdParty/ANGLE/src/common/RefCountObject.h
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// RefCountObject.h: Defines the gl::RefCountObject base class that provides
+// lifecycle support for GL objects using the traditional BindObject scheme, but
+// that need to be reference counted for correct cross-context deletion.
+// (Concretely, textures, buffers and renderbuffers.)
+
+#ifndef COMMON_REFCOUNTOBJECT_H_
+#define COMMON_REFCOUNTOBJECT_H_
+
+#include <cstddef>
+
+#define GL_APICALL
+#include <GLES2/gl2.h>
+
+#include "common/debug.h"
+
+class RefCountObject
+{
+ public:
+ explicit RefCountObject(GLuint id);
+ virtual ~RefCountObject();
+
+ virtual void addRef() const;
+ virtual void release() const;
+
+ GLuint id() const { return mId; }
+
+ private:
+ GLuint mId;
+
+ mutable std::size_t mRefCount;
+};
+
+class RefCountObjectBindingPointer
+{
+ protected:
+ RefCountObjectBindingPointer() : mObject(NULL) { }
+ ~RefCountObjectBindingPointer() { ASSERT(mObject == NULL); } // Objects have to be released before the resource manager is destroyed, so they must be explicitly cleaned up.
+
+ void set(RefCountObject *newObject);
+ RefCountObject *get() const { return mObject; }
+
+ public:
+ GLuint id() const { return (mObject != NULL) ? mObject->id() : 0; }
+ bool operator ! () const { return (get() == NULL); }
+
+ private:
+ RefCountObject *mObject;
+};
+
+template <class ObjectType>
+class BindingPointer : public RefCountObjectBindingPointer
+{
+ public:
+ void set(ObjectType *newObject) { RefCountObjectBindingPointer::set(newObject); }
+ ObjectType *get() const { return static_cast<ObjectType*>(RefCountObjectBindingPointer::get()); }
+ ObjectType *operator -> () const { return get(); }
+};
+
+#endif // COMMON_REFCOUNTOBJECT_H_
diff --git a/Source/ThirdParty/ANGLE/src/common/debug.cpp b/Source/ThirdParty/ANGLE/src/common/debug.cpp
index 3de5d4e..845d258 100644
--- a/Source/ThirdParty/ANGLE/src/common/debug.cpp
+++ b/Source/ThirdParty/ANGLE/src/common/debug.cpp
@@ -1,44 +1,103 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// debug.cpp: Debugging utilities.
-
-#include "common/debug.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#ifndef TRACE_OUTPUT_FILE
-#define TRACE_OUTPUT_FILE "debug.txt"
-#endif
-
-static bool trace_on = true;
-
-namespace gl
-{
-void trace(const char *format, ...)
-{
-#if !defined(ANGLE_DISABLE_TRACE)
- if (trace_on)
- {
- if (format)
- {
- FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
-
- if (file)
- {
- va_list vararg;
- va_start(vararg, format);
- vfprintf(file, format, vararg);
- va_end(vararg);
-
- fclose(file);
- }
- }
- }
-#endif // !defined(ANGLE_DISABLE_TRACE)
-}
-}
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+// debug.cpp: Debugging utilities.
+
+#include "common/debug.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <d3d9.h>
+#include <windows.h>
+
+namespace gl
+{
+
+typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
+
+static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
+{
+#if !defined(ANGLE_DISABLE_PERF)
+ if (perfActive())
+ {
+ char message[32768];
+ int len = vsprintf_s(message, format, vararg);
+ if (len < 0)
+ {
+ return;
+ }
+
+ // There are no ASCII variants of these D3DPERF functions.
+ wchar_t wideMessage[32768];
+ for (int i = 0; i < len; ++i)
+ {
+ wideMessage[i] = message[i];
+ }
+ wideMessage[len] = 0;
+
+ perfFunc(0, wideMessage);
+ }
+#endif
+
+#if !defined(ANGLE_DISABLE_TRACE)
+#if defined(NDEBUG)
+ if (traceFileDebugOnly)
+ {
+ return;
+ }
+#endif
+
+ FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
+ if (file)
+ {
+ vfprintf(file, format, vararg);
+ fclose(file);
+ }
+#endif
+}
+
+void trace(bool traceFileDebugOnly, const char *format, ...)
+{
+ va_list vararg;
+ va_start(vararg, format);
+#if defined(ANGLE_DISABLE_PERF)
+ output(traceFileDebugOnly, NULL, format, vararg);
+#else
+ output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
+#endif
+ va_end(vararg);
+}
+
+bool perfActive()
+{
+#if defined(ANGLE_DISABLE_PERF)
+ return false;
+#else
+ static bool active = D3DPERF_GetStatus() != 0;
+ return active;
+#endif
+}
+
+ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
+{
+#if !defined(ANGLE_DISABLE_PERF)
+ va_list vararg;
+ va_start(vararg, format);
+ output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
+ va_end(vararg);
+#endif
+}
+
+ScopedPerfEventHelper::~ScopedPerfEventHelper()
+{
+#if !defined(ANGLE_DISABLE_PERF)
+ if (perfActive())
+ {
+ D3DPERF_EndEvent();
+ }
+#endif
+}
+}
diff --git a/Source/ThirdParty/ANGLE/src/common/debug.h b/Source/ThirdParty/ANGLE/src/common/debug.h
index 2c4ec70..9828ecf 100644
--- a/Source/ThirdParty/ANGLE/src/common/debug.h
+++ b/Source/ThirdParty/ANGLE/src/common/debug.h
@@ -12,49 +12,87 @@
#include <stdio.h>
#include <assert.h>
+#include "common/angleutils.h"
+
+#if !defined(TRACE_OUTPUT_FILE)
+#define TRACE_OUTPUT_FILE "debug.txt"
+#endif
+
namespace gl
{
// Outputs text to the debugging log
- void trace(const char *format, ...);
+ void trace(bool traceFileDebugOnly, const char *format, ...);
+
+ // Returns whether D3DPERF is active.
+ bool perfActive();
+
+ // Pairs a D3D begin event with an end event.
+ class ScopedPerfEventHelper
+ {
+ public:
+ ScopedPerfEventHelper(const char* format, ...);
+ ~ScopedPerfEventHelper();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedPerfEventHelper);
+ };
}
// A macro to output a trace of a function call and its arguments to the debugging log
-#if !defined(NDEBUG) && !defined(ANGLE_DISABLE_TRACE)
- #define TRACE(message, ...) gl::trace("trace: %s"message"\n", __FUNCTION__, __VA_ARGS__)
+#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
+#define TRACE(message, ...) (void(0))
+#else
+#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__)
+#endif
+
+// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
+#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
+#define FIXME(message, ...) (void(0))
#else
- #define TRACE(...) ((void)0)
+#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__)
#endif
-// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing. Will occur even in release mode.
-#define FIXME(message, ...) gl::trace("fixme: %s"message"\n", __FUNCTION__, __VA_ARGS__)
+// A macro to output a function call and its arguments to the debugging log, in case of error.
+#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
+#define ERR(message, ...) (void(0))
+#else
+#define ERR(message, ...) gl::trace(false, "err: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__)
+#endif
-// A macro to output a function call and its arguments to the debugging log, in case of error. Will occur even in release mode.
-#define ERR(message, ...) gl::trace("err: %s"message"\n", __FUNCTION__, __VA_ARGS__)
+// A macro to log a performance event around a scope.
+#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
+#define EVENT(message, ...) (void(0))
+#else
+#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__(__FUNCTION__ message "\n", __VA_ARGS__);
+#endif
// A macro asserting a condition and outputting failures to the debug log
+#if !defined(NDEBUG)
#define ASSERT(expression) do { \
if(!(expression)) \
ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
- assert(expression); \
+ assert(expression); \
} while(0)
-
+#else
+#define ASSERT(expression) (void(0))
+#endif
// A macro to indicate unimplemented functionality
-#ifndef NDEBUG
- #define UNIMPLEMENTED() do { \
- FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
- assert(false); \
- } while(0)
+#if !defined(NDEBUG)
+#define UNIMPLEMENTED() do { \
+ FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+ } while(0)
#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
-#ifndef NDEBUG
- #define UNREACHABLE() do { \
- ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
- assert(false); \
- } while(0)
+#if !defined(NDEBUG)
+#define UNREACHABLE() do { \
+ ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \
+ assert(false); \
+ } while(0)
#else
#define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
#endif
diff --git a/Source/ThirdParty/ANGLE/src/common/version.h b/Source/ThirdParty/ANGLE/src/common/version.h
new file mode 100644
index 0000000..203c421
--- /dev/null
+++ b/Source/ThirdParty/ANGLE/src/common/version.h
@@ -0,0 +1,10 @@
+#define MAJOR_VERSION 1
+#define MINOR_VERSION 0
+#define BUILD_VERSION 0
+#define BUILD_REVISION 1009
+
+#define STRINGIFY(x) #x
+#define MACRO_STRINGIFY(x) STRINGIFY(x)
+
+#define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION)
+#define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)