Commit 9e83c151 by Etienne Bergeron Committed by Commit Bot

Active the delegate worker pool for chromium (3/3)

This CL is activating the delegate WorkerPool in Chromium. Must land after: https://chromium-review.googlesource.com/c/angle/angle/+/2231708 Related CLs: 1) https://chromium-review.googlesource.com/c/angle/angle/+/2231708 2) https://chromium-review.googlesource.com/c/chromium/src/+/2231864 3) [this CL] Bug: chromium:1091259 Change-Id: I62c7175fec2846fee014702d8561eeaf48ca93de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2231710 Commit-Queue: Etienne Bergeron <etienneb@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 90e6fad9
...@@ -504,6 +504,9 @@ config("angle_backend_config") { ...@@ -504,6 +504,9 @@ config("angle_backend_config") {
if (angle_enable_null) { if (angle_enable_null) {
defines += [ "ANGLE_ENABLE_NULL" ] defines += [ "ANGLE_ENABLE_NULL" ]
} }
if (angle_delegate_workers) {
defines += [ "ANGLE_DELEGATE_WORKERS" ]
}
configs = [] configs = []
......
...@@ -91,6 +91,12 @@ declare_args() { ...@@ -91,6 +91,12 @@ declare_args() {
} }
declare_args() { declare_args() {
# By default, ANGLE is using a thread pool for parallel compilation.
# Activating the delegate worker results in posting the tasks using the
# embedder API. In Chromium code base, it results in sending tasks to the
# worker thread pool.
angle_delegate_workers = build_with_chromium
angle_enable_d3d9 = is_win && !angle_is_winuwp angle_enable_d3d9 = is_win && !angle_is_winuwp
angle_enable_d3d11 = is_win angle_enable_d3d11 = is_win
angle_enable_gl = angle_enable_gl =
......
...@@ -247,16 +247,11 @@ inline void DefaultCacheProgram(PlatformMethods *platform, ...@@ -247,16 +247,11 @@ inline void DefaultCacheProgram(PlatformMethods *platform,
const uint8_t *programBytes) const uint8_t *programBytes)
{} {}
using PostWorkerTaskCallback = void (*)(void *userData); using PostWorkerTaskCallback = void (*)(void *userData);
using PostWorkerTaskFunc = void (*)(PlatformMethods *platform, using PostWorkerTaskFunc = void (*)(PlatformMethods *platform,
PostWorkerTaskCallback callback, PostWorkerTaskCallback callback,
void *userData); void *userData);
inline void DefaultPostWorkerTask(PlatformMethods *platform, constexpr PostWorkerTaskFunc DefaultPostWorkerTask = nullptr;
PostWorkerTaskCallback callback,
void *userData)
{
callback(userData);
}
// Platform methods are enumerated here once. // Platform methods are enumerated here once.
#define ANGLE_PLATFORM_OP(OP) \ #define ANGLE_PLATFORM_OP(OP) \
...@@ -326,7 +321,6 @@ ANGLE_PLATFORM_EXPORT bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisp ...@@ -326,7 +321,6 @@ ANGLE_PLATFORM_EXPORT bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisp
// Sets the platform methods back to their defaults. // Sets the platform methods back to their defaults.
// If display is not valid, behaviour is undefined. // If display is not valid, behaviour is undefined.
ANGLE_PLATFORM_EXPORT void ANGLE_APIENTRY ANGLEResetDisplayPlatform(angle::EGLDisplayType display); ANGLE_PLATFORM_EXPORT void ANGLE_APIENTRY ANGLEResetDisplayPlatform(angle::EGLDisplayType display);
} // extern "C" } // extern "C"
namespace angle namespace angle
......
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
#include "libANGLE/trace.h" #include "libANGLE/trace.h"
#if (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED) #if (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED) || (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED)
# include <condition_variable> # include <condition_variable>
# include <future> # include <future>
# include <mutex> # include <mutex>
# include <queue> # include <queue>
# include <thread> # include <thread>
#endif // (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED) #endif // (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED) || (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED)
namespace angle namespace angle
{ {
...@@ -320,11 +320,13 @@ std::shared_ptr<WorkerThreadPool> WorkerThreadPool::Create(bool multithreaded) ...@@ -320,11 +320,13 @@ std::shared_ptr<WorkerThreadPool> WorkerThreadPool::Create(bool multithreaded)
std::shared_ptr<WorkerThreadPool> pool(nullptr); std::shared_ptr<WorkerThreadPool> pool(nullptr);
#if (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED) #if (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED)
if (multithreaded) const bool hasPostWorkerTaskImpl = ANGLEPlatformCurrent()->postWorkerTask;
if (hasPostWorkerTaskImpl && multithreaded)
{ {
pool = std::shared_ptr<WorkerThreadPool>(new DelegateWorkerPool()); pool = std::shared_ptr<WorkerThreadPool>(new DelegateWorkerPool());
} }
#elif (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED) #endif
#if (!pool && ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED)
if (multithreaded) if (multithreaded)
{ {
pool = std::shared_ptr<WorkerThreadPool>( pool = std::shared_ptr<WorkerThreadPool>(
......
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