mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Implement WaitableEvent and WorkerTaskPool for multi-threaded tasks
This patch adds the basic implementation of WaitableEvent and WorkerTaskPool for multi-threaded tasks in Dawn (for example, the multi-threaded implementation of CreateReady*Pipeline()). BUG=dawn:529 TEST=dawn_unittests Change-Id: Ibf84348f4c0f0d26badc19ae94cd536cef89d084 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36360 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
311a17a8fe
commit
064f33e441
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <dawn/webgpu.h>
|
||||
|
||||
@@ -60,6 +61,24 @@ namespace dawn_platform {
|
||||
CachingInterface& operator=(const CachingInterface&) = delete;
|
||||
};
|
||||
|
||||
class DAWN_PLATFORM_EXPORT WaitableEvent {
|
||||
public:
|
||||
WaitableEvent() = default;
|
||||
virtual ~WaitableEvent() = default;
|
||||
virtual void Wait() = 0; // Wait for completion
|
||||
virtual bool IsComplete() = 0; // Non-blocking check if the event is complete
|
||||
};
|
||||
|
||||
using PostWorkerTaskCallback = void (*)(void* userdata);
|
||||
|
||||
class DAWN_PLATFORM_EXPORT WorkerTaskPool {
|
||||
public:
|
||||
WorkerTaskPool() = default;
|
||||
virtual ~WorkerTaskPool() = default;
|
||||
virtual std::unique_ptr<WaitableEvent> PostWorkerTask(PostWorkerTaskCallback,
|
||||
void* userdata) = 0;
|
||||
};
|
||||
|
||||
class DAWN_PLATFORM_EXPORT Platform {
|
||||
public:
|
||||
Platform();
|
||||
@@ -85,6 +104,7 @@ namespace dawn_platform {
|
||||
// device which uses it to persistently cache objects.
|
||||
virtual CachingInterface* GetCachingInterface(const void* fingerprint,
|
||||
size_t fingerprintSize);
|
||||
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
|
||||
|
||||
private:
|
||||
Platform(const Platform&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user