WebGPU error handling 4: CommandEncoder for wire tests

These were the last use of CommandBufferBuilder in Dawn except for its
implementation in dawn_native so it is removed from dawn.json.

Also removes an already disabled test that's obsoleted by the error
handling rework.

BUG=dawn:8

Change-Id: Id2b8a3d5afcd73cc77cfcb09c6a3f851b9483aea
Reviewed-on: https://dawn-review.googlesource.com/c/4761
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2019-02-18 09:42:03 +00:00 committed by Commit Bot service account
parent 2f321dd4ab
commit 37b715deec
4 changed files with 53 additions and 159 deletions

View File

@ -271,55 +271,6 @@
"command buffer": { "command buffer": {
"category": "object" "category": "object"
}, },
"command buffer builder": {
"category": "object",
"methods": [
{
"name": "get result",
"returns": "command buffer"
},
{
"name": "begin compute pass",
"returns": "compute pass encoder"
},
{
"name": "begin render pass",
"args": [
{"name": "info", "type": "render pass descriptor"}
],
"returns": "render pass encoder"
},
{
"name": "copy buffer to buffer",
"args": [
{"name": "source", "type": "buffer"},
{"name": "source offset", "type": "uint32_t"},
{"name": "destination", "type": "buffer"},
{"name": "destination offset", "type": "uint32_t"},
{"name": "size", "type": "uint32_t"}
],
"TODO": [
"Restrictions on the alignment of the copy? Cf Metal on OSX"
]
},
{
"name": "copy buffer to texture",
"args": [
{"name": "source", "type": "buffer copy view", "annotation": "const*"},
{"name": "destination", "type": "texture copy view", "annotation": "const*"},
{"name": "copy size", "type": "extent 3D", "annotation": "const*"}
]
},
{
"name": "copy texture to buffer",
"args": [
{"name": "source", "type": "texture copy view", "annotation": "const*"},
{"name": "destination", "type": "buffer copy view", "annotation": "const*"},
{"name": "copy size", "type": "extent 3D", "annotation": "const*"}
]
}
]
},
"command encoder": { "command encoder": {
"category": "object", "category": "object",
"methods": [ "methods": [
@ -465,10 +416,6 @@
"name": "create buffer builder for testing", "name": "create buffer builder for testing",
"returns": "buffer builder" "returns": "buffer builder"
}, },
{
"name": "create command buffer builder",
"returns": "command buffer builder"
},
{ {
"name": "create command encoder", "name": "create command encoder",
"returns": "command encoder" "returns": "command encoder"

View File

@ -28,19 +28,19 @@ class WireArgumentTests : public WireTest {
// Test that the wire is able to send numerical values // Test that the wire is able to send numerical values
TEST_F(WireArgumentTests, ValueArgument) { TEST_F(WireArgumentTests, ValueArgument) {
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
dawnComputePassEncoder pass = dawnCommandBufferBuilderBeginComputePass(builder); dawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
dawnComputePassEncoderDispatch(pass, 1, 2, 3); dawnComputePassEncoderDispatch(pass, 1, 2, 3);
dawnCommandBufferBuilder apiBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)).WillOnce(Return(apiBuilder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandBufferBuilderBeginComputePass(apiBuilder)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass));
EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1); EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3)).Times(1);
EXPECT_CALL(api, CommandBufferBuilderRelease(apiBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiEncoder));
EXPECT_CALL(api, ComputePassEncoderRelease(apiPass)); EXPECT_CALL(api, ComputePassEncoderRelease(apiPass));
FlushClient(); FlushClient();
} }
@ -58,21 +58,21 @@ bool CheckPushConstantValues(const uint32_t* values) {
} }
TEST_F(WireArgumentTests, ValueArrayArgument) { TEST_F(WireArgumentTests, ValueArrayArgument) {
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
dawnComputePassEncoder pass = dawnCommandBufferBuilderBeginComputePass(builder); dawnComputePassEncoder pass = dawnCommandEncoderBeginComputePass(encoder);
dawnComputePassEncoderSetPushConstants(pass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, dawnComputePassEncoderSetPushConstants(pass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4,
testPushConstantValues); testPushConstantValues);
dawnCommandBufferBuilder apiBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)).WillOnce(Return(apiBuilder)); EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder(); dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
EXPECT_CALL(api, CommandBufferBuilderBeginComputePass(apiBuilder)).WillOnce(Return(apiPass)); EXPECT_CALL(api, CommandEncoderBeginComputePass(apiEncoder)).WillOnce(Return(apiPass));
EXPECT_CALL(api, EXPECT_CALL(api,
ComputePassEncoderSetPushConstants(apiPass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, ComputePassEncoderSetPushConstants(apiPass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4,
ResultOf(CheckPushConstantValues, Eq(true)))); ResultOf(CheckPushConstantValues, Eq(true))));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiEncoder));
EXPECT_CALL(api, ComputePassEncoderRelease(apiPass)); EXPECT_CALL(api, ComputePassEncoderRelease(apiPass));
FlushClient(); FlushClient();
@ -193,17 +193,17 @@ TEST_F(WireArgumentTests, ObjectAsValueArgument) {
EXPECT_CALL(api, RenderPassDescriptorBuilderGetResult(apiRenderPassBuilder)) EXPECT_CALL(api, RenderPassDescriptorBuilderGetResult(apiRenderPassBuilder))
.WillOnce(Return(apiRenderPass)); .WillOnce(Return(apiRenderPass));
// Create command buffer builder, setting render pass descriptor // Create command buffer encoder, setting render pass descriptor
dawnCommandBufferBuilder cmdBufBuilder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
dawnCommandBufferBuilderBeginRenderPass(cmdBufBuilder, renderPass); dawnCommandEncoderBeginRenderPass(cmdBufEncoder, renderPass);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferBuilderBeginRenderPass(apiCmdBufBuilder, apiRenderPass)).Times(1); EXPECT_CALL(api, CommandEncoderBeginRenderPass(apiCmdBufEncoder, apiRenderPass)).Times(1);
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
EXPECT_CALL(api, RenderPassDescriptorBuilderRelease(apiRenderPassBuilder)); EXPECT_CALL(api, RenderPassDescriptorBuilderRelease(apiRenderPassBuilder));
EXPECT_CALL(api, RenderPassDescriptorRelease(apiRenderPass)); EXPECT_CALL(api, RenderPassDescriptorRelease(apiRenderPass));
FlushClient(); FlushClient();
@ -215,21 +215,21 @@ TEST_F(WireArgumentTests, ObjectsAsPointerArgument) {
dawnCommandBuffer apiCmdBufs[2]; dawnCommandBuffer apiCmdBufs[2];
// Create two command buffers we need to use a GMock sequence otherwise the order of the // Create two command buffers we need to use a GMock sequence otherwise the order of the
// CreateCommandBufferBuilder might be swapped since they are equivalent in term of matchers // CreateCommandEncoder might be swapped since they are equivalent in term of matchers
Sequence s; Sequence s;
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
dawnCommandBufferBuilder cmdBufBuilder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
cmdBufs[i] = dawnCommandBufferBuilderGetResult(cmdBufBuilder); cmdBufs[i] = dawnCommandEncoderFinish(cmdBufEncoder);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.InSequence(s) .InSequence(s)
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
apiCmdBufs[i] = api.GetNewCommandBuffer(); apiCmdBufs[i] = api.GetNewCommandBuffer();
EXPECT_CALL(api, CommandBufferBuilderGetResult(apiCmdBufBuilder)) EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder))
.WillOnce(Return(apiCmdBufs[i])); .WillOnce(Return(apiCmdBufs[i]));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferRelease(apiCmdBufs[i])); EXPECT_CALL(api, CommandBufferRelease(apiCmdBufs[i]));
} }

