Make angle::Result an enum.
This moves away from a class type to a value type. This should improve
performance when using angle::Result as a return value. Previously the
generated code would return a pointer instead of a value.
Improves performance in the most targeted microbenchmark by 10%. In
more realistic scanarios it will have a smaller improvement. Also
simplifies the class implementation and usage.
Includes some unrelated code generation changes.
Bug: angleproject:2491
Change-Id: Ifcf86870bf1c00a2f73c39ea6e4f05ca705050aa
Reviewed-on: https://chromium-review.googlesource.com/c/1356139
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index e57fb20..9cd9632 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -123,11 +123,11 @@
bool available;
ANGLE_TRY(query->isResultAvailable(context, &available));
*params = CastFromStateValue<T>(pname, static_cast<GLuint>(available));
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
default:
UNREACHABLE();
- return angle::Result::Stop();
+ return angle::Result::Stop;
}
}
@@ -672,7 +672,7 @@
}
// Notify the renderer of a context switch.
- return mImplementation->onMakeCurrent(this).toEGL();
+ return angle::ResultToEGL(mImplementation->onMakeCurrent(this));
}
egl::Error Context::releaseSurface(const egl::Display *display)
@@ -3523,7 +3523,7 @@
const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
mGLState.clearDirtyBits();
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMask)
@@ -3531,7 +3531,7 @@
const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask);
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
mGLState.clearDirtyBits(dirtyBits);
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
ANGLE_INLINE angle::Result Context::syncDirtyObjects(const State::DirtyObjects &objectMask)
@@ -3557,7 +3557,7 @@
ANGLE_TRY(syncDirtyObjects(mClearDirtyObjects));
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearAttachmentsInitialized(this, mask));
ANGLE_TRY(syncDirtyBits(mClearDirtyBits));
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
angle::Result Context::prepareForClearBuffer(GLenum buffer, GLint drawbuffer)
@@ -3566,7 +3566,7 @@
ANGLE_TRY(mGLState.getDrawFramebuffer()->ensureClearBufferAttachmentsInitialized(this, buffer,
drawbuffer));
ANGLE_TRY(syncDirtyBits(mClearDirtyBits));
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
ANGLE_INLINE angle::Result Context::prepareForDispatch()
@@ -3580,7 +3580,7 @@
{
ANGLE_TRY(syncDirtyObjects(objectMask));
ANGLE_TRY(syncDirtyBits(bitMask));
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
void Context::blitFramebuffer(GLint srcX0,
@@ -4494,7 +4494,7 @@
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
- if (buffer->map(this, access) == angle::Result::Stop())
+ if (buffer->map(this, access) == angle::Result::Stop)
{
return nullptr;
}
@@ -4508,7 +4508,7 @@
ASSERT(buffer);
GLboolean result;
- if (buffer->unmap(this, &result) == angle::Result::Stop())
+ if (buffer->unmap(this, &result) == angle::Result::Stop)
{
return GL_FALSE;
}
@@ -4524,7 +4524,7 @@
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
- if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop())
+ if (buffer->mapRange(this, offset, length, access) == angle::Result::Stop)
{
return nullptr;
}
@@ -4561,7 +4561,7 @@
// TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering?
ANGLE_TRY(syncDirtyBits());
- return angle::Result::Continue();
+ return angle::Result::Continue;
}
void Context::activeShaderProgram(GLuint pipeline, GLuint program)
@@ -6638,7 +6638,7 @@
GLsync syncHandle = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle));
Sync *syncObject = getSync(syncHandle);
- if (syncObject->set(this, condition, flags) == angle::Result::Stop())
+ if (syncObject->set(this, condition, flags) == angle::Result::Stop)
{
deleteSync(syncHandle);
return nullptr;
@@ -6657,7 +6657,7 @@
Sync *syncObject = getSync(sync);
GLenum result = GL_WAIT_FAILED;
- if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop())
+ if (syncObject->clientWait(this, flags, timeout, &result) == angle::Result::Stop)
{
return GL_WAIT_FAILED;
}
@@ -7189,7 +7189,7 @@
ASSERT(fenceObject->isSet() == GL_TRUE);
GLboolean result = GL_TRUE;
- if (fenceObject->test(this, &result) == angle::Result::Stop())
+ if (fenceObject->test(this, &result) == angle::Result::Stop)
{
return GL_TRUE;
}