Use the correct Validation/InternalError status for CreatePipelineAsync
Bug: chromium:1404422 Change-Id: I88d354688d2a0c39be120919a8ea4b234ce9c9af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119460 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Shrek Shao <shrekshao@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
be967e31fc
commit
5860a14591
|
@ -26,82 +26,85 @@
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(std::string errorMessage,
|
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(void* userdata)
|
||||||
void* userdata)
|
: mStatus(WGPUCreatePipelineAsyncStatus_Success), mUserData(userdata) {}
|
||||||
: mErrorMessage(errorMessage), mUserData(userdata) {}
|
|
||||||
|
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(
|
||||||
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
|
std::string errorMessage,
|
||||||
|
void* userdata)
|
||||||
|
: mErrorMessage(errorMessage), mStatus(status), mUserData(userdata) {}
|
||||||
|
|
||||||
CreatePipelineAsyncCallbackTaskBase::~CreatePipelineAsyncCallbackTaskBase() = default;
|
CreatePipelineAsyncCallbackTaskBase::~CreatePipelineAsyncCallbackTaskBase() = default;
|
||||||
|
|
||||||
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
|
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
|
||||||
Ref<ComputePipelineBase> pipeline,
|
Ref<ComputePipelineBase> pipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata)
|
||||||
|
: CreatePipelineAsyncCallbackTaskBase(userdata),
|
||||||
|
mPipeline(std::move(pipeline)),
|
||||||
|
mCreateComputePipelineAsyncCallback(callback) {}
|
||||||
|
|
||||||
|
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
|
||||||
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata)
|
void* userdata)
|
||||||
: CreatePipelineAsyncCallbackTaskBase(errorMessage, userdata),
|
: CreatePipelineAsyncCallbackTaskBase(status, errorMessage, userdata),
|
||||||
mPipeline(std::move(pipeline)),
|
|
||||||
mCreateComputePipelineAsyncCallback(callback) {}
|
mCreateComputePipelineAsyncCallback(callback) {}
|
||||||
|
|
||||||
CreateComputePipelineAsyncCallbackTask::~CreateComputePipelineAsyncCallbackTask() = default;
|
CreateComputePipelineAsyncCallbackTask::~CreateComputePipelineAsyncCallbackTask() = default;
|
||||||
|
|
||||||
void CreateComputePipelineAsyncCallbackTask::Finish() {
|
void CreateComputePipelineAsyncCallbackTask::Finish() {
|
||||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||||
|
mCreateComputePipelineAsyncCallback(mStatus, ToAPI(mPipeline.Detach()), mErrorMessage.c_str(),
|
||||||
if (mPipeline.Get() != nullptr) {
|
mUserData);
|
||||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Success,
|
|
||||||
ToAPI(mPipeline.Detach()), "", mUserData);
|
|
||||||
} else {
|
|
||||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
|
||||||
mErrorMessage.c_str(), mUserData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateComputePipelineAsyncCallbackTask::HandleShutDown() {
|
void CreateComputePipelineAsyncCallbackTask::HandleShutDown() {
|
||||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||||
"Device destroyed before callback", mUserData);
|
"Device destroyed before callback", mUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateComputePipelineAsyncCallbackTask::HandleDeviceLoss() {
|
void CreateComputePipelineAsyncCallbackTask::HandleDeviceLoss() {
|
||||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||||
"Device lost before callback", mUserData);
|
"Device lost before callback", mUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
|
CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
|
||||||
Ref<RenderPipelineBase> pipeline,
|
Ref<RenderPipelineBase> pipeline,
|
||||||
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
void* userdata)
|
||||||
|
: CreatePipelineAsyncCallbackTaskBase(userdata),
|
||||||
|
mPipeline(std::move(pipeline)),
|
||||||
|
mCreateRenderPipelineAsyncCallback(callback) {}
|
||||||
|
|
||||||
|
CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
|
||||||
|
WGPUCreatePipelineAsyncStatus status,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata)
|
void* userdata)
|
||||||
: CreatePipelineAsyncCallbackTaskBase(errorMessage, userdata),
|
: CreatePipelineAsyncCallbackTaskBase(status, errorMessage, userdata),
|
||||||
mPipeline(std::move(pipeline)),
|
|
||||||
mCreateRenderPipelineAsyncCallback(callback) {}
|
mCreateRenderPipelineAsyncCallback(callback) {}
|
||||||
|
|
||||||
CreateRenderPipelineAsyncCallbackTask::~CreateRenderPipelineAsyncCallbackTask() = default;
|
CreateRenderPipelineAsyncCallbackTask::~CreateRenderPipelineAsyncCallbackTask() = default;
|
||||||
|
|
||||||
void CreateRenderPipelineAsyncCallbackTask::Finish() {
|
void CreateRenderPipelineAsyncCallbackTask::Finish() {
|
||||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||||
|
mCreateRenderPipelineAsyncCallback(mStatus, ToAPI(mPipeline.Detach()), mErrorMessage.c_str(),
|
||||||
if (mPipeline.Get() != nullptr) {
|
mUserData);
|
||||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Success,
|
|
||||||
ToAPI(mPipeline.Detach()), "", mUserData);
|
|
||||||
} else {
|
|
||||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
|
||||||
mErrorMessage.c_str(), mUserData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderPipelineAsyncCallbackTask::HandleShutDown() {
|
void CreateRenderPipelineAsyncCallbackTask::HandleShutDown() {
|
||||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||||
"Device destroyed before callback", mUserData);
|
"Device destroyed before callback", mUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderPipelineAsyncCallbackTask::HandleDeviceLoss() {
|
void CreateRenderPipelineAsyncCallbackTask::HandleDeviceLoss() {
|
||||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||||
|
|
||||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||||
"Device lost before callback", mUserData);
|
"Device lost before callback", mUserData);
|
||||||
}
|
}
|
||||||
|
@ -128,14 +131,16 @@ void CreateComputePipelineAsyncTask::Run() {
|
||||||
eventLabel);
|
eventLabel);
|
||||||
|
|
||||||
MaybeError maybeError = mComputePipeline->Initialize();
|
MaybeError maybeError = mComputePipeline->Initialize();
|
||||||
std::string errorMessage;
|
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
mComputePipeline = nullptr;
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = maybeError.AcquireError()->GetMessage();
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
|
device->GetCallbackTaskManager()->AddCallbackTask(
|
||||||
|
std::make_unique<CreateComputePipelineAsyncCallbackTask>(status, error->GetMessage(),
|
||||||
|
mCallback, mUserdata));
|
||||||
|
} else {
|
||||||
|
device->AddComputePipelineAsyncCallbackTask(mComputePipeline, mCallback, mUserdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
device->AddComputePipelineAsyncCallbackTask(mComputePipeline, errorMessage, mCallback,
|
|
||||||
mUserdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateComputePipelineAsyncTask::RunAsync(
|
void CreateComputePipelineAsyncTask::RunAsync(
|
||||||
|
@ -180,13 +185,16 @@ void CreateRenderPipelineAsyncTask::Run() {
|
||||||
eventLabel);
|
eventLabel);
|
||||||
|
|
||||||
MaybeError maybeError = mRenderPipeline->Initialize();
|
MaybeError maybeError = mRenderPipeline->Initialize();
|
||||||
std::string errorMessage;
|
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
mRenderPipeline = nullptr;
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = maybeError.AcquireError()->GetMessage();
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
|
device->GetCallbackTaskManager()->AddCallbackTask(
|
||||||
|
std::make_unique<CreateRenderPipelineAsyncCallbackTask>(status, error->GetMessage(),
|
||||||
|
mCallback, mUserdata));
|
||||||
|
} else {
|
||||||
|
device->AddRenderPipelineAsyncCallbackTask(mRenderPipeline, mCallback, mUserdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
device->AddRenderPipelineAsyncCallbackTask(mRenderPipeline, errorMessage, mCallback, mUserdata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderPipelineAsyncTask::RunAsync(std::unique_ptr<CreateRenderPipelineAsyncTask> task) {
|
void CreateRenderPipelineAsyncTask::RunAsync(std::unique_ptr<CreateRenderPipelineAsyncTask> task) {
|
||||||
|
|
|
@ -33,16 +33,23 @@ class ShaderModuleBase;
|
||||||
struct FlatComputePipelineDescriptor;
|
struct FlatComputePipelineDescriptor;
|
||||||
|
|
||||||
struct CreatePipelineAsyncCallbackTaskBase : CallbackTask {
|
struct CreatePipelineAsyncCallbackTaskBase : CallbackTask {
|
||||||
CreatePipelineAsyncCallbackTaskBase(std::string errorMessage, void* userData);
|
explicit CreatePipelineAsyncCallbackTaskBase(void* userData);
|
||||||
|
CreatePipelineAsyncCallbackTaskBase(WGPUCreatePipelineAsyncStatus status,
|
||||||
|
std::string errorMessage,
|
||||||
|
void* userData);
|
||||||
~CreatePipelineAsyncCallbackTaskBase() override;
|
~CreatePipelineAsyncCallbackTaskBase() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string mErrorMessage;
|
std::string mErrorMessage;
|
||||||
|
WGPUCreatePipelineAsyncStatus mStatus;
|
||||||
void* mUserData;
|
void* mUserData;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
||||||
CreateComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
CreateComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
CreateComputePipelineAsyncCallbackTask(WGPUCreatePipelineAsyncStatus status,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
@ -59,6 +66,9 @@ struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskB
|
||||||
|
|
||||||
struct CreateRenderPipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
struct CreateRenderPipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
||||||
CreateRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
CreateRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||||
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
CreateRenderPipelineAsyncCallbackTask(WGPUCreatePipelineAsyncStatus status,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
|
|
@ -1074,9 +1074,10 @@ void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor*
|
||||||
// callback.
|
// callback.
|
||||||
if (maybeResult.IsError()) {
|
if (maybeResult.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
||||||
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
||||||
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
callback(status, nullptr, error->GetMessage().c_str(), userdata);
|
||||||
userdata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PipelineLayoutBase* DeviceBase::APICreatePipelineLayout(
|
PipelineLayoutBase* DeviceBase::APICreatePipelineLayout(
|
||||||
|
@ -1117,9 +1118,10 @@ void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor* de
|
||||||
// callback.
|
// callback.
|
||||||
if (maybeResult.IsError()) {
|
if (maybeResult.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
||||||
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
||||||
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
callback(status, nullptr, error->GetMessage().c_str(), userdata);
|
||||||
userdata);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder(
|
RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder(
|
||||||
|
@ -1516,21 +1518,19 @@ MaybeError DeviceBase::CreateComputePipelineAsync(const ComputePipelineDescripto
|
||||||
void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Ref<ComputePipelineBase> result;
|
|
||||||
std::string errorMessage;
|
|
||||||
|
|
||||||
MaybeError maybeError = computePipeline->Initialize();
|
MaybeError maybeError = computePipeline->Initialize();
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = error->GetMessage();
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
|
std::make_unique<CreateComputePipelineAsyncCallbackTask>(status, error->GetMessage(),
|
||||||
|
callback, userdata));
|
||||||
} else {
|
} else {
|
||||||
result = AddOrGetCachedComputePipeline(std::move(computePipeline));
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
|
std::make_unique<CreateComputePipelineAsyncCallbackTask>(
|
||||||
|
AddOrGetCachedComputePipeline(std::move(computePipeline)), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateComputePipelineAsyncCallbackTask> callbackTask =
|
|
||||||
std::make_unique<CreateComputePipelineAsyncCallbackTask>(std::move(result), errorMessage,
|
|
||||||
callback, userdata);
|
|
||||||
mCallbackTaskManager->AddCallbackTask(std::move(callbackTask));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is overwritten with the async version on the backends
|
// This function is overwritten with the async version on the backends
|
||||||
|
@ -1538,21 +1538,19 @@ void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> com
|
||||||
void DeviceBase::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void DeviceBase::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Ref<RenderPipelineBase> result;
|
|
||||||
std::string errorMessage;
|
|
||||||
|
|
||||||
MaybeError maybeError = renderPipeline->Initialize();
|
MaybeError maybeError = renderPipeline->Initialize();
|
||||||
if (maybeError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = error->GetMessage();
|
WGPUCreatePipelineAsyncStatus status =
|
||||||
|
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||||
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
|
std::make_unique<CreateRenderPipelineAsyncCallbackTask>(status, error->GetMessage(),
|
||||||
|
callback, userdata));
|
||||||
} else {
|
} else {
|
||||||
result = AddOrGetCachedRenderPipeline(std::move(renderPipeline));
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
|
std::make_unique<CreateRenderPipelineAsyncCallbackTask>(
|
||||||
|
AddOrGetCachedRenderPipeline(std::move(renderPipeline)), callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateRenderPipelineAsyncCallbackTask> callbackTask =
|
|
||||||
std::make_unique<CreateRenderPipelineAsyncCallbackTask>(std::move(result), errorMessage,
|
|
||||||
callback, userdata);
|
|
||||||
mCallbackTaskManager->AddCallbackTask(std::move(callbackTask));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> DeviceBase::CreatePipelineLayout(
|
ResultOrError<Ref<PipelineLayoutBase>> DeviceBase::CreatePipelineLayout(
|
||||||
|
@ -1792,7 +1790,6 @@ dawn::platform::WorkerTaskPool* DeviceBase::GetWorkerTaskPool() const {
|
||||||
|
|
||||||
void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
||||||
Ref<ComputePipelineBase> pipeline,
|
Ref<ComputePipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
// CreateComputePipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
// CreateComputePipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
||||||
|
@ -1804,21 +1801,19 @@ void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
||||||
// TODO(dawn:529): call AddOrGetCachedComputePipeline() asynchronously in
|
// TODO(dawn:529): call AddOrGetCachedComputePipeline() asynchronously in
|
||||||
// CreateComputePipelineAsyncTaskImpl::Run() when the front-end pipeline cache is
|
// CreateComputePipelineAsyncTaskImpl::Run() when the front-end pipeline cache is
|
||||||
// thread-safe.
|
// thread-safe.
|
||||||
if (mPipeline.Get() != nullptr) {
|
ASSERT(mPipeline != nullptr);
|
||||||
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(mPipeline);
|
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(mPipeline);
|
||||||
}
|
|
||||||
|
|
||||||
CreateComputePipelineAsyncCallbackTask::Finish();
|
CreateComputePipelineAsyncCallbackTask::Finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mCallbackTaskManager->AddCallbackTask(
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(
|
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(std::move(pipeline),
|
||||||
std::move(pipeline), errorMessage, callback, userdata));
|
callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
// CreateRenderPipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
// CreateRenderPipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
||||||
|
@ -1840,8 +1835,8 @@ void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipe
|
||||||
};
|
};
|
||||||
|
|
||||||
mCallbackTaskManager->AddCallbackTask(
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
std::make_unique<CreateRenderPipelineAsyncWaitableCallbackTask>(
|
std::make_unique<CreateRenderPipelineAsyncWaitableCallbackTask>(std::move(pipeline),
|
||||||
std::move(pipeline), errorMessage, callback, userdata));
|
callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineCompatibilityToken DeviceBase::GetNextPipelineCompatibilityToken() {
|
PipelineCompatibilityToken DeviceBase::GetNextPipelineCompatibilityToken() {
|
||||||
|
|
|
@ -379,11 +379,9 @@ class DeviceBase : public RefCountedWithExternalCount {
|
||||||
dawn::platform::WorkerTaskPool* GetWorkerTaskPool() const;
|
dawn::platform::WorkerTaskPool* GetWorkerTaskPool() const;
|
||||||
|
|
||||||
void AddComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
void AddComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
void AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
void AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,18 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WGPUCreatePipelineAsyncStatus CreatePipelineAsyncStatusFromErrorType(InternalErrorType error) {
|
||||||
|
switch (error) {
|
||||||
|
case InternalErrorType::Validation:
|
||||||
|
return WGPUCreatePipelineAsyncStatus_ValidationError;
|
||||||
|
case InternalErrorType::DeviceLost:
|
||||||
|
return WGPUCreatePipelineAsyncStatus_DeviceLost;
|
||||||
|
case InternalErrorType::Internal:
|
||||||
|
case InternalErrorType::OutOfMemory:
|
||||||
|
return WGPUCreatePipelineAsyncStatus_InternalError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PipelineBase
|
// PipelineBase
|
||||||
|
|
||||||
PipelineBase::PipelineBase(DeviceBase* device,
|
PipelineBase::PipelineBase(DeviceBase* device,
|
||||||
|
|
|
@ -40,6 +40,8 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
|
||||||
const PipelineLayoutBase* layout,
|
const PipelineLayoutBase* layout,
|
||||||
SingleShaderStage stage);
|
SingleShaderStage stage);
|
||||||
|
|
||||||
|
WGPUCreatePipelineAsyncStatus CreatePipelineAsyncStatusFromErrorType(InternalErrorType error);
|
||||||
|
|
||||||
struct ProgrammableStage {
|
struct ProgrammableStage {
|
||||||
Ref<ShaderModuleBase> module;
|
Ref<ShaderModuleBase> module;
|
||||||
std::string entryPoint;
|
std::string entryPoint;
|
||||||
|
|
|
@ -213,7 +213,8 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
|
||||||
&csDesc,
|
&csDesc,
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||||
|
status);
|
||||||
|
|
||||||
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
||||||
|
@ -341,7 +342,8 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
|
||||||
&renderPipelineDescriptor,
|
&renderPipelineDescriptor,
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||||
|
status);
|
||||||
|
|
||||||
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||||
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
task->renderPipeline = wgpu::RenderPipeline::Acquire(returnPipeline);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CreatePipelineAsyncTaskTests : public DawnNativeTest {};
|
||||||
|
|
||||||
// A regression test for a null pointer issue in CreateRenderPipelineAsyncTask::Run().
|
// A regression test for a null pointer issue in CreateRenderPipelineAsyncTask::Run().
|
||||||
// See crbug.com/dawn/1310 for more details.
|
// See crbug.com/dawn/1310 for more details.
|
||||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAsync) {
|
TEST_F(CreatePipelineAsyncTaskTests, InitializationValidationErrorInCreateRenderPipelineAsync) {
|
||||||
dawn::native::DeviceBase* deviceBase =
|
dawn::native::DeviceBase* deviceBase =
|
||||||
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||||
Ref<dawn::native::RenderPipelineMock> renderPipelineMock =
|
Ref<dawn::native::RenderPipelineMock> renderPipelineMock =
|
||||||
|
@ -36,7 +36,35 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAs
|
||||||
renderPipelineMock,
|
renderPipelineMock,
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||||
|
status);
|
||||||
|
},
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
asyncTask.Run();
|
||||||
|
device.Tick();
|
||||||
|
|
||||||
|
EXPECT_CALL(*renderPipelineMock.Get(), DestroyImpl).Times(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that Internal error are converted to the InternalError status in async pipeline creation
|
||||||
|
// callbacks.
|
||||||
|
TEST_F(CreatePipelineAsyncTaskTests, InitializationInternalErrorInCreateRenderPipelineAsync) {
|
||||||
|
dawn::native::DeviceBase* deviceBase =
|
||||||
|
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||||
|
Ref<dawn::native::RenderPipelineMock> renderPipelineMock =
|
||||||
|
AcquireRef(new dawn::native::RenderPipelineMock(deviceBase));
|
||||||
|
|
||||||
|
ON_CALL(*renderPipelineMock.Get(), Initialize)
|
||||||
|
.WillByDefault(testing::Return(testing::ByMove(
|
||||||
|
DAWN_MAKE_ERROR(dawn::native::InternalErrorType::Internal, "Initialization Error"))));
|
||||||
|
|
||||||
|
dawn::native::CreateRenderPipelineAsyncTask asyncTask(
|
||||||
|
renderPipelineMock,
|
||||||
|
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||||
|
const char* message, void* userdata) {
|
||||||
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_InternalError,
|
||||||
|
status);
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
@ -48,7 +76,7 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAs
|
||||||
|
|
||||||
// A regression test for a null pointer issue in CreateComputePipelineAsyncTask::Run().
|
// A regression test for a null pointer issue in CreateComputePipelineAsyncTask::Run().
|
||||||
// See crbug.com/dawn/1310 for more details.
|
// See crbug.com/dawn/1310 for more details.
|
||||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateComputePipelineAsync) {
|
TEST_F(CreatePipelineAsyncTaskTests, InitializationValidationErrorInCreateComputePipelineAsync) {
|
||||||
dawn::native::DeviceBase* deviceBase =
|
dawn::native::DeviceBase* deviceBase =
|
||||||
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||||
Ref<dawn::native::ComputePipelineMock> computePipelineMock =
|
Ref<dawn::native::ComputePipelineMock> computePipelineMock =
|
||||||
|
@ -62,7 +90,35 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateComputePipelineA
|
||||||
computePipelineMock,
|
computePipelineMock,
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
const char* message, void* userdata) {
|
const char* message, void* userdata) {
|
||||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||||
|
status);
|
||||||
|
},
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
asyncTask.Run();
|
||||||
|
device.Tick();
|
||||||
|
|
||||||
|
EXPECT_CALL(*computePipelineMock.Get(), DestroyImpl).Times(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that Internal error are converted to the InternalError status in async pipeline creation
|
||||||
|
// callbacks.
|
||||||
|
TEST_F(CreatePipelineAsyncTaskTests, InitializationInternalErrorInCreateComputePipelineAsync) {
|
||||||
|
dawn::native::DeviceBase* deviceBase =
|
||||||
|
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||||
|
Ref<dawn::native::ComputePipelineMock> computePipelineMock =
|
||||||
|
AcquireRef(new dawn::native::ComputePipelineMock(deviceBase));
|
||||||
|
|
||||||
|
ON_CALL(*computePipelineMock.Get(), Initialize)
|
||||||
|
.WillByDefault(testing::Return(testing::ByMove(
|
||||||
|
DAWN_MAKE_ERROR(dawn::native::InternalErrorType::Internal, "Initialization Error"))));
|
||||||
|
|
||||||
|
dawn::native::CreateComputePipelineAsyncTask asyncTask(
|
||||||
|
computePipelineMock,
|
||||||
|
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||||
|
const char* message, void* userdata) {
|
||||||
|
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_InternalError,
|
||||||
|
status);
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
|
||||||
|
|
||||||
StrictMock<MockCallback<WGPUCreateComputePipelineAsyncCallback>> creationCallback;
|
StrictMock<MockCallback<WGPUCreateComputePipelineAsyncCallback>> creationCallback;
|
||||||
EXPECT_CALL(creationCallback,
|
EXPECT_CALL(creationCallback,
|
||||||
Call(WGPUCreatePipelineAsyncStatus_Error, nullptr, _, this + 1))
|
Call(WGPUCreatePipelineAsyncStatus_ValidationError, nullptr, _, this + 1))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
device.CreateComputePipelineAsync(&pipelineDesc, creationCallback.Callback(),
|
device.CreateComputePipelineAsync(&pipelineDesc, creationCallback.Callback(),
|
||||||
creationCallback.MakeUserdata(this + 1));
|
creationCallback.MakeUserdata(this + 1));
|
||||||
|
|
|
@ -145,13 +145,15 @@ TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncError) {
|
||||||
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateComputePipelineAsyncCallback(
|
api.CallDeviceCreateComputePipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
apiDevice, WGPUCreatePipelineAsyncStatus_ValidationError, nullptr,
|
||||||
|
"Some error message");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
EXPECT_CALL(
|
||||||
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
*mockCreateComputePipelineAsyncCallback,
|
||||||
|
Call(WGPUCreatePipelineAsyncStatus_ValidationError, _, StrEq("Some error message"), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
@ -211,13 +213,15 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncError) {
|
||||||
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
||||||
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
apiDevice, WGPUCreatePipelineAsyncStatus_ValidationError, nullptr,
|
||||||
|
"Some error message");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
EXPECT_CALL(
|
||||||
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
*mockCreateRenderPipelineAsyncCallback,
|
||||||
|
Call(WGPUCreatePipelineAsyncStatus_ValidationError, _, StrEq("Some error message"), this))
|
||||||
.Times(1);
|
.Times(1);
|
||||||
|
|
||||||
FlushServer();
|
FlushServer();
|
||||||
|
|
Loading…
Reference in New Issue