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 {
|
||||
|
||||
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(std::string errorMessage,
|
||||
void* userdata)
|
||||
: mErrorMessage(errorMessage), mUserData(userdata) {}
|
||||
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(void* userdata)
|
||||
: mStatus(WGPUCreatePipelineAsyncStatus_Success), mUserData(userdata) {}
|
||||
|
||||
CreatePipelineAsyncCallbackTaskBase::CreatePipelineAsyncCallbackTaskBase(
|
||||
WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
void* userdata)
|
||||
: mErrorMessage(errorMessage), mStatus(status), mUserData(userdata) {}
|
||||
|
||||
CreatePipelineAsyncCallbackTaskBase::~CreatePipelineAsyncCallbackTaskBase() = default;
|
||||
|
||||
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
|
||||
Ref<ComputePipelineBase> pipeline,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata)
|
||||
: CreatePipelineAsyncCallbackTaskBase(userdata),
|
||||
mPipeline(std::move(pipeline)),
|
||||
mCreateComputePipelineAsyncCallback(callback) {}
|
||||
|
||||
CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask(
|
||||
WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata)
|
||||
: CreatePipelineAsyncCallbackTaskBase(errorMessage, userdata),
|
||||
mPipeline(std::move(pipeline)),
|
||||
: CreatePipelineAsyncCallbackTaskBase(status, errorMessage, userdata),
|
||||
mCreateComputePipelineAsyncCallback(callback) {}
|
||||
|
||||
CreateComputePipelineAsyncCallbackTask::~CreateComputePipelineAsyncCallbackTask() = default;
|
||||
|
||||
void CreateComputePipelineAsyncCallbackTask::Finish() {
|
||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||
|
||||
if (mPipeline.Get() != nullptr) {
|
||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Success,
|
||||
ToAPI(mPipeline.Detach()), "", mUserData);
|
||||
} else {
|
||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
||||
mErrorMessage.c_str(), mUserData);
|
||||
}
|
||||
mCreateComputePipelineAsyncCallback(mStatus, ToAPI(mPipeline.Detach()), mErrorMessage.c_str(),
|
||||
mUserData);
|
||||
}
|
||||
|
||||
void CreateComputePipelineAsyncCallbackTask::HandleShutDown() {
|
||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||
|
||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||
"Device destroyed before callback", mUserData);
|
||||
}
|
||||
|
||||
void CreateComputePipelineAsyncCallbackTask::HandleDeviceLoss() {
|
||||
ASSERT(mCreateComputePipelineAsyncCallback != nullptr);
|
||||
|
||||
mCreateComputePipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||
"Device lost before callback", mUserData);
|
||||
}
|
||||
|
||||
CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
|
||||
Ref<RenderPipelineBase> pipeline,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata)
|
||||
: CreatePipelineAsyncCallbackTaskBase(userdata),
|
||||
mPipeline(std::move(pipeline)),
|
||||
mCreateRenderPipelineAsyncCallback(callback) {}
|
||||
|
||||
CreateRenderPipelineAsyncCallbackTask::CreateRenderPipelineAsyncCallbackTask(
|
||||
WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata)
|
||||
: CreatePipelineAsyncCallbackTaskBase(errorMessage, userdata),
|
||||
mPipeline(std::move(pipeline)),
|
||||
: CreatePipelineAsyncCallbackTaskBase(status, errorMessage, userdata),
|
||||
mCreateRenderPipelineAsyncCallback(callback) {}
|
||||
|
||||
CreateRenderPipelineAsyncCallbackTask::~CreateRenderPipelineAsyncCallbackTask() = default;
|
||||
|
||||
void CreateRenderPipelineAsyncCallbackTask::Finish() {
|
||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||
|
||||
if (mPipeline.Get() != nullptr) {
|
||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Success,
|
||||
ToAPI(mPipeline.Detach()), "", mUserData);
|
||||
} else {
|
||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
||||
mErrorMessage.c_str(), mUserData);
|
||||
}
|
||||
mCreateRenderPipelineAsyncCallback(mStatus, ToAPI(mPipeline.Detach()), mErrorMessage.c_str(),
|
||||
mUserData);
|
||||
}
|
||||
|
||||
void CreateRenderPipelineAsyncCallbackTask::HandleShutDown() {
|
||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||
|
||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceDestroyed, nullptr,
|
||||
"Device destroyed before callback", mUserData);
|
||||
}
|
||||
|
||||
void CreateRenderPipelineAsyncCallbackTask::HandleDeviceLoss() {
|
||||
ASSERT(mCreateRenderPipelineAsyncCallback != nullptr);
|
||||
|
||||
mCreateRenderPipelineAsyncCallback(WGPUCreatePipelineAsyncStatus_DeviceLost, nullptr,
|
||||
"Device lost before callback", mUserData);
|
||||
}
|
||||
|
@ -128,14 +131,16 @@ void CreateComputePipelineAsyncTask::Run() {
|
|||
eventLabel);
|
||||
|
||||
MaybeError maybeError = mComputePipeline->Initialize();
|
||||
std::string errorMessage;
|
||||
if (maybeError.IsError()) {
|
||||
mComputePipeline = nullptr;
|
||||
errorMessage = maybeError.AcquireError()->GetMessage();
|
||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||
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(
|
||||
|
@ -180,13 +185,16 @@ void CreateRenderPipelineAsyncTask::Run() {
|
|||
eventLabel);
|
||||
|
||||
MaybeError maybeError = mRenderPipeline->Initialize();
|
||||
std::string errorMessage;
|
||||
if (maybeError.IsError()) {
|
||||
mRenderPipeline = nullptr;
|
||||
errorMessage = maybeError.AcquireError()->GetMessage();
|
||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||
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) {
|
||||
|
|
|
@ -33,16 +33,23 @@ class ShaderModuleBase;
|
|||
struct FlatComputePipelineDescriptor;
|
||||
|
||||
struct CreatePipelineAsyncCallbackTaskBase : CallbackTask {
|
||||
CreatePipelineAsyncCallbackTaskBase(std::string errorMessage, void* userData);
|
||||
explicit CreatePipelineAsyncCallbackTaskBase(void* userData);
|
||||
CreatePipelineAsyncCallbackTaskBase(WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
void* userData);
|
||||
~CreatePipelineAsyncCallbackTaskBase() override;
|
||||
|
||||
protected:
|
||||
std::string mErrorMessage;
|
||||
WGPUCreatePipelineAsyncStatus mStatus;
|
||||
void* mUserData;
|
||||
};
|
||||
|
||||
struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
||||
CreateComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
CreateComputePipelineAsyncCallbackTask(WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
|
@ -59,6 +66,9 @@ struct CreateComputePipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskB
|
|||
|
||||
struct CreateRenderPipelineAsyncCallbackTask : CreatePipelineAsyncCallbackTaskBase {
|
||||
CreateRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
CreateRenderPipelineAsyncCallbackTask(WGPUCreatePipelineAsyncStatus status,
|
||||
std::string errorMessage,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
|
|
|
@ -1074,9 +1074,10 @@ void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor*
|
|||
// callback.
|
||||
if (maybeResult.IsError()) {
|
||||
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
||||
WGPUCreatePipelineAsyncStatus status =
|
||||
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
||||
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
||||
userdata);
|
||||
callback(status, nullptr, error->GetMessage().c_str(), userdata);
|
||||
}
|
||||
}
|
||||
PipelineLayoutBase* DeviceBase::APICreatePipelineLayout(
|
||||
|
@ -1117,9 +1118,10 @@ void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor* de
|
|||
// callback.
|
||||
if (maybeResult.IsError()) {
|
||||
std::unique_ptr<ErrorData> error = maybeResult.AcquireError();
|
||||
WGPUCreatePipelineAsyncStatus status =
|
||||
CreatePipelineAsyncStatusFromErrorType(error->GetType());
|
||||
// TODO(crbug.com/dawn/1122): Call callbacks only on wgpuInstanceProcessEvents
|
||||
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr, error->GetMessage().c_str(),
|
||||
userdata);
|
||||
callback(status, nullptr, error->GetMessage().c_str(), userdata);
|
||||
}
|
||||
}
|
||||
RenderBundleEncoder* DeviceBase::APICreateRenderBundleEncoder(
|
||||
|
@ -1516,21 +1518,19 @@ MaybeError DeviceBase::CreateComputePipelineAsync(const ComputePipelineDescripto
|
|||
void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
Ref<ComputePipelineBase> result;
|
||||
std::string errorMessage;
|
||||
|
||||
MaybeError maybeError = computePipeline->Initialize();
|
||||
if (maybeError.IsError()) {
|
||||
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 {
|
||||
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
|
||||
|
@ -1538,21 +1538,19 @@ void DeviceBase::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> com
|
|||
void DeviceBase::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
Ref<RenderPipelineBase> result;
|
||||
std::string errorMessage;
|
||||
|
||||
MaybeError maybeError = renderPipeline->Initialize();
|
||||
if (maybeError.IsError()) {
|
||||
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 {
|
||||
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(
|
||||
|
@ -1792,7 +1790,6 @@ dawn::platform::WorkerTaskPool* DeviceBase::GetWorkerTaskPool() const {
|
|||
|
||||
void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
||||
Ref<ComputePipelineBase> pipeline,
|
||||
std::string errorMessage,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
// CreateComputePipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
||||
|
@ -1804,21 +1801,19 @@ void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
|||
// TODO(dawn:529): call AddOrGetCachedComputePipeline() asynchronously in
|
||||
// CreateComputePipelineAsyncTaskImpl::Run() when the front-end pipeline cache is
|
||||
// thread-safe.
|
||||
if (mPipeline.Get() != nullptr) {
|
||||
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(mPipeline);
|
||||
}
|
||||
ASSERT(mPipeline != nullptr);
|
||||
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(mPipeline);
|
||||
|
||||
CreateComputePipelineAsyncCallbackTask::Finish();
|
||||
}
|
||||
};
|
||||
|
||||
mCallbackTaskManager->AddCallbackTask(
|
||||
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(
|
||||
std::move(pipeline), errorMessage, callback, userdata));
|
||||
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(std::move(pipeline),
|
||||
callback, userdata));
|
||||
}
|
||||
|
||||
void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||
std::string errorMessage,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata) {
|
||||
// CreateRenderPipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
||||
|
@ -1840,8 +1835,8 @@ void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipe
|
|||
};
|
||||
|
||||
mCallbackTaskManager->AddCallbackTask(
|
||||
std::make_unique<CreateRenderPipelineAsyncWaitableCallbackTask>(
|
||||
std::move(pipeline), errorMessage, callback, userdata));
|
||||
std::make_unique<CreateRenderPipelineAsyncWaitableCallbackTask>(std::move(pipeline),
|
||||
callback, userdata));
|
||||
}
|
||||
|
||||
PipelineCompatibilityToken DeviceBase::GetNextPipelineCompatibilityToken() {
|
||||
|
|
|
@ -379,11 +379,9 @@ class DeviceBase : public RefCountedWithExternalCount {
|
|||
dawn::platform::WorkerTaskPool* GetWorkerTaskPool() const;
|
||||
|
||||
void AddComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
||||
std::string errorMessage,
|
||||
WGPUCreateComputePipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
void AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||
std::string errorMessage,
|
||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||
void* userdata);
|
||||
|
||||
|
|
|
@ -139,6 +139,18 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
|
|||
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(DeviceBase* device,
|
||||
|
|
|
@ -40,6 +40,8 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
|
|||
const PipelineLayoutBase* layout,
|
||||
SingleShaderStage stage);
|
||||
|
||||
WGPUCreatePipelineAsyncStatus CreatePipelineAsyncStatusFromErrorType(InternalErrorType error);
|
||||
|
||||
struct ProgrammableStage {
|
||||
Ref<ShaderModuleBase> module;
|
||||
std::string entryPoint;
|
||||
|
|
|
@ -213,7 +213,8 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
|
|||
&csDesc,
|
||||
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||
const char* message, void* userdata) {
|
||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||
status);
|
||||
|
||||
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||
task->computePipeline = wgpu::ComputePipeline::Acquire(returnPipeline);
|
||||
|
@ -341,7 +342,8 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
|
|||
&renderPipelineDescriptor,
|
||||
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||
const char* message, void* userdata) {
|
||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Error, status);
|
||||
EXPECT_EQ(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_ValidationError,
|
||||
status);
|
||||
|
||||
CreatePipelineAsyncTask* task = static_cast<CreatePipelineAsyncTask*>(userdata);
|
||||
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().
|
||||
// See crbug.com/dawn/1310 for more details.
|
||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAsync) {
|
||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationValidationErrorInCreateRenderPipelineAsync) {
|
||||
dawn::native::DeviceBase* deviceBase =
|
||||
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||
Ref<dawn::native::RenderPipelineMock> renderPipelineMock =
|
||||
|
@ -36,7 +36,35 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAs
|
|||
renderPipelineMock,
|
||||
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
||||
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);
|
||||
|
||||
|
@ -48,7 +76,7 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateRenderPipelineAs
|
|||
|
||||
// A regression test for a null pointer issue in CreateComputePipelineAsyncTask::Run().
|
||||
// See crbug.com/dawn/1310 for more details.
|
||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateComputePipelineAsync) {
|
||||
TEST_F(CreatePipelineAsyncTaskTests, InitializationValidationErrorInCreateComputePipelineAsync) {
|
||||
dawn::native::DeviceBase* deviceBase =
|
||||
reinterpret_cast<dawn::native::DeviceBase*>(device.Get());
|
||||
Ref<dawn::native::ComputePipelineMock> computePipelineMock =
|
||||
|
@ -62,7 +90,35 @@ TEST_F(CreatePipelineAsyncTaskTests, InitializationErrorInCreateComputePipelineA
|
|||
computePipelineMock,
|
||||
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
||||
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);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
|
|||
|
||||
StrictMock<MockCallback<WGPUCreateComputePipelineAsyncCallback>> creationCallback;
|
||||
EXPECT_CALL(creationCallback,
|
||||
Call(WGPUCreatePipelineAsyncStatus_Error, nullptr, _, this + 1))
|
||||
Call(WGPUCreatePipelineAsyncStatus_ValidationError, nullptr, _, this + 1))
|
||||
.Times(1);
|
||||
device.CreateComputePipelineAsync(&pipelineDesc, creationCallback.Callback(),
|
||||
creationCallback.MakeUserdata(this + 1));
|
||||
|
|
|
@ -145,13 +145,15 @@ TEST_F(WireCreatePipelineAsyncTest, CreateComputePipelineAsyncError) {
|
|||
EXPECT_CALL(api, OnDeviceCreateComputePipelineAsync(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateComputePipelineAsyncCallback(
|
||||
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
||||
apiDevice, WGPUCreatePipelineAsyncStatus_ValidationError, nullptr,
|
||||
"Some error message");
|
||||
}));
|
||||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockCreateComputePipelineAsyncCallback,
|
||||
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
||||
EXPECT_CALL(
|
||||
*mockCreateComputePipelineAsyncCallback,
|
||||
Call(WGPUCreatePipelineAsyncStatus_ValidationError, _, StrEq("Some error message"), this))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
@ -211,13 +213,15 @@ TEST_F(WireCreatePipelineAsyncTest, CreateRenderPipelineAsyncError) {
|
|||
EXPECT_CALL(api, OnDeviceCreateRenderPipelineAsync(apiDevice, _, _, _))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
api.CallDeviceCreateRenderPipelineAsyncCallback(
|
||||
apiDevice, WGPUCreatePipelineAsyncStatus_Error, nullptr, "Some error message");
|
||||
apiDevice, WGPUCreatePipelineAsyncStatus_ValidationError, nullptr,
|
||||
"Some error message");
|
||||
}));
|
||||
|
||||
FlushClient();
|
||||
|
||||
EXPECT_CALL(*mockCreateRenderPipelineAsyncCallback,
|
||||
Call(WGPUCreatePipelineAsyncStatus_Error, _, StrEq("Some error message"), this))
|
||||
EXPECT_CALL(
|
||||
*mockCreateRenderPipelineAsyncCallback,
|
||||
Call(WGPUCreatePipelineAsyncStatus_ValidationError, _, StrEq("Some error message"), this))
|
||||
.Times(1);
|
||||
|
||||
FlushServer();
|
||||
|
|
Loading…
Reference in New Issue