Metal: Support creating compute pipeline asynchronously

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I9427afbb11196c14843c6fb7bf6224afca6d63fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-06-09 00:42:46 +00:00 committed by Dawn LUCI CQ
parent cabd60d991
commit c9a6df3297
4 changed files with 28 additions and 0 deletions

View File

@ -30,6 +30,11 @@ namespace dawn_native { namespace metal {
static ResultOrError<Ref<ComputePipeline>> Create(
Device* device,
const ComputePipelineDescriptor* descriptor);
static void CreateAsync(Device* device,
const ComputePipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateComputePipelineAsyncCallback callback,
void* userdata);
void Encode(id<MTLComputeCommandEncoder> encoder);
MTLSize GetLocalWorkGroupSize() const;

View File

@ -14,6 +14,7 @@
#include "dawn_native/metal/ComputePipelineMTL.h"
#include "dawn_native/CreatePipelineAsyncTask.h"
#include "dawn_native/metal/DeviceMTL.h"
#include "dawn_native/metal/ShaderModuleMTL.h"
@ -66,4 +67,16 @@ namespace dawn_native { namespace metal {
return mRequiresStorageBufferLength;
}
void ComputePipeline::CreateAsync(Device* device,
const ComputePipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) {
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
std::make_unique<CreateComputePipelineAsyncTask>(pipeline, descriptor, blueprintHash,
callback, userdata);
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
}
}} // namespace dawn_native::metal

View File

@ -112,6 +112,10 @@ namespace dawn_native { namespace metal {
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
TextureBase* texture,
const TextureViewDescriptor* descriptor) override;
void CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) override;
void InitTogglesFromDriver();
void ShutDownImpl() override;

View File

@ -259,6 +259,12 @@ namespace dawn_native { namespace metal {
const TextureViewDescriptor* descriptor) {
return TextureView::Create(texture, descriptor);
}
void Device::CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) {
ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
}
ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
uint64_t frontendCompletedSerial{GetCompletedCommandSerial()};