Commit f16e94cd by Mohan Maiya Committed by Commit Bot

Prefer retrieval of TLS values through ASM code on Android

On the Android platform prefer using the ASM code to retrieve TLS context object even for single threaded apps. This helps get rid of a branch in GetGlobalContext() and GetValidGlobalContext() further improving the CPU perf of TLS operations. Bug: angleproject:4717 Change-Id: I58d3d3b7061d613b24f945c07bed497c7c4be25c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2250318 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com>
parent c028fc73
...@@ -116,18 +116,6 @@ ANGLE_INLINE bool SetContextToAndroidOpenGLTLSSlot(gl::Context *value) ...@@ -116,18 +116,6 @@ ANGLE_INLINE bool SetContextToAndroidOpenGLTLSSlot(gl::Context *value)
return false; return false;
} }
ANGLE_INLINE bool GetContextFromAndroidOpenGLTLSSlot(gl::Context **value)
{
#if defined(ANGLE_PLATFORM_ANDROID)
if (gUseAndroidOpenGLTlsSlot)
{
*value = static_cast<gl::Context *>(ANGLE_ANDROID_GET_GL_TLS()[kAndroidOpenGLTlsSlot]);
return true;
}
#endif
return false;
}
void SetUseAndroidOpenGLTlsSlot(bool platformTypeVulkan); void SetUseAndroidOpenGLTlsSlot(bool platformTypeVulkan);
// TODO(kbr): for POSIX platforms this will have to be changed to take // TODO(kbr): for POSIX platforms this will have to be changed to take
......
...@@ -42,18 +42,17 @@ extern Context *gSingleThreadedContext; ...@@ -42,18 +42,17 @@ extern Context *gSingleThreadedContext;
ANGLE_INLINE Context *GetGlobalContext() ANGLE_INLINE Context *GetGlobalContext()
{ {
if (gSingleThreadedContext) #if defined(ANGLE_PLATFORM_ANDROID)
// TODO: Replace this branch with a compile time flag (http://anglebug.com/4764)
if (gUseAndroidOpenGLTlsSlot)
{ {
return gSingleThreadedContext; return static_cast<gl::Context *>(ANGLE_ANDROID_GET_GL_TLS()[kAndroidOpenGLTlsSlot]);
} }
else #endif
if (gSingleThreadedContext)
{ {
Context *context; return gSingleThreadedContext;
bool fastTlsResult = GetContextFromAndroidOpenGLTLSSlot(&context);
if (fastTlsResult)
{
return context;
}
} }
egl::Thread *thread = egl::GetCurrentThread(); egl::Thread *thread = egl::GetCurrentThread();
...@@ -62,22 +61,23 @@ ANGLE_INLINE Context *GetGlobalContext() ...@@ -62,22 +61,23 @@ ANGLE_INLINE Context *GetGlobalContext()
ANGLE_INLINE Context *GetValidGlobalContext() ANGLE_INLINE Context *GetValidGlobalContext()
{ {
if (gSingleThreadedContext && !gSingleThreadedContext->isContextLost()) #if defined(ANGLE_PLATFORM_ANDROID)
// TODO: Replace this branch with a compile time flag (http://anglebug.com/4764)
if (gUseAndroidOpenGLTlsSlot)
{ {
return gSingleThreadedContext; Context *context =
} static_cast<gl::Context *>(ANGLE_ANDROID_GET_GL_TLS()[kAndroidOpenGLTlsSlot]);
else if (!gSingleThreadedContext) if (context && !context->isContextLost())
{
Context *context;
bool fastTlsResult = GetContextFromAndroidOpenGLTLSSlot(&context);
if (fastTlsResult)
{ {
if (context && !context->isContextLost()) return context;
{
return context;
}
} }
} }
#endif
if (gSingleThreadedContext && !gSingleThreadedContext->isContextLost())
{
return gSingleThreadedContext;
}
egl::Thread *thread = egl::GetCurrentThread(); egl::Thread *thread = egl::GetCurrentThread();
return thread->getValidContext(); return thread->getValidContext();
......
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