Metal: Support creating render pipeline asynchronously

This patch implements the asynchronous path of creating render
pipeline on Metal backend.

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I3f40949f35f6cbc340bebf481bd4e204b12d86c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64880
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-09-24 00:40:59 +00:00 committed by Dawn LUCI CQ
parent 525039ddc6
commit 0e3aa3c8d0
4 changed files with 28 additions and 0 deletions

View File

@ -117,6 +117,10 @@ namespace dawn_native { namespace metal {
size_t blueprintHash, size_t blueprintHash,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) override; void* userdata) override;
void CreateRenderPipelineAsyncImpl(const RenderPipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) override;
void InitTogglesFromDriver(); void InitTogglesFromDriver();
void ShutDownImpl() override; void ShutDownImpl() override;

View File

@ -291,6 +291,12 @@ namespace dawn_native { namespace metal {
void* userdata) { void* userdata) {
ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata); ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
} }
void Device::CreateRenderPipelineAsyncImpl(const RenderPipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) {
RenderPipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
}
ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() { ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
uint64_t frontendCompletedSerial{GetCompletedCommandSerial()}; uint64_t frontendCompletedSerial{GetCompletedCommandSerial()};

View File

@ -30,6 +30,11 @@ namespace dawn_native { namespace metal {
static ResultOrError<Ref<RenderPipeline>> Create( static ResultOrError<Ref<RenderPipeline>> Create(
Device* device, Device* device,
const RenderPipelineDescriptor* descriptor); const RenderPipelineDescriptor* descriptor);
static void CreateAsync(Device* device,
const RenderPipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata);
MTLPrimitiveType GetMTLPrimitiveTopology() const; MTLPrimitiveType GetMTLPrimitiveTopology() const;
MTLWinding GetMTLFrontFace() const; MTLWinding GetMTLFrontFace() const;

View File

@ -14,6 +14,7 @@
#include "dawn_native/metal/RenderPipelineMTL.h" #include "dawn_native/metal/RenderPipelineMTL.h"
#include "dawn_native/CreatePipelineAsyncTask.h"
#include "dawn_native/VertexFormat.h" #include "dawn_native/VertexFormat.h"
#include "dawn_native/metal/DeviceMTL.h" #include "dawn_native/metal/DeviceMTL.h"
#include "dawn_native/metal/PipelineLayoutMTL.h" #include "dawn_native/metal/PipelineLayoutMTL.h"
@ -501,4 +502,16 @@ namespace dawn_native { namespace metal {
return mtlVertexDescriptor; return mtlVertexDescriptor;
} }
void RenderPipeline::CreateAsync(Device* device,
const RenderPipelineDescriptor* descriptor,
size_t blueprintHash,
WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) {
Ref<RenderPipeline> pipeline = AcquireRef(new RenderPipeline(device, descriptor));
std::unique_ptr<CreateRenderPipelineAsyncTask> asyncTask =
std::make_unique<CreateRenderPipelineAsyncTask>(pipeline, blueprintHash, callback,
userdata);
CreateRenderPipelineAsyncTask::RunAsync(std::move(asyncTask));
}
}} // namespace dawn_native::metal }} // namespace dawn_native::metal