Hash :
a100d8f4
Author :
Date :
2018-12-29T16:39:55
ParallelCompile: add GL backend support For GL backend, at first each worker thread must have a naitve context for its own to work in. These worker contexts have to be shared from the main context, so that all shader and program objects are seen in any context. This extends backend displays to create and destroy the worker contexts. RendererGL manages and allocates them to the worker threads. ShaderImpl has a new compile method added to do the actual glCompile work in worker thread. The ProgramGL's link method is broken down by introducing the LinkEventGL class. Bug: chromium:849576 Change-Id: Idc2c51b4b6c978781ae77810e62c480acc67ebb5 Reviewed-on: https://chromium-review.googlesource.com/c/1373015 Commit-Queue: Jie A Chen <jie.a.chen@intel.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
//
// Copyright 2016 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.
//
// WorkerThread:
// Asychronous tasks/threads for ANGLE, similar to a TaskRunner in Chromium.
// Can be implemented as different targets, depending on platform.
//
#ifndef LIBANGLE_WORKER_THREAD_H_
#define LIBANGLE_WORKER_THREAD_H_
#include <array>
#include <memory>
#include <vector>
#include "common/debug.h"
#include "libANGLE/features.h"
namespace angle
{
// A callback function with no return value and no arguments.
class Closure
{
public:
virtual ~Closure() = default;
virtual void operator()() = 0;
};
// An event that we can wait on, useful for joining worker threads.
class WaitableEvent : angle::NonCopyable
{
public:
WaitableEvent();
virtual ~WaitableEvent();
// Waits indefinitely for the event to be signaled.
virtual void wait() = 0;
// Peeks whether the event is ready. If ready, wait() will not block.
virtual bool isReady() = 0;
template <size_t Count>
static void WaitMany(std::array<std::shared_ptr<WaitableEvent>, Count> *waitables)
{
ASSERT(Count > 0);
for (size_t index = 0; index < Count; ++index)
{
(*waitables)[index]->wait();
}
}
};
// Request WorkerThreads from the WorkerThreadPool. Each pool can keep worker threads around so
// we avoid the costly spin up and spin down time.
class WorkerThreadPool : angle::NonCopyable
{
public:
WorkerThreadPool();
virtual ~WorkerThreadPool();
static std::shared_ptr<WorkerThreadPool> Create(bool multithreaded);
// Returns an event to wait on for the task to finish.
// If the pool fails to create the task, returns null.
virtual std::shared_ptr<WaitableEvent> postWorkerTask(std::shared_ptr<Closure> task) = 0;
virtual void setMaxThreads(size_t maxThreads) = 0;
virtual bool isAsync() = 0;
};
} // namespace angle
#endif // LIBANGLE_WORKER_THREAD_H_