View File

@ -26,59 +26,59 @@ class WireBasicTests : public WireTest {
// One call gets forwarded correctly. // One call gets forwarded correctly.
TEST_F(WireBasicTests, CallForwarded) { TEST_F(WireBasicTests, CallForwarded) {
dawnDeviceCreateCommandBufferBuilder(device); dawnDeviceCreateCommandEncoder(device);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
FlushClient(); FlushClient();
} }
// Test that calling methods on a new object works as expected. // Test that calling methods on a new object works as expected.
TEST_F(WireBasicTests, CreateThenCall) { TEST_F(WireBasicTests, CreateThenCall) {
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
dawnCommandBufferBuilderGetResult(builder); dawnCommandEncoderFinish(encoder);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
dawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer(); dawnCommandBuffer apiCmdBuf = api.GetNewCommandBuffer();
EXPECT_CALL(api, CommandBufferBuilderGetResult(apiCmdBufBuilder)).WillOnce(Return(apiCmdBuf)); EXPECT_CALL(api, CommandEncoderFinish(apiCmdBufEncoder)).WillOnce(Return(apiCmdBuf));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferRelease(apiCmdBuf)); EXPECT_CALL(api, CommandBufferRelease(apiCmdBuf));
FlushClient(); FlushClient();
} }
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, RefCountKeptInClient) { TEST_F(WireBasicTests, RefCountKeptInClient) {
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
dawnCommandBufferBuilderReference(builder); dawnCommandEncoderReference(encoder);
dawnCommandBufferBuilderRelease(builder); dawnCommandEncoderRelease(encoder);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
FlushClient(); FlushClient();
} }
// Test that client reference/release do not call the backend API. // Test that client reference/release do not call the backend API.
TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) { TEST_F(WireBasicTests, ReleaseCalledOnRefCount0) {
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device); dawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device);
dawnCommandBufferBuilderRelease(builder); dawnCommandEncoderRelease(encoder);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder(); dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice)) EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder)); .WillOnce(Return(apiCmdBufEncoder));
EXPECT_CALL(api, CommandBufferBuilderRelease(apiCmdBufBuilder)); EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
FlushClient(); FlushClient();
} }

