Revert "Replace the wire serializer with a no-op impl on disconnect"

This reverts commit e757c012be.

Reason for revert: Uses a static initializer

Original change's description:
> Replace the wire serializer with a no-op impl on disconnect
>
> Now that the command serialization knows to no-op if
> GetCmdSpace returns nullptr, when the wire is disconnected,
> we can replace it with a no-op serializer that always returns
> nullptr.
>
> Bug: chromium:951558
> Change-Id: I7363fd10f529119e515eda0e743e1a7839049b9b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30000
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Reviewed-by: Stephen White <senorblanco@chromium.org>
> Commit-Queue: Austin Eng <enga@chromium.org>

TBR=cwallez@chromium.org,senorblanco@chromium.org,enga@chromium.org

Change-Id: I6549cfb27c6c5812e067ea23c6a706e84c78e1a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:951558
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30380
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2020-10-16 03:03:58 +00:00 committed by Commit Bot service account
parent 5e5f239b5f
commit b1938273e4
2 changed files with 14 additions and 22 deletions

View File

@ -19,27 +19,6 @@
namespace dawn_wire { namespace client {
namespace {
class NoopCommandSerializer final : public CommandSerializer {
public:
~NoopCommandSerializer() = default;
size_t GetMaximumAllocationSize() const final {
return 0;
}
void* GetCmdSpace(size_t size) final {
return nullptr;
}
bool Flush() final {
return false;
}
};
NoopCommandSerializer gNoopCommandSerializer;
} // anonymous namespace
Client::Client(CommandSerializer* serializer, MemoryTransferService* memoryTransferService)
: ClientBase(), mSerializer(serializer), mMemoryTransferService(memoryTransferService) {
if (mMemoryTransferService == nullptr) {
@ -74,7 +53,11 @@ namespace dawn_wire { namespace client {
}
void Client::Disconnect() {
mSerializer = ChunkedCommandSerializer(&gNoopCommandSerializer);
if (mDisconnected) {
return;
}
mDisconnected = true;
if (mDevice != nullptr) {
mDevice->HandleDeviceLost("GPU connection lost");
}

View File

@ -48,6 +48,10 @@ namespace dawn_wire { namespace client {
template <typename Cmd>
void SerializeCommand(const Cmd& cmd) {
// TODO(enga): Swap out the serializer with a no-op one on disconnect.
if (mDisconnected) {
return;
}
mSerializer.SerializeCommand(cmd, *this);
}
@ -55,6 +59,10 @@ namespace dawn_wire { namespace client {
void SerializeCommand(const Cmd& cmd,
size_t extraSize,
ExtraSizeSerializeFn&& SerializeExtraSize) {
// TODO(enga): Swap out the serializer with a no-op one on disconnect.
if (mDisconnected) {
return;
}
mSerializer.SerializeCommand(cmd, *this, extraSize, SerializeExtraSize);
}
@ -68,6 +76,7 @@ namespace dawn_wire { namespace client {
WireDeserializeAllocator mAllocator;
MemoryTransferService* mMemoryTransferService = nullptr;
std::unique_ptr<MemoryTransferService> mOwnedMemoryTransferService = nullptr;
bool mDisconnected = false;
};
std::unique_ptr<MemoryTransferService> CreateInlineMemoryTransferService();