Nuke Builders Part 2: remove all builder code from wire

This removes blocks of code that were obviously builder-specific but
also removes the ObjectStorage::valid member that was used to implement
the maybe monad on the wire server side. This is no longer needed since
dawn_native handles the maybe monad internally now.

BUG=dawn:125

Change-Id: I8c30daae9fc70853bc1996d85a860b4877c5976c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6161
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2019-04-01 21:04:17 +00:00
committed by Commit Bot service account
parent 20b0c33913
commit cb2c64f7d9
22 changed files with 67 additions and 411 deletions

View File

@@ -158,12 +158,14 @@ TEST_F(WireArgumentTests, CStringArgument) {
pipelineDescriptor.depthStencilState = &depthStencilState;
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor);
DawnRenderPipeline apiDummyPipeline = api.GetNewRenderPipeline();
EXPECT_CALL(api,
DeviceCreateRenderPipeline(
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool {
return desc->vertexStage->entryPoint == std::string("main");
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummyPipeline));
FlushClient();
}
@@ -247,6 +249,8 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
descriptor.borderColor = DAWN_BORDER_COLOR_TRANSPARENT_BLACK;
dawnDeviceCreateSampler(device, &descriptor);
DawnSampler apiDummySampler = api.GetNewSampler();
EXPECT_CALL(api, DeviceCreateSampler(
apiDevice, MatchesLambda([](const DawnSamplerDescriptor* desc) -> bool {
return desc->nextInChain == nullptr &&
@@ -260,7 +264,7 @@ TEST_F(WireArgumentTests, StructureOfValuesArgument) {
desc->borderColor == DAWN_BORDER_COLOR_TRANSPARENT_BLACK &&
desc->lodMinClamp == kLodMin && desc->lodMaxClamp == kLodMax;
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummySampler));
FlushClient();
}
@@ -281,6 +285,8 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
descriptor.bindGroupLayouts = &bgl;
dawnDeviceCreatePipelineLayout(device, &descriptor);
DawnPipelineLayout apiDummyLayout = api.GetNewPipelineLayout();
EXPECT_CALL(api, DeviceCreatePipelineLayout(
apiDevice,
MatchesLambda([apiBgl](const DawnPipelineLayoutDescriptor* desc) -> bool {
@@ -288,7 +294,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
desc->bindGroupLayoutCount == 1 &&
desc->bindGroupLayouts[0] == apiBgl;
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummyLayout));
FlushClient();
}

View File

@@ -73,29 +73,16 @@ class WireBufferMappingTests : public WireTest {
mockBufferMapReadCallback = std::make_unique<StrictMock<MockBufferMapReadCallback>>();
mockBufferMapWriteCallback = std::make_unique<StrictMock<MockBufferMapWriteCallback>>();
{
DawnBufferDescriptor descriptor;
descriptor.nextInChain = nullptr;
DawnBufferDescriptor descriptor;
descriptor.nextInChain = nullptr;
apiBuffer = api.GetNewBuffer();
buffer = dawnDeviceCreateBuffer(device, &descriptor);
apiBuffer = api.GetNewBuffer();
buffer = dawnDeviceCreateBuffer(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(apiBuffer))
.RetiresOnSaturation();
FlushClient();
}
{
DawnBufferDescriptor descriptor;
descriptor.nextInChain = nullptr;
errorBuffer = dawnDeviceCreateBuffer(device, &descriptor);
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(nullptr))
.RetiresOnSaturation();
FlushClient();
}
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
.WillOnce(Return(apiBuffer))
.RetiresOnSaturation();
FlushClient();
}
void TearDown() override {
@@ -117,9 +104,6 @@ class WireBufferMappingTests : public WireTest {
// A successfully created buffer
DawnBuffer buffer;
DawnBuffer apiBuffer;
// An buffer that wasn't created on the server side
DawnBuffer errorBuffer;
};
// MapRead-specific tests
@@ -171,35 +155,24 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForRead) {
FlushServer();
}
// Check mapping for reading a buffer that didn't get created on the server side
TEST_F(WireBufferMappingTests, MappingForReadErrorBuffer) {
DawnCallbackUserdata userdata = 8655;
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
FlushClient();
EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
.Times(1);
FlushServer();
dawnBufferUnmap(errorBuffer);
FlushClient();
}
// Check that the map read callback is called with UNKNOWN when the buffer is destroyed before the
// request is finished
TEST_F(WireBufferMappingTests, DestroyBeforeReadRequestEnd) {
DawnCallbackUserdata userdata = 8656;
dawnBufferMapReadAsync(errorBuffer, ToMockBufferMapReadCallback, userdata);
dawnBufferMapReadAsync(buffer, ToMockBufferMapReadCallback, userdata);
// Return success
EXPECT_CALL(api, OnBufferMapReadAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() {
api.CallMapReadCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, nullptr, 0);
}));
// Destroy before the client gets the success, so the callback is called with unknown.
EXPECT_CALL(*mockBufferMapReadCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
.Times(1);
dawnBufferRelease(errorBuffer);
dawnBufferRelease(buffer);
EXPECT_CALL(api, BufferRelease(apiBuffer));
FlushClient();
FlushServer();
@@ -381,35 +354,27 @@ TEST_F(WireBufferMappingTests, ErrorWhileMappingForWrite) {
FlushServer();
}
// Check mapping for writing a buffer that didn't get created on the server side
TEST_F(WireBufferMappingTests, MappingForWriteErrorBuffer) {
DawnCallbackUserdata userdata = 8655;
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
FlushClient();
EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata))
.Times(1);
FlushServer();
dawnBufferUnmap(errorBuffer);
FlushClient();
}
// Check that the map write callback is called with UNKNOWN when the buffer is destroyed before the
// request is finished
TEST_F(WireBufferMappingTests, DestroyBeforeWriteRequestEnd) {
DawnCallbackUserdata userdata = 8656;
dawnBufferMapWriteAsync(errorBuffer, ToMockBufferMapWriteCallback, userdata);
dawnBufferMapWriteAsync(buffer, ToMockBufferMapWriteCallback, userdata);
// Return success
EXPECT_CALL(api, OnBufferMapWriteAsyncCallback(apiBuffer, _, _))
.WillOnce(InvokeWithoutArgs([&]() {
api.CallMapWriteCallback(apiBuffer, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, nullptr, 0);
}));
// Destroy before the client gets the success, so the callback is called with unknown.
EXPECT_CALL(*mockBufferMapWriteCallback,
Call(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, 0, userdata))
.Times(1);
dawnBufferRelease(buffer);
EXPECT_CALL(api, BufferRelease(apiBuffer));
dawnBufferRelease(errorBuffer);
FlushClient();
FlushServer();
}
// Check the map read callback is called with UNKNOWN when the map request would have worked, but

View File

@@ -37,7 +37,8 @@ TEST_F(WireInjectTextureTests, CallAfterReserveInject) {
ASSERT_TRUE(GetWireServer()->InjectTexture(apiTexture, reservation.id, reservation.generation));
dawnTextureCreateDefaultTextureView(reservation.texture);
EXPECT_CALL(api, TextureCreateDefaultTextureView(apiTexture)).WillOnce(Return(nullptr));
DawnTextureView apiDummyView = api.GetNewTextureView();
EXPECT_CALL(api, TextureCreateDefaultTextureView(apiTexture)).WillOnce(Return(apiDummyView));
FlushClient();
}

View File

@@ -49,6 +49,8 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
bgDesc.bindings = &binding;
dawnDeviceCreateBindGroup(device, &bgDesc);
DawnBindGroup apiDummyBindGroup = api.GetNewBindGroup();
EXPECT_CALL(api, DeviceCreateBindGroup(
apiDevice, MatchesLambda([](const DawnBindGroupDescriptor* desc) -> bool {
return desc->nextInChain == nullptr && desc->bindingCount == 1 &&
@@ -57,7 +59,7 @@ TEST_F(WireOptionalTests, OptionalObjectValue) {
desc->bindings[0].buffer == nullptr &&
desc->bindings[0].textureView == nullptr;
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummyBindGroup));
FlushClient();
}
@@ -147,6 +149,8 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
// First case: depthStencilState is not null.
pipelineDescriptor.depthStencilState = &depthStencilState;
dawnDeviceCreateRenderPipeline(device, &pipelineDescriptor);
DawnRenderPipeline apiDummyPipeline = api.GetNewRenderPipeline();
EXPECT_CALL(
api,
DeviceCreateRenderPipeline(
@@ -172,7 +176,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
desc->depthStencilState->stencilReadMask == 0xff &&
desc->depthStencilState->stencilWriteMask == 0xff;
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummyPipeline));
FlushClient();
@@ -184,7 +188,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
apiDevice, MatchesLambda([](const DawnRenderPipelineDescriptor* desc) -> bool {
return desc->depthStencilState == nullptr;
})))
.WillOnce(Return(nullptr));
.WillOnce(Return(apiDummyPipeline));
FlushClient();
}