View File

@ -250,56 +250,3 @@ TEST_F(WireCallbackTests, BuilderErrorCallback) {
FlushServer(); FlushServer();
} }
// Test that the server doesn't forward calls to error objects or with error objects
// Also test that when GetResult is called on an error builder, the error callback is fired
// TODO(cwallez@chromium.org): This test is disabled because the introduction of encoders breaks
// the assumptions of the "builder error" handling that a builder is self-contained. We need to
// revisit this once the new error handling is in place.
TEST_F(WireCallbackTests, DISABLED_CallsSkippedAfterBuilderError) {
dawnCommandBufferBuilder cmdBufBuilder = dawnDeviceCreateCommandBufferBuilder(device);
dawnCommandBufferBuilderSetErrorCallback(cmdBufBuilder, ToMockBuilderErrorCallback, 1, 2);
dawnRenderPassEncoder pass = dawnCommandBufferBuilderBeginRenderPass(cmdBufBuilder, nullptr);
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 3, 4);
dawnBuffer buffer = dawnBufferBuilderGetResult(bufferBuilder); // Hey look an error!
// These calls will be skipped because of the error
dawnBufferSetSubData(buffer, 0, 0, nullptr);
dawnRenderPassEncoderSetIndexBuffer(pass, buffer, 0);
dawnRenderPassEncoderEndPass(pass);
dawnCommandBufferBuilderGetResult(cmdBufBuilder);
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder();
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice))
.WillOnce(Return(apiCmdBufBuilder));
dawnRenderPassEncoder apiPass = api.GetNewRenderPassEncoder();
EXPECT_CALL(api, CommandBufferBuilderBeginRenderPass(apiCmdBufBuilder, _))
.WillOnce(Return(apiPass));
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
.WillOnce(Return(apiBufferBuilder));
// Hey look an error!
EXPECT_CALL(api, BufferBuilderGetResult(apiBufferBuilder))
.WillOnce(InvokeWithoutArgs([&]() -> dawnBuffer {
api.CallBuilderErrorCallback(apiBufferBuilder, DAWN_BUILDER_ERROR_STATUS_ERROR,
"Error");
return nullptr;
}));
EXPECT_CALL(api, BufferSetSubData(_, _, _, _)).Times(0);
EXPECT_CALL(api, RenderPassEncoderSetIndexBuffer(_, _, _)).Times(0);
EXPECT_CALL(api, CommandBufferBuilderGetResult(_)).Times(0);
FlushClient();
EXPECT_CALL(*mockBuilderErrorCallback, Call(DAWN_BUILDER_ERROR_STATUS_ERROR, _, 1, 2)).Times(1);
EXPECT_CALL(*mockBuilderErrorCallback, Call(DAWN_BUILDER_ERROR_STATUS_ERROR, _, 3, 4)).Times(1);
FlushServer();
}