D3D12: Support creating compute pipeline asynchronously

This patch implements the asynchronous path of CreateComputePipelineAsync
on D3D12 backend with the basic framework of the dawn_unittest
AsyncTaskTest.Basic.

1. Call the constructor of dawn_native::d3d12::ComputePipeline in the main
   thread.
2. Execute dawn_native::ComputePipelineBase::Initialize() (a virtual function)
   asynchronously.
3. Ensure every operation in dawn_native::d3d12::ComputePipeline::Initialize()
   is thread-safe (PersistentCache).
4. Save all the return values (pipeline object or error message, userdata, etc)
   in a CreateComputePipelineAsyncWaitableCallbackTask object and insert this
   callback task into CallbackTaskManager.
5. In Callback.Finish():
- Insert the pipeline object into the pipeline cache if necessary
- Call WGPUCreateComputePipelineAsyncCallback

Note that as we always handle the front-end pipeline cache in the main thread,
we don't need to make it thread-safe right now.

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I7eba2ce550b32439a94b2a4d1aa7f1b3383aa514
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47900
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Jiawei Shao
2021-06-04 05:12:06 +00:00
committed by Dawn LUCI CQ
parent 2adb3c83e4
commit 5e1ca53269
19 changed files with 270 additions and 26 deletions

View File

@@ -29,6 +29,7 @@ namespace dawn_native {
if (mCache == nullptr) {
return blob;
}
std::lock_guard<std::mutex> lock(mMutex);
blob.bufferSize = mCache->LoadData(reinterpret_cast<WGPUDevice>(mDevice), key.data(),
key.size(), nullptr, 0);
if (blob.bufferSize > 0) {
@@ -48,6 +49,7 @@ namespace dawn_native {
}
ASSERT(value != nullptr);
ASSERT(size > 0);
std::lock_guard<std::mutex> lock(mMutex);
mCache->StoreData(reinterpret_cast<WGPUDevice>(mDevice), key.data(), key.size(), value,
size);
}