Reject createPipelineAsync callback if unsafe APIs are disabled
Async functions should fail by rejecting the callback instead of generating a device error. This fixes a leak in the wire where the allocation for the callback was never delete since it was never called. Fixed: chromium:1181627 Change-Id: I840073c1d1b5f1401aa8ed29d3c8f0e1e4fefd35 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42540 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
7564ae1def
commit
87649ff09d
|
@ -711,9 +711,10 @@ namespace dawn_native {
|
||||||
ComputePipelineBase* result = nullptr;
|
ComputePipelineBase* result = nullptr;
|
||||||
|
|
||||||
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||||
ConsumedError(
|
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
||||||
DAWN_VALIDATION_ERROR("CreateComputePipelineAsync is disallowed because it isn't "
|
"CreateComputePipelineAsync is disallowed because it isn't completely "
|
||||||
"completely implemented yet."));
|
"implemented yet.",
|
||||||
|
userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,9 +764,10 @@ namespace dawn_native {
|
||||||
RenderPipelineBase* result = nullptr;
|
RenderPipelineBase* result = nullptr;
|
||||||
|
|
||||||
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||||
ConsumedError(
|
callback(WGPUCreatePipelineAsyncStatus_Error, nullptr,
|
||||||
DAWN_VALIDATION_ERROR("CreateRenderPipelineAsync is disallowed because it isn't "
|
"CreateRenderPipelineAsync is disallowed because it isn't completely "
|
||||||
"completely implemented yet."));
|
"implemented yet.",
|
||||||
|
userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
|
#include "tests/MockCallback.h"
|
||||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
@ -223,15 +224,13 @@ TEST_F(UnsafeAPIValidationTest, CreateComputePipelineAsyncDisallowed) {
|
||||||
// Control case: CreateComputePipeline is allowed.
|
// Control case: CreateComputePipeline is allowed.
|
||||||
device.CreateComputePipeline(&desc);
|
device.CreateComputePipeline(&desc);
|
||||||
|
|
||||||
|
testing::MockCallback<WGPUCreateComputePipelineAsyncCallback> callback;
|
||||||
|
EXPECT_CALL(callback,
|
||||||
|
Call(WGPUCreatePipelineAsyncStatus_Error, nullptr, testing::NotNull(), this));
|
||||||
// Error case: CreateComputePipelineAsync is disallowed.
|
// Error case: CreateComputePipelineAsync is disallowed.
|
||||||
ASSERT_DEVICE_ERROR(device.CreateComputePipelineAsync(
|
device.CreateComputePipelineAsync(&desc, callback.Callback(), callback.MakeUserdata(this));
|
||||||
&desc,
|
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPUComputePipeline returnPipeline,
|
WaitForAllOperations(device);
|
||||||
const char* message, void* userdata) {
|
|
||||||
// Status can be Error or Unkown (when using the wire).
|
|
||||||
EXPECT_NE(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Success, status);
|
|
||||||
},
|
|
||||||
nullptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that CreateRenderPipelineAsync is disallowed as part of unsafe APIs
|
// Check that CreateRenderPipelineAsync is disallowed as part of unsafe APIs
|
||||||
|
@ -252,13 +251,11 @@ TEST_F(UnsafeAPIValidationTest, CreateRenderPipelineAsyncDisallowed) {
|
||||||
// Control case: CreateRenderPipeline is allowed.
|
// Control case: CreateRenderPipeline is allowed.
|
||||||
device.CreateRenderPipeline(&desc);
|
device.CreateRenderPipeline(&desc);
|
||||||
|
|
||||||
|
testing::MockCallback<WGPUCreateRenderPipelineAsyncCallback> callback;
|
||||||
|
EXPECT_CALL(callback,
|
||||||
|
Call(WGPUCreatePipelineAsyncStatus_Error, nullptr, testing::NotNull(), this));
|
||||||
// Error case: CreateRenderPipelineAsync is disallowed.
|
// Error case: CreateRenderPipelineAsync is disallowed.
|
||||||
ASSERT_DEVICE_ERROR(device.CreateRenderPipelineAsync(
|
device.CreateRenderPipelineAsync(&desc, callback.Callback(), callback.MakeUserdata(this));
|
||||||
&desc,
|
|
||||||
[](WGPUCreatePipelineAsyncStatus status, WGPURenderPipeline returnPipeline,
|
WaitForAllOperations(device);
|
||||||
const char* message, void* userdata) {
|
|
||||||
// Status can be Error or Unkown (when using the wire).
|
|
||||||
EXPECT_NE(WGPUCreatePipelineAsyncStatus::WGPUCreatePipelineAsyncStatus_Success, status);
|
|
||||||
},
|
|
||||||
nullptr));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue