Commit cfe14e28 by Jamie Madill Committed by Commit Bot

EGL: Remove egl::Error from validation code.

Instead of using an egl::Error return value, errors are recorded on the egl::Thread immediately at the call site. This makes the code work the same way as in the GL entry points. Updates the EGL "try" macros to include a special handler for the EGL validation entry points. Uses a special ValidationContext helper class to preserve the existing info. Bug: angleproject:5378 Change-Id: I897f221a41fe406676950600e4ac559081b9f541 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2551790 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 56663dbf
......@@ -186,6 +186,22 @@ inline bool IsError(const egl::Error &err)
return err.isError();
}
// TODO(jmadill): Remove this when refactor is complete. http://anglebug.com/3041
inline bool IsError(bool value)
{
return !value;
}
// Utility macro for handling implementation methods inside Validation.
#define ANGLE_HANDLE_VALIDATION_ERR(X) \
do \
{ \
(void)(X); \
return false; \
} while (0)
#define ANGLE_VALIDATION_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_VALIDATION_ERR)
#include "Error.inc"
#endif // LIBANGLE_ERROR_H_
......@@ -19,6 +19,10 @@ bool gUseAndroidOpenGLTlsSlot;
namespace egl
{
namespace
{
Debug *sDebug = nullptr;
} // namespace
Thread::Thread()
: mLabel(nullptr),
......@@ -42,18 +46,29 @@ void Thread::setSuccess()
mError = EGL_SUCCESS;
}
void Thread::setError(const Error &error,
const Debug *debug,
void Thread::setError(EGLint error,
const char *command,
const LabeledObject *object)
const LabeledObject *object,
const char *message)
{
ASSERT(debug != nullptr);
mError = error;
if (error != EGL_SUCCESS && message)
{
EnsureDebugAllocated();
sDebug->insertMessage(error, command, ErrorCodeToMessageType(error), getLabel(),
object ? object->getLabel() : nullptr, message);
}
}
void Thread::setError(const Error &error, const char *command, const LabeledObject *object)
{
mError = error.getCode();
if (error.isError() && !error.getMessage().empty())
{
debug->insertMessage(error.getCode(), command, ErrorCodeToMessageType(error.getCode()),
getLabel(), object ? object->getLabel() : nullptr, error.getMessage());
EnsureDebugAllocated();
sDebug->insertMessage(error.getCode(), command, ErrorCodeToMessageType(error.getCode()),
getLabel(), object ? object->getLabel() : nullptr,
error.getMessage());
}
}
......@@ -108,4 +123,24 @@ Display *Thread::getDisplay() const
}
return nullptr;
}
void EnsureDebugAllocated()
{
// All EGL calls use a global lock, this is thread safe
if (sDebug == nullptr)
{
sDebug = new Debug();
}
}
void DeallocateDebug()
{
SafeDelete(sDebug);
}
Debug *GetDebug()
{
EnsureDebugAllocated();
return sDebug;
}
} // namespace egl
......@@ -39,10 +39,14 @@ class Thread : public LabeledObject
EGLLabelKHR getLabel() const override;
void setSuccess();
void setError(const Error &error,
const Debug *debug,
void setError(EGLint error,
const char *command,
const LabeledObject *object);
const LabeledObject *object,
const char *message);
// TODO: Remove egl::Error. http://anglebug.com/3041
void setError(const Error &error, const char *command, const LabeledObject *object);
EGLint getError() const;
void setAPI(EGLenum api);
......@@ -61,6 +65,10 @@ class Thread : public LabeledObject
gl::Context *mContext;
};
void EnsureDebugAllocated();
void DeallocateDebug();
Debug *GetDebug();
} // namespace egl
#endif // LIBANGLE_THREAD_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -749,12 +749,6 @@ bool ValidateGetMultisamplefvBase(const Context *context,
const GLfloat *val);
bool ValidateSampleMaskiBase(const Context *context, GLuint maskNumber, GLbitfield mask);
// Utility macro for handling implementation methods inside Validation.
#define ANGLE_HANDLE_VALIDATION_ERR(X) \
(void)(X); \
return false
#define ANGLE_VALIDATION_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_VALIDATION_ERR)
// We should check with Khronos if returning INVALID_FRAMEBUFFER_OPERATION is OK when querying
// implementation format info for incomplete framebuffers. It seems like these queries are
// incongruent with the other errors.
......
......@@ -12,6 +12,7 @@
#include "common/platform.h"
#include "common/system_utils.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/Thread.h"
#include "libGLESv2/resource.h"
#include <atomic>
......@@ -20,8 +21,6 @@ namespace egl
{
namespace
{
Debug *g_Debug = nullptr;
ANGLE_REQUIRE_CONSTANT_INIT std::atomic<angle::GlobalMutex *> g_Mutex(nullptr);
static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value,
"global mutex is not trivially destructible");
......@@ -47,15 +46,6 @@ Thread *AllocateCurrentThread()
return gCurrentThread;
}
void AllocateDebug()
{
// All EGL calls use a global lock, this is thread safe
if (g_Debug == nullptr)
{
g_Debug = new Debug();
}
}
void AllocateMutex()
{
if (g_Mutex == nullptr)
......@@ -85,12 +75,6 @@ Thread *GetCurrentThread()
return (current ? current : AllocateCurrentThread());
}
Debug *GetDebug()
{
AllocateDebug();
return g_Debug;
}
void SetContextCurrent(Thread *thread, gl::Context *context)
{
ASSERT(gCurrentThread);
......@@ -122,17 +106,11 @@ namespace egl
namespace
{
void DeallocateCurrentThread()
{
SafeDelete(gCurrentThread);
}
void DeallocateDebug()
{
SafeDelete(g_Debug);
}
void DeallocateMutex()
{
angle::GlobalMutex *mutex = g_Mutex.exchange(nullptr);
......@@ -145,8 +123,7 @@ void DeallocateMutex()
bool InitializeProcess()
{
ASSERT(g_Debug == nullptr);
AllocateDebug();
EnsureDebugAllocated();
AllocateMutex();
return AllocateCurrentThread() != nullptